-
Notifications
You must be signed in to change notification settings - Fork 932
Gloas process epoch #8287
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
Open
shane-moore
wants to merge
3
commits into
sigp:gloas-envelope-processing
Choose a base branch
from
shane-moore:epbs-process-epoch
base: gloas-envelope-processing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+90
−1
Open
Gloas process epoch #8287
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pub use process_builder_pending_payments::process_builder_pending_payments; | ||
|
|
||
| mod process_builder_pending_payments; |
64 changes: 64 additions & 0 deletions
64
...ensus/state_processing/src/per_epoch_processing/gloas/process_builder_pending_payments.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use crate::EpochProcessingError; | ||
| use safe_arith::SafeArith; | ||
| use types::{BeaconState, BuilderPendingPayment, ChainSpec, EthSpec, Vector}; | ||
|
|
||
| /// TODO(EIP-7732): Add EF consensus-spec tests for `process_builder_pending_payments` | ||
| /// Currently blocked by EF consensus-spec-tests for Gloas not yet integrated. | ||
| pub fn process_builder_pending_payments<E: EthSpec>( | ||
| state: &mut BeaconState<E>, | ||
| spec: &ChainSpec, | ||
| ) -> Result<(), EpochProcessingError> { | ||
| let quorum = get_builder_payment_quorum_threshold(state, spec)?; | ||
|
|
||
| // Collect qualifying payments | ||
| let qualifying_payments = state | ||
| .builder_pending_payments()? | ||
| .iter() | ||
| .take(E::slots_per_epoch() as usize) | ||
| .filter(|payment| payment.weight > quorum) | ||
| .cloned() | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| // Update `builder_pending_withdrawals` with qualifying `builder_pending_payments` | ||
| qualifying_payments.into_iter().try_for_each( | ||
| |payment| -> Result<(), EpochProcessingError> { | ||
| let exit_queue_epoch = | ||
| state.compute_exit_epoch_and_update_churn(payment.withdrawal.amount, spec)?; | ||
| let withdrawable_epoch = | ||
| exit_queue_epoch.safe_add(spec.min_validator_withdrawability_delay)?; | ||
|
|
||
| let mut withdrawal = payment.withdrawal.clone(); | ||
| withdrawal.withdrawable_epoch = withdrawable_epoch; | ||
| state.builder_pending_withdrawals_mut()?.push(withdrawal)?; | ||
| Ok(()) | ||
| }, | ||
| )?; | ||
|
|
||
| // Move remaining `builder_pending_payments` to start of list and set the rest to default | ||
| let new_payments = state | ||
| .builder_pending_payments()? | ||
| .iter() | ||
| .skip(E::slots_per_epoch() as usize) | ||
| .cloned() | ||
| .chain((0..E::slots_per_epoch() as usize).map(|_| BuilderPendingPayment::default())) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| *state.builder_pending_payments_mut()? = Vector::new(new_payments)?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| pub fn get_builder_payment_quorum_threshold<E: EthSpec>( | ||
| state: &BeaconState<E>, | ||
| spec: &ChainSpec, | ||
| ) -> Result<u64, EpochProcessingError> { | ||
| let total_active_balance = state.get_total_active_balance()?; | ||
|
|
||
| let quorum = total_active_balance | ||
| .safe_div(E::slots_per_epoch())? | ||
| .safe_mul(spec.builder_payment_threshold_numerator)?; | ||
|
|
||
| quorum | ||
| .safe_div(spec.builder_payment_threshold_denominator) | ||
| .map_err(EpochProcessingError::from) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
So this isn't actually epoch processing. If you look at what calls this
process_epoch()function, you will see it is only used in tests and in generating an epoch summary. The actual epoch processing is inprocess_epoch_single_pass()which uses an optimized single pass version of epoch processing. Michael did an algorithmic description here. I would have a look at howprocess_proposer_lookahead()was implemented if you want to do this.