Skip to content

Conversation

@frontier159
Copy link
Owner

No description provided.

@frontier159 frontier159 changed the title Initial attempt extendLock Apr 27, 2022
@mountainpath9
Copy link

General comment - this includes both efficiency improvements and new behavior. It would make the ultimate approvers job easier if these were separate PRs, so that the new desired behaviour is clear and a minimal change.

return _withdrawLocked(msg.sender, destination_address, kek_id, arr_idx);
}

// Overloaded to take the arr_idx such that it can be computed off-chain.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is computing the index off chain reasonable?

Is it not that the case that the array index calculated may become out of date before it is used in which case _getState () will fail with "Stake not found" ?

Copy link
Owner Author

@frontier159 frontier159 Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it could given we're now pop()'ing the item out of the array (leaving as a delete wouldn't change the arr_idx)

It was my concern too, but according to @butlerji it's ok to make it a concern of the client to handle correctly.

That's one of the reasons I left the old version too which only takes the kek_id...again up to FRAX to comment operationally I think.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it a concern of the client to handle correctly.

@butlerji I don't see how this would work. Would the client specifically detect the "Stake not found" error, and then know this is a reason to retry?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the flow would be pretty synchronous and single-threaded for a given address.

So first start with: myLockedStakes = contract.lockedStakesOf(myAddress)

Then if the client calls withdrawLocked() then its local array should change too for any subsequent calls (or just call contract.lockedStakesOf(myAddress) again)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the flow would be pretty synchronous and single-threaded for a given address.

Oh - I misunderstood. I thought the array was being used for all addresses.

@frontier159
Copy link
Owner Author

frontier159 commented Apr 28, 2022

General comment - this includes both efficiency improvements and new behavior. It would make the ultimate approvers job easier if these were separate PRs, so that the new desired behaviour is clear and a minimal change.

@mountainpath9 Perhaps, but given these combined changes aren't too complex I think we want the FRAX team to look at it all as one.

Operationally, we may be calling stakeLocked() many times for the same account, so (according to @butlerji) that lockedStakes[account] array could get large enough to cause painful gas issues over time (eg 100 items)

Copy link

@princetonbishop princetonbishop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments


// Update the rewards array
for (uint256 i = 0; i < earned_arr.length; i++){
// Update the rewards array

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick - on open source projects, I find the min changes you can make (basically make the reviewers job so fucking easy) the quicker you can get stuff landed. As you build up trust/rep you can start moving stuff around a bit more.

With that perspective, when putting this PR up as a draft for travis, I'd add comments calling out that this is just some loop fusion to make things a bit more efficient (possibly required to keep overall size down), and can be reverted if he prefers for simplicity.

Basically, call out explicitly what's nice to have vs the core change that must land :)

sync_gauge_weights(false);

// Update the fraxPerLPStored
fraxPerLPStored = fraxPerLPToken();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not super obvious this code change is simply algebra moving terms around vs changing the actual implementation of something.

If just algebra, when sharing with Travis, post what you think this achieves/why it's worth the risk of change

//
// For discussion: Do we need to keep this older version (on-chain arr_idx lookup)?
// Is overload ok, or better to have a v2?
function lockAdditional(bytes32 kek_id, uint256 addl_liq) public {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what we are after - we only care about refreshing locks (as we'll never have more than a single active lock).

Do we leave this out w.r.t optimising getting our refreshing changes in (maybe similar to the above - keep calling out this is a nice to have)

}

// Extend the lock period on an existing stake by secs
function extendLock(bytes32 kek_id, uint256 arr_idx, uint256 secs) updateRewardAndBalance(msg.sender, true) public returns (bytes32) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO I'd be partial to lockAdditional being overloaded with an extend secs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants