mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
update config
This commit is contained in:
@@ -874,46 +874,40 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
return Err(Error::SlotOutOfBounds);
|
||||
}
|
||||
|
||||
let seed = self.get_inclusion_list_seed(slot, spec)?;
|
||||
let indices = self.get_active_validator_indices(epoch, spec)?;
|
||||
let seed = self.get_seed(epoch, Domain::InclusionListCommittee, spec)?;
|
||||
let active_validator_indices = self.get_active_validator_indices(epoch, spec)?;
|
||||
let active_validator_count = active_validator_indices.len();
|
||||
|
||||
let start = (slot.safe_rem(E::slots_per_epoch())?)
|
||||
.as_usize()
|
||||
.safe_mul(E::InclusionListCommitteeSize::to_usize())?;
|
||||
let end = start.safe_add(E::InclusionListCommitteeSize::to_usize())?;
|
||||
|
||||
println!("start {:?}", start);
|
||||
println!("end {:?}", end);
|
||||
println!("slot {:?}", slot);
|
||||
|
||||
let mut i = start;
|
||||
let mut il_committee_indices =
|
||||
Vec::with_capacity(E::InclusionListCommitteeSize::to_usize());
|
||||
while i < end {
|
||||
let shuffled_index = compute_shuffled_index(
|
||||
i.safe_rem(indices.len())?,
|
||||
indices.len(),
|
||||
&seed,
|
||||
i.safe_rem(active_validator_count)?,
|
||||
active_validator_count,
|
||||
seed.as_slice(),
|
||||
spec.shuffle_round_count,
|
||||
)
|
||||
.ok_or(Error::UnableToShuffle)?;
|
||||
il_committee_indices.push(shuffled_index as u64);
|
||||
let validator_index = *active_validator_indices
|
||||
.get(shuffled_index)
|
||||
.ok_or(Error::ShuffleIndexOutOfBounds(shuffled_index))?;
|
||||
il_committee_indices.push(validator_index as u64);
|
||||
i.safe_add_assign(1)?;
|
||||
}
|
||||
|
||||
Ok(InclusionListCommittee::<E>::from(il_committee_indices))
|
||||
}
|
||||
|
||||
/// Compute the seed to use for the beacon inclusion list committee selection at the given
|
||||
/// `slot`.
|
||||
///
|
||||
/// Spec v0.12.1
|
||||
pub fn get_inclusion_list_seed(&self, slot: Slot, spec: &ChainSpec) -> Result<Vec<u8>, Error> {
|
||||
let epoch = slot.epoch(E::slots_per_epoch());
|
||||
let mut preimage = self
|
||||
.get_seed(epoch, Domain::InclusionListCommittee, spec)?
|
||||
.as_slice()
|
||||
.to_vec();
|
||||
preimage.append(&mut int_to_bytes8(slot.as_u64()));
|
||||
Ok(hash(&preimage))
|
||||
}
|
||||
|
||||
/// Returns the block root which decided the proposer shuffling for the epoch passed in parameter. This root
|
||||
/// can be used to key this proposer shuffling.
|
||||
///
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::Transactions;
|
||||
|
||||
use super::{EthSpec, SignedInclusionList, Slot, Transaction};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tracing::debug;
|
||||
use tracing::info;
|
||||
|
||||
/// Map from slot to inclusion lists
|
||||
#[derive(Debug, Default, Clone, PartialEq)]
|
||||
@@ -25,6 +25,17 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
self.inner_map.remove(&slot);
|
||||
}
|
||||
|
||||
pub fn inclusion_list_seen(&self, inclusion_list: &SignedInclusionList<E>) -> bool {
|
||||
let slot = inclusion_list.message.slot;
|
||||
let Some(inner) = self.inner_map.get(&slot) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
inner
|
||||
.inclusion_lists_seen
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
}
|
||||
|
||||
pub fn on_inclusion_list(&mut self, inclusion_list: SignedInclusionList<E>) {
|
||||
let slot = inclusion_list.message.slot;
|
||||
let inner = self.inner_map.entry(slot).or_default();
|
||||
@@ -33,7 +44,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.inclusion_list_equivocators
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
{
|
||||
debug!(
|
||||
info!(
|
||||
?slot,
|
||||
inclusion_list.message.validator_index,
|
||||
"This validator was flagged for an equivocating inclusion list",
|
||||
@@ -47,7 +58,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
&& inner.inclusion_lists.contains(&inclusion_list)
|
||||
{
|
||||
debug!("Already seen identical inclusion list from this validator");
|
||||
info!("Already seen identical inclusion list from this validator");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +67,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
&& !inner.inclusion_lists.contains(&inclusion_list)
|
||||
{
|
||||
debug!(
|
||||
info!(
|
||||
?slot,
|
||||
inclusion_list.message.validator_index, "Equivocating inclusion list",
|
||||
);
|
||||
@@ -76,7 +87,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.insert(inclusion_list.message.validator_index);
|
||||
inner.inclusion_lists.insert(inclusion_list);
|
||||
|
||||
debug!(
|
||||
info!(
|
||||
?slot,
|
||||
tx_count = inner.inclusion_list_transactions.len(),
|
||||
"Successfully added inclusion list transactions to the cache",
|
||||
|
||||
@@ -975,7 +975,7 @@ impl ChainSpec {
|
||||
/*
|
||||
* FOCIL params
|
||||
*/
|
||||
domain_inclusion_list_committee: 13,
|
||||
domain_inclusion_list_committee: 12,
|
||||
inclusion_list_committee_size: 16,
|
||||
eip7805_fork_epoch: None,
|
||||
eip7805_fork_version: [0x06, 0x00, 0x00, 0x00],
|
||||
@@ -1320,7 +1320,7 @@ impl ChainSpec {
|
||||
/*
|
||||
* FOCIL params
|
||||
*/
|
||||
domain_inclusion_list_committee: 13,
|
||||
domain_inclusion_list_committee: 12,
|
||||
inclusion_list_committee_size: 16,
|
||||
eip7805_fork_epoch: None,
|
||||
eip7805_fork_version: [0x06, 0x00, 0x00, 0x00],
|
||||
|
||||
Reference in New Issue
Block a user