-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove withdrawn_epoch #2998
remove withdrawn_epoch #2998
Conversation
e656d85
to
a6ad484
Compare
a6ad484
to
70f90c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR logic looks good to me. Great work 👍
We need to double-check if we do want the "re-use indices" feature.
- Pros:
- Code simplification
- Save data storage and validator set iteration time
- Cons:
- The
fully_withdrawn_epoch
was useful to look up the validator withdrawal time. - The validator index is no more the reliable identifier. It has to come with their pubkey.
- The
Generally, I think pros > cons, so the PR looks good to me. 👍 But would love to hear more feedback too.
tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py
Outdated
Show resolved
Hide resolved
tests/core/pyspec/eth2spec/test/capella/epoch_processing/test_process_full_withdrawals.py
Show resolved
Hide resolved
I am not fully convinced that reusing the validator index is really that much impactful. It sounds to me as an implementation detail more than a specification item I am concerned by validator registry size. But applications could simply delete the validator entry from whatever storage option they choose and add an |
I would like to capitalize on this optimization even if re-usable indexes are not adopted. The validator tree is the most expensive part of the state, not increasing depth by one unless really necessary has a non-negligible impact |
Depth does not change in the validator registry Merkle tree, the hack is that if you lay out all field roots contiguously you can hash that tree as if it were of depth The point I want to make is that we can easily keep the validator registry dense, not sparse, and not reuse validator indices at the same time without much complexity, and the cost of having to check public key is likely worse than simply adding an scalar index field. |
I just mainly want to point out that use of |
Co-authored-by: Hsiao-Wei Wang <hsiaowei.eth@gmail.com>
2dc6e0c
to
91ea9e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
I like keeping the option to implement reusable validator indices (even though it is in aggregate probably not our best idea) and this PR would keep the validator subtree aligned along nice power of two
I left two suggestions for what I think are missing assert
s and otherwise just some notes in case anyone is ever reviewing this later
yield from run_epoch_processing_with(spec, state, 'process_full_withdrawals') | ||
yield 'pre', state | ||
spec.process_full_withdrawals(state) | ||
yield 'post', state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to not use the run_epoch_processing_with
helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this pattern is useful when you need to capture information right before the function is called.
In this case, balance updates can/will occur during those interim epoch processings. So in some cases this changes the to_be_withdrawn
indices in some test cases
tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py
Outdated
Show resolved
Hide resolved
tests/core/pyspec/eth2spec/test/capella/block_processing/test_process_deposit.py
Outdated
Show resolved
Hide resolved
initial_balance = spec.MAX_EFFECTIVE_BALANCE - 1000 | ||
initial_effective_balance = spec.MAX_EFFECTIVE_BALANCE - spec.EFFECTIVE_BALANCE_INCREMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this violates some spec invariants but is not material for the thing this test intends to verify so we can let it be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not actually do so
You can have an epoch in which your balance was initially spec.MAX_EFFECTIVE_BALANCE - spec.EFFECTIVE_BALANCE_INCREMENT - 1000
and your initial effective balance is as above. Then you could receiv a 1 ETH deposit, pushing your balance (and effective) to the balance above as your initial conditional
Co-authored-by: Alex Stokes <r.alex.stokes@gmail.com>
b731098
to
bfca7f9
Compare
Handle 4th point in #2758 due to the desire to not change the shape of the validators datastructure and merkle tree.
fully_withdrawn_epoch
The point of
fully_withdrawn_epoch
is to be able to potentially re-use indices after some extended period of non-use (e.g. 3x max best-WS period -- (3x4) 12 months). A zero balance andwithdrawable_epoch
are sufficient to capture this logic for safe reuse. Thus removefully_withdrawn_epoch
In the event that a top-up is made to such a validator, a new full withdrawal is initiated. This requires 1ETH to perform and is rate limited by the
Deposit
queue.