mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
Fork choice changes
This commit is contained in:
@@ -470,6 +470,8 @@ pub struct BeaconChain<T: BeaconChainTypes> {
|
||||
pub(crate) attester_cache: Arc<AttesterCache>,
|
||||
/// A cache used when producing attestations whilst the head block is still being imported.
|
||||
pub early_attester_cache: EarlyAttesterCache<T::EthSpec>,
|
||||
/// A cache used to store verified/equivocating inclusion lists.
|
||||
pub inclusion_list_cache: InclusionListCache<T::EthSpec>,
|
||||
/// Cache gossip verified blocks to serve over ReqResp before they are imported
|
||||
pub reqresp_pre_import_cache: Arc<RwLock<ReqRespPreImportCache<T::EthSpec>>>,
|
||||
/// A cache used to keep track of various block timings.
|
||||
|
||||
@@ -10,7 +10,7 @@ use fork_choice::ForkChoiceStore;
|
||||
use proto_array::JustifiedBalances;
|
||||
use safe_arith::ArithError;
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use store::{Error as StoreError, HotColdDB, ItemStore};
|
||||
@@ -140,6 +140,7 @@ pub struct BeaconForkChoiceStore<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<
|
||||
unrealized_finalized_checkpoint: Checkpoint,
|
||||
proposer_boost_root: Hash256,
|
||||
equivocating_indices: BTreeSet<u64>,
|
||||
inclusion_list_equivocators: HashMap<(Slot, Hash256), BTreeSet<u64>>,
|
||||
_phantom: PhantomData<E>,
|
||||
}
|
||||
|
||||
@@ -189,6 +190,7 @@ where
|
||||
unrealized_finalized_checkpoint: finalized_checkpoint,
|
||||
proposer_boost_root: Hash256::zero(),
|
||||
equivocating_indices: BTreeSet::new(),
|
||||
inclusion_list_equivocators: HashMap::new(),
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
@@ -227,6 +229,7 @@ where
|
||||
unrealized_finalized_checkpoint: persisted.unrealized_finalized_checkpoint,
|
||||
proposer_boost_root: persisted.proposer_boost_root,
|
||||
equivocating_indices: persisted.equivocating_indices,
|
||||
inclusion_list_equivocators: HashMap::new(),
|
||||
_phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -965,6 +965,7 @@ where
|
||||
validator_pubkey_cache: RwLock::new(validator_pubkey_cache),
|
||||
attester_cache: <_>::default(),
|
||||
early_attester_cache: <_>::default(),
|
||||
inclusion_list_cache: <_>::default(),
|
||||
reqresp_pre_import_cache: <_>::default(),
|
||||
light_client_server_cache: LightClientServerCache::new(),
|
||||
light_client_server_tx: self.light_client_server_tx,
|
||||
|
||||
@@ -52,6 +52,7 @@ pub enum NotifyExecutionLayer {
|
||||
pub struct PayloadNotifier<T: BeaconChainTypes> {
|
||||
pub chain: Arc<BeaconChain<T>>,
|
||||
pub block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
pub inclusion_list_transactions: InclusionListTransactions<T::EthSpec>,
|
||||
payload_verification_status: Option<PayloadVerificationStatus>,
|
||||
}
|
||||
|
||||
@@ -102,10 +103,16 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
Some(PayloadVerificationStatus::Irrelevant)
|
||||
};
|
||||
|
||||
let inclusion_list_transactions = chain
|
||||
.inclusion_list_cache
|
||||
.get_inclusion_list_transactions(block.slot())
|
||||
.unwrap_or(vec![].into());
|
||||
|
||||
Ok(Self {
|
||||
chain,
|
||||
block,
|
||||
payload_verification_status,
|
||||
inclusion_list_transactions,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,7 +120,12 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
if let Some(precomputed_status) = self.payload_verification_status {
|
||||
Ok(precomputed_status)
|
||||
} else {
|
||||
notify_new_payload(&self.chain, self.block.message()).await
|
||||
notify_new_payload(
|
||||
&self.chain,
|
||||
self.block.message(),
|
||||
self.inclusion_list_transactions,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +142,7 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
async fn notify_new_payload<'a, T: BeaconChainTypes>(
|
||||
chain: &Arc<BeaconChain<T>>,
|
||||
block: BeaconBlockRef<'a, T::EthSpec>,
|
||||
il_transactions: InclusionListTransactions<T::EthSpec>,
|
||||
) -> Result<PayloadVerificationStatus, BlockError> {
|
||||
let execution_layer = chain
|
||||
.execution_layer
|
||||
@@ -137,7 +150,12 @@ async fn notify_new_payload<'a, T: BeaconChainTypes>(
|
||||
.ok_or(ExecutionPayloadError::NoExecutionConnection)?;
|
||||
|
||||
let execution_block_hash = block.execution_payload()?.block_hash();
|
||||
let new_payload_response = execution_layer.notify_new_payload(block.try_into()?).await;
|
||||
let new_payload_response = execution_layer
|
||||
.notify_new_payload(NewPayloadRequest::try_from_block_and_il_transactions(
|
||||
block,
|
||||
il_transactions,
|
||||
)?)
|
||||
.await;
|
||||
|
||||
match new_payload_response {
|
||||
Ok(status) => match status {
|
||||
|
||||
Reference in New Issue
Block a user