Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains two options for mitigating the issue described in #1991.
Solution 1
The first solution found in file
deposit_v4
is a general reduction in the gas used across the contract. These changes reduce the reading and writing to storage when writing future committees but the issue of uneven gas costs remains.The effects of the changes can be seen in the below table:
The 2nd
depositTopUp
is so much cheaper because we do not need to write new keys to storage, only update the balances.Solution 2
The second solution is in
deposit_v5
. This is an attempt to remove the uneven gas cost of thedepositTopUp()
call by removing the need to writefutureCommittee
all together and having the committee calculated on the fly whenever it is required.The code's outline is complete but the solution is unfinished. TODO:
committee()
scales with number of depositors. Is it acceptable to pay this gas fee in all scenarios in which it is called?StakerMoved
. Figure out how we can continue to support the behavior expected by third parties and consensus