-
Notifications
You must be signed in to change notification settings - Fork 925
More proposer shuffling cleanup #8130
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
base: unstable
Are you sure you want to change the base?
Changes from all commits
77cb635
59b873b
e9b7a51
5aba2ec
ffe1c82
5fcaeb2
3520fa4
fc3a5e9
59cbaba
f3f94b3
a4ab920
6ce8fd8
97da066
3171c12
a9ff728
ff5edd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ use smallvec::SmallVec; | |
use state_processing::state_advance::partial_state_advance; | ||
use std::num::NonZeroUsize; | ||
use std::sync::Arc; | ||
use tracing::instrument; | ||
use types::non_zero_usize::new_non_zero_usize; | ||
use types::{ | ||
BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, Fork, Hash256, Slot, Unsigned, | ||
|
@@ -199,11 +200,14 @@ pub fn compute_proposer_duties_from_head<T: BeaconChainTypes>( | |
.map_err(BeaconChainError::from)?; | ||
|
||
let dependent_root = state | ||
// The only block which decides its own shuffling is the genesis block. | ||
.proposer_shuffling_decision_root(chain.genesis_block_root, &chain.spec) | ||
.proposer_shuffling_decision_root_at_epoch(request_epoch, head_block_root, &chain.spec) | ||
.map_err(BeaconChainError::from)?; | ||
|
||
Ok((indices, dependent_root, execution_status, state.fork())) | ||
// Use fork_at_epoch rather than the state's fork, because post-Fulu we may not have advanced | ||
// the state completely into the new epoch. | ||
let fork = chain.spec.fork_at_epoch(request_epoch); | ||
|
||
Ok((indices, dependent_root, execution_status, fork)) | ||
} | ||
|
||
/// If required, advance `state` to the epoch required to determine proposer indices in `target_epoch`. | ||
|
@@ -214,6 +218,7 @@ pub fn compute_proposer_duties_from_head<T: BeaconChainTypes>( | |
/// - No-op if `state.current_epoch() == target_epoch`. | ||
/// - It must be the case that `state.canonical_root() == state_root`, but this function will not | ||
/// check that. | ||
#[instrument(skip_all, fields(?state_root, %target_epoch, state_slot = %state.slot()), level = "debug")] | ||
pub fn ensure_state_can_determine_proposers_for_epoch<E: EthSpec>( | ||
state: &mut BeaconState<E>, | ||
state_root: Hash256, | ||
|
@@ -234,14 +239,6 @@ pub fn ensure_state_can_determine_proposers_for_epoch<E: EthSpec>( | |
if state.current_epoch() > maximum_epoch { | ||
Err(BeaconStateError::SlotOutOfBounds.into()) | ||
} else if state.current_epoch() >= minimum_epoch { | ||
if target_epoch > state.current_epoch() { | ||
let target_slot = target_epoch.start_slot(E::slots_per_epoch()); | ||
|
||
// Advance the state into the same epoch as the block. Use the "partial" method since state | ||
// roots are not important for proposer/attester shuffling. | ||
partial_state_advance(state, Some(state_root), target_slot, spec) | ||
.map_err(BeaconChainError::from)?; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not necessary anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pawan added this to work around the fact that we weren't advancing into the Fulu fork epoch to compute its shuffling (we were wrongly assuming we had lookahead). Now that we've fixed the function to calculate the decision slot, this is no longer a concern. In this PR we've also started using Removing the advance means we can take advantage of the lookahead post-Fulu. We avoid doing up to 1 epoch of unnecessary state advance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gloas fork epoch test added in 3171c12 |
||
Ok(()) | ||
} else { | ||
// State's current epoch is less than the minimum epoch. | ||
|
Uh oh!
There was an error while loading. Please reload this page.