mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
update il cache with is timely
This commit is contained in:
@@ -6532,7 +6532,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
let il_txs = self
|
||||
.inclusion_list_cache
|
||||
.read()
|
||||
.get_inclusion_list_transactions(il_slot)
|
||||
.get_inclusion_list_transactions(il_slot, false)
|
||||
.unwrap_or_default();
|
||||
Some(
|
||||
il_txs
|
||||
@@ -7794,11 +7794,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn on_verified_inclusion_list(&self, signed_il: SignedInclusionList<T::EthSpec>) {
|
||||
info!("Adding verified inclusion list to the cache");
|
||||
pub fn on_verified_inclusion_list(
|
||||
&self,
|
||||
signed_il: SignedInclusionList<T::EthSpec>,
|
||||
is_timely: bool,
|
||||
) {
|
||||
info!(is_timely, "Adding verified inclusion list to the cache");
|
||||
self.inclusion_list_cache
|
||||
.write()
|
||||
.on_inclusion_list(signed_il);
|
||||
.on_inclusion_list(signed_il, is_timely);
|
||||
}
|
||||
|
||||
pub fn inclusion_list_seen(&self, signed_il: &SignedInclusionList<T::EthSpec>) -> bool {
|
||||
|
||||
@@ -1126,7 +1126,7 @@ where
|
||||
let il_txs = chain
|
||||
.inclusion_list_cache
|
||||
.read()
|
||||
.get_inclusion_list_transactions(il_slot)
|
||||
.get_inclusion_list_transactions(il_slot, false)
|
||||
.unwrap_or_default();
|
||||
Some(
|
||||
il_txs
|
||||
|
||||
@@ -110,7 +110,7 @@ impl<T: BeaconChainTypes> PayloadNotifier<T> {
|
||||
chain
|
||||
.inclusion_list_cache
|
||||
.read()
|
||||
.get_inclusion_list_transactions(il_slot)
|
||||
.get_inclusion_list_transactions(il_slot, true)
|
||||
.unwrap_or(VariableList::new(vec![]).map_err(|_| {
|
||||
BlockError::InternalError("Cant create empty IL".to_string())
|
||||
})?);
|
||||
|
||||
@@ -33,6 +33,7 @@ impl From<BeaconChainError> for GossipInclusionListError {
|
||||
|
||||
pub struct GossipVerifiedInclusionList<T: BeaconChainTypes> {
|
||||
pub signed_il: SignedInclusionList<T::EthSpec>,
|
||||
pub is_timely: bool,
|
||||
}
|
||||
|
||||
impl<T: BeaconChainTypes> GossipVerifiedInclusionList<T> {
|
||||
@@ -123,8 +124,17 @@ impl<T: BeaconChainTypes> GossipVerifiedInclusionList<T> {
|
||||
return Err(GossipInclusionListError::PriorInclusionListKnown);
|
||||
}
|
||||
|
||||
// Compute timeliness: timely if received before INCLUSION_LIST_DUE_BPS into the slot
|
||||
// INCLUSION_LIST_DUE_BPS = 6667 basis points = 66.67% of slot duration
|
||||
let slot_duration_ms = chain.spec.get_slot_duration().as_millis() as u64;
|
||||
let inclusion_list_due_ms = slot_duration_ms * 6667 / 10000;
|
||||
let il_delay_ms =
|
||||
get_slot_delay_ms(timestamp_now(), message_slot, &chain.slot_clock).as_millis() as u64;
|
||||
let is_timely = il_delay_ms <= inclusion_list_due_ms;
|
||||
|
||||
Ok(Self {
|
||||
signed_il: signed_il.clone(),
|
||||
is_timely,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ impl InclusionListGossipTester {
|
||||
|
||||
self.harness
|
||||
.chain
|
||||
.on_verified_inclusion_list(self.inclusion_list.clone());
|
||||
.on_verified_inclusion_list(self.inclusion_list.clone(), true);
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user