mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
fix tests
This commit is contained in:
@@ -92,45 +92,35 @@ impl GossipVerifiedProposerPreferences {
|
|||||||
return Err(ProposerPreferencesError::DependentRootNotCanonical { dependent_root });
|
return Err(ProposerPreferencesError::DependentRootNotCanonical { dependent_root });
|
||||||
}
|
}
|
||||||
let dependent_state_root = dependent_block.state_root;
|
let dependent_state_root = dependent_block.state_root;
|
||||||
let dependent_block_slot = dependent_block.slot;
|
|
||||||
drop(fork_choice);
|
drop(fork_choice);
|
||||||
|
|
||||||
// Fetch the state at the dependent_root block.
|
// We need a state at `target_epoch` so we have the correct proposer lookahead.
|
||||||
// Per spec, we need the checkpoint state at epoch (proposal_epoch - MIN_SEED_LOOKAHEAD).
|
|
||||||
// The dependent_root is the block root at the proposer shuffling decision slot.
|
|
||||||
let (state_root, mut dependent_state) = ctx
|
|
||||||
.store
|
|
||||||
.get_advanced_hot_state(dependent_root, dependent_block_slot, dependent_state_root)
|
|
||||||
.map_err(crate::BeaconChainError::DBError)?
|
|
||||||
.ok_or(ProposerPreferencesError::DependentRootUnknown { dependent_root })?;
|
|
||||||
|
|
||||||
// We need to advance the state to `target_epoch` so epoch transition runs and
|
|
||||||
// `process_proposer_lookahead` populates the lookahead for the proposal epoch.
|
|
||||||
let proposal_epoch = proposal_slot.epoch(T::EthSpec::slots_per_epoch());
|
let proposal_epoch = proposal_slot.epoch(T::EthSpec::slots_per_epoch());
|
||||||
let target_epoch = proposal_epoch.saturating_sub(ctx.spec.min_seed_lookahead);
|
let target_epoch = proposal_epoch.saturating_sub(ctx.spec.min_seed_lookahead);
|
||||||
let target_slot = target_epoch.start_slot(T::EthSpec::slots_per_epoch());
|
let target_slot = target_epoch.start_slot(T::EthSpec::slots_per_epoch());
|
||||||
|
|
||||||
if dependent_state.current_epoch() < target_epoch {
|
let (state_root, mut state) = ctx
|
||||||
partial_state_advance(
|
.store
|
||||||
&mut dependent_state,
|
.get_advanced_hot_state(dependent_root, target_slot, dependent_state_root)
|
||||||
Some(state_root),
|
.map_err(crate::BeaconChainError::DBError)?
|
||||||
target_slot,
|
.ok_or(ProposerPreferencesError::DependentRootUnknown { dependent_root })?;
|
||||||
ctx.spec,
|
|
||||||
)
|
if state.current_epoch() < target_epoch {
|
||||||
|
partial_state_advance(&mut state, Some(state_root), target_slot, ctx.spec)
|
||||||
.map_err(crate::BeaconChainError::StateAdvanceError)?;
|
.map_err(crate::BeaconChainError::StateAdvanceError)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !dependent_state.is_valid_proposal_slot(&signed_preferences.message, ctx.spec)? {
|
if !state.is_valid_proposal_slot(&signed_preferences.message, ctx.spec)? {
|
||||||
return Err(ProposerPreferencesError::InvalidProposalSlot {
|
return Err(ProposerPreferencesError::InvalidProposalSlot {
|
||||||
validator_index,
|
validator_index,
|
||||||
proposal_slot,
|
proposal_slot,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify signature using the dependent state (which has the validator pubkeys)
|
// Verify signature
|
||||||
proposer_preferences_signature_set(
|
proposer_preferences_signature_set(
|
||||||
&dependent_state,
|
&state,
|
||||||
|i| get_pubkey_from_state(&dependent_state, i),
|
|i| get_pubkey_from_state(&state, i),
|
||||||
&signed_preferences,
|
&signed_preferences,
|
||||||
ctx.spec,
|
ctx.spec,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use fork_choice::ForkChoice;
|
|||||||
use genesis::{generate_deterministic_keypairs, interop_genesis_state};
|
use genesis::{generate_deterministic_keypairs, interop_genesis_state};
|
||||||
use proto_array::PayloadStatus;
|
use proto_array::PayloadStatus;
|
||||||
use slot_clock::{SlotClock, TestingSlotClock};
|
use slot_clock::{SlotClock, TestingSlotClock};
|
||||||
use store::{HotColdDB, StoreConfig};
|
use store::{HotColdDB, MemoryStore, StoreConfig};
|
||||||
use types::{
|
use types::{
|
||||||
Address, BeaconBlock, ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, MinimalEthSpec,
|
Address, BeaconBlock, ChainSpec, Checkpoint, Epoch, EthSpec, Hash256, MinimalEthSpec,
|
||||||
ProposerPreferences, SignedBeaconBlock, SignedProposerPreferences, Slot,
|
ProposerPreferences, SignedBeaconBlock, SignedProposerPreferences, Slot,
|
||||||
@@ -36,6 +36,7 @@ struct TestContext {
|
|||||||
preferences_cache: GossipVerifiedProposerPreferenceCache,
|
preferences_cache: GossipVerifiedProposerPreferenceCache,
|
||||||
slot_clock: TestingSlotClock,
|
slot_clock: TestingSlotClock,
|
||||||
spec: ChainSpec,
|
spec: ChainSpec,
|
||||||
|
store: Arc<HotColdDB<E, MemoryStore, MemoryStore>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestContext {
|
impl TestContext {
|
||||||
@@ -91,6 +92,7 @@ impl TestContext {
|
|||||||
preferences_cache: GossipVerifiedProposerPreferenceCache::default(),
|
preferences_cache: GossipVerifiedProposerPreferenceCache::default(),
|
||||||
slot_clock,
|
slot_clock,
|
||||||
spec,
|
spec,
|
||||||
|
store,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +102,7 @@ impl TestContext {
|
|||||||
gossip_verified_proposer_preferences_cache: &self.preferences_cache,
|
gossip_verified_proposer_preferences_cache: &self.preferences_cache,
|
||||||
slot_clock: &self.slot_clock,
|
slot_clock: &self.slot_clock,
|
||||||
spec: &self.spec,
|
spec: &self.spec,
|
||||||
|
store: &self.store,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4113,7 +4113,9 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
| ProposerPreferencesError::ProposalSlotAlreadyPassed { .. }
|
| ProposerPreferencesError::ProposalSlotAlreadyPassed { .. }
|
||||||
| ProposerPreferencesError::BeaconChainError(_)
|
| ProposerPreferencesError::BeaconChainError(_)
|
||||||
| ProposerPreferencesError::BeaconStateError(_)
|
| ProposerPreferencesError::BeaconStateError(_)
|
||||||
| ProposerPreferencesError::UnableToReadSlot,
|
| ProposerPreferencesError::UnableToReadSlot
|
||||||
|
| ProposerPreferencesError::DependentRootUnknown { .. }
|
||||||
|
| ProposerPreferencesError::DependentRootNotCanonical { .. },
|
||||||
) => {
|
) => {
|
||||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user