mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-02 12:13:46 +00:00
Merge branch 'unstable' into into-anchor
This commit is contained in:
@@ -1256,6 +1256,11 @@ where
|
||||
.is_finalized_checkpoint_or_descendant::<E>(block_root)
|
||||
}
|
||||
|
||||
pub fn is_descendant(&self, ancestor_root: Hash256, descendant_root: Hash256) -> bool {
|
||||
self.proto_array
|
||||
.is_descendant(ancestor_root, descendant_root)
|
||||
}
|
||||
|
||||
/// Returns `Ok(true)` if `block_root` has been imported optimistically or deemed invalid.
|
||||
///
|
||||
/// Returns `Ok(false)` if `block_root`'s execution payload has been elected as fully VALID, if
|
||||
|
||||
@@ -25,6 +25,9 @@ pub type E = MainnetEthSpec;
|
||||
|
||||
pub const VALIDATOR_COUNT: usize = 64;
|
||||
|
||||
// When set to true, cache any states fetched from the db.
|
||||
pub const CACHE_STATE_IN_TESTS: bool = true;
|
||||
|
||||
/// Defines some delay between when an attestation is created and when it is mutated.
|
||||
pub enum MutationDelay {
|
||||
/// No delay between creation and mutation.
|
||||
@@ -373,7 +376,7 @@ impl ForkChoiceTest {
|
||||
let state = harness
|
||||
.chain
|
||||
.store
|
||||
.get_state(&state_root, None)
|
||||
.get_state(&state_root, None, CACHE_STATE_IN_TESTS)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let balances = state
|
||||
|
||||
@@ -22,6 +22,9 @@ pub const VALIDATOR_COUNT: usize = 64;
|
||||
pub const EPOCH_OFFSET: u64 = 4;
|
||||
pub const NUM_ATTESTATIONS: u64 = 1;
|
||||
|
||||
// When set to true, cache any states fetched from the db.
|
||||
pub const CACHE_STATE_IN_TESTS: bool = true;
|
||||
|
||||
/// A cached set of keys.
|
||||
static KEYPAIRS: LazyLock<Vec<Keypair>> =
|
||||
LazyLock::new(|| generate_deterministic_keypairs(MAX_VALIDATOR_COUNT));
|
||||
@@ -1114,9 +1117,10 @@ async fn block_replayer_peeking_state_roots() {
|
||||
.get_blinded_block(&parent_block_root)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
// Cache the state to make CI go brr.
|
||||
let parent_state = harness
|
||||
.chain
|
||||
.get_state(&parent_block.state_root(), Some(parent_block.slot()))
|
||||
.get_state(&parent_block.state_root(), Some(parent_block.slot()), true)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -213,12 +213,16 @@ impl<E: EthSpec> LightClientUpdate<E> {
|
||||
.map_err(|_| Error::InconsistentFork)?
|
||||
{
|
||||
ForkName::Base => return Err(Error::AltairForkNotActive),
|
||||
ForkName::Altair | ForkName::Bellatrix => {
|
||||
fork_name @ ForkName::Altair | fork_name @ ForkName::Bellatrix => {
|
||||
let attested_header =
|
||||
LightClientHeaderAltair::block_to_light_client_header(attested_block)?;
|
||||
|
||||
let finalized_header = if let Some(finalized_block) = finalized_block {
|
||||
LightClientHeaderAltair::block_to_light_client_header(finalized_block)?
|
||||
if finalized_block.fork_name_unchecked() == fork_name {
|
||||
LightClientHeaderAltair::block_to_light_client_header(finalized_block)?
|
||||
} else {
|
||||
LightClientHeaderAltair::default()
|
||||
}
|
||||
} else {
|
||||
LightClientHeaderAltair::default()
|
||||
};
|
||||
@@ -233,12 +237,16 @@ impl<E: EthSpec> LightClientUpdate<E> {
|
||||
signature_slot: block_slot,
|
||||
})
|
||||
}
|
||||
ForkName::Capella => {
|
||||
fork_name @ ForkName::Capella => {
|
||||
let attested_header =
|
||||
LightClientHeaderCapella::block_to_light_client_header(attested_block)?;
|
||||
|
||||
let finalized_header = if let Some(finalized_block) = finalized_block {
|
||||
LightClientHeaderCapella::block_to_light_client_header(finalized_block)?
|
||||
if finalized_block.fork_name_unchecked() == fork_name {
|
||||
LightClientHeaderCapella::block_to_light_client_header(finalized_block)?
|
||||
} else {
|
||||
LightClientHeaderCapella::default()
|
||||
}
|
||||
} else {
|
||||
LightClientHeaderCapella::default()
|
||||
};
|
||||
@@ -253,12 +261,16 @@ impl<E: EthSpec> LightClientUpdate<E> {
|
||||
signature_slot: block_slot,
|
||||
})
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
fork_name @ ForkName::Deneb => {
|
||||
let attested_header =
|
||||
LightClientHeaderDeneb::block_to_light_client_header(attested_block)?;
|
||||
|
||||
let finalized_header = if let Some(finalized_block) = finalized_block {
|
||||
LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?
|
||||
if finalized_block.fork_name_unchecked() == fork_name {
|
||||
LightClientHeaderDeneb::block_to_light_client_header(finalized_block)?
|
||||
} else {
|
||||
LightClientHeaderDeneb::default()
|
||||
}
|
||||
} else {
|
||||
LightClientHeaderDeneb::default()
|
||||
};
|
||||
@@ -273,12 +285,16 @@ impl<E: EthSpec> LightClientUpdate<E> {
|
||||
signature_slot: block_slot,
|
||||
})
|
||||
}
|
||||
ForkName::Electra => {
|
||||
fork_name @ ForkName::Electra => {
|
||||
let attested_header =
|
||||
LightClientHeaderElectra::block_to_light_client_header(attested_block)?;
|
||||
|
||||
let finalized_header = if let Some(finalized_block) = finalized_block {
|
||||
LightClientHeaderElectra::block_to_light_client_header(finalized_block)?
|
||||
if finalized_block.fork_name_unchecked() == fork_name {
|
||||
LightClientHeaderElectra::block_to_light_client_header(finalized_block)?
|
||||
} else {
|
||||
LightClientHeaderElectra::default()
|
||||
}
|
||||
} else {
|
||||
LightClientHeaderElectra::default()
|
||||
};
|
||||
@@ -293,12 +309,16 @@ impl<E: EthSpec> LightClientUpdate<E> {
|
||||
signature_slot: block_slot,
|
||||
})
|
||||
}
|
||||
ForkName::Fulu => {
|
||||
fork_name @ ForkName::Fulu => {
|
||||
let attested_header =
|
||||
LightClientHeaderFulu::block_to_light_client_header(attested_block)?;
|
||||
|
||||
let finalized_header = if let Some(finalized_block) = finalized_block {
|
||||
LightClientHeaderFulu::block_to_light_client_header(finalized_block)?
|
||||
if finalized_block.fork_name_unchecked() == fork_name {
|
||||
LightClientHeaderFulu::block_to_light_client_header(finalized_block)?
|
||||
} else {
|
||||
LightClientHeaderFulu::default()
|
||||
}
|
||||
} else {
|
||||
LightClientHeaderFulu::default()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user