mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 05:07:12 +00:00
merge unstable
This commit is contained in:
@@ -18,6 +18,7 @@ use super::{
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
AlreadySigned(usize),
|
||||
IncorrectStateVariant,
|
||||
InvalidCommitteeLength,
|
||||
@@ -223,7 +224,7 @@ impl<E: EthSpec> Attestation<E> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_aggregation_bit(&self, index: usize) -> Result<bool, ssz_types::Error> {
|
||||
pub fn get_aggregation_bit(&self, index: usize) -> Result<bool, ssz::BitfieldError> {
|
||||
match self {
|
||||
Attestation::Base(att) => att.aggregation_bits.get(index),
|
||||
Attestation::Electra(att) => att.aggregation_bits.get(index),
|
||||
@@ -353,13 +354,13 @@ impl<E: EthSpec> AttestationElectra<E> {
|
||||
if self
|
||||
.aggregation_bits
|
||||
.get(committee_position)
|
||||
.map_err(Error::SszTypesError)?
|
||||
.map_err(Error::BitfieldError)?
|
||||
{
|
||||
Err(Error::AlreadySigned(committee_position))
|
||||
} else {
|
||||
self.aggregation_bits
|
||||
.set(committee_position, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
|
||||
self.signature.add_assign(signature);
|
||||
|
||||
@@ -427,13 +428,13 @@ impl<E: EthSpec> AttestationBase<E> {
|
||||
if self
|
||||
.aggregation_bits
|
||||
.get(committee_position)
|
||||
.map_err(Error::SszTypesError)?
|
||||
.map_err(Error::BitfieldError)?
|
||||
{
|
||||
Err(Error::AlreadySigned(committee_position))
|
||||
} else {
|
||||
self.aggregation_bits
|
||||
.set(committee_position, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
|
||||
self.signature.add_assign(signature);
|
||||
|
||||
@@ -443,7 +444,7 @@ impl<E: EthSpec> AttestationBase<E> {
|
||||
|
||||
pub fn extend_aggregation_bits(
|
||||
&self,
|
||||
) -> Result<BitList<E::MaxValidatorsPerSlot>, ssz_types::Error> {
|
||||
) -> Result<BitList<E::MaxValidatorsPerSlot>, ssz::BitfieldError> {
|
||||
self.aggregation_bits.resize::<E::MaxValidatorsPerSlot>()
|
||||
}
|
||||
}
|
||||
@@ -600,12 +601,12 @@ mod tests {
|
||||
let attestation_data = size_of::<AttestationData>();
|
||||
let signature = size_of::<AggregateSignature>();
|
||||
|
||||
assert_eq!(aggregation_bits, 56);
|
||||
assert_eq!(aggregation_bits, 152);
|
||||
assert_eq!(attestation_data, 128);
|
||||
assert_eq!(signature, 288 + 16);
|
||||
|
||||
let attestation_expected = aggregation_bits + attestation_data + signature;
|
||||
assert_eq!(attestation_expected, 488);
|
||||
assert_eq!(attestation_expected, 584);
|
||||
assert_eq!(
|
||||
size_of::<AttestationBase<MainnetEthSpec>>(),
|
||||
attestation_expected
|
||||
@@ -623,13 +624,13 @@ mod tests {
|
||||
size_of::<BitList<<MainnetEthSpec as EthSpec>::MaxCommitteesPerSlot>>();
|
||||
let signature = size_of::<AggregateSignature>();
|
||||
|
||||
assert_eq!(aggregation_bits, 56);
|
||||
assert_eq!(committee_bits, 56);
|
||||
assert_eq!(aggregation_bits, 152);
|
||||
assert_eq!(committee_bits, 152);
|
||||
assert_eq!(attestation_data, 128);
|
||||
assert_eq!(signature, 288 + 16);
|
||||
|
||||
let attestation_expected = aggregation_bits + committee_bits + attestation_data + signature;
|
||||
assert_eq!(attestation_expected, 544);
|
||||
assert_eq!(attestation_expected, 736);
|
||||
assert_eq!(
|
||||
size_of::<AttestationElectra<MainnetEthSpec>>(),
|
||||
attestation_expected
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::{EthSpec, InclusionListTransactions, SignedInclusionList, Slot, Transaction};
|
||||
use slog::{debug, Logger};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tracing::debug;
|
||||
|
||||
/// Map from slot to inclusion lists
|
||||
#[derive(Debug, Default, Clone, PartialEq)]
|
||||
@@ -23,7 +23,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
self.inner_map.remove(&slot);
|
||||
}
|
||||
|
||||
pub fn on_inclusion_list(&mut self, inclusion_list: SignedInclusionList<E>, log: &Logger) {
|
||||
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();
|
||||
|
||||
@@ -32,10 +32,9 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
{
|
||||
debug!(
|
||||
log,
|
||||
"This validator was flagged for an equivocating inclusion list";
|
||||
"slot" => slot,
|
||||
"validator_index" => inclusion_list.message.validator_index
|
||||
?slot,
|
||||
inclusion_list.message.validator_index,
|
||||
"This validator was flagged for an equivocating inclusion list",
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -46,10 +45,7 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
.contains(&inclusion_list.message.validator_index)
|
||||
&& inner.inclusion_lists.contains(&inclusion_list)
|
||||
{
|
||||
debug!(
|
||||
log,
|
||||
"Already seen identical inclusion list from this validator";
|
||||
);
|
||||
debug!("Already seen identical inclusion list from this validator");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,10 +55,8 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
&& !inner.inclusion_lists.contains(&inclusion_list)
|
||||
{
|
||||
debug!(
|
||||
log,
|
||||
"Equivocating inclusion list";
|
||||
"slot" => slot,
|
||||
"validator_index" => inclusion_list.message.validator_index
|
||||
?slot,
|
||||
inclusion_list.message.validator_index, "Equivocating inclusion list",
|
||||
);
|
||||
inner
|
||||
.inclusion_list_equivocators
|
||||
@@ -81,10 +75,9 @@ impl<E: EthSpec> InclusionListCache<E> {
|
||||
inner.inclusion_lists.insert(inclusion_list);
|
||||
|
||||
debug!(
|
||||
log,
|
||||
"Successfully added inclusion list transactions to the cache";
|
||||
"slot" => slot,
|
||||
"total_count" => inner.inclusion_list_transactions.len()
|
||||
?slot,
|
||||
tx_count = inner.inclusion_list_transactions.len(),
|
||||
"Successfully added inclusion list transactions to the cache",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
@@ -227,17 +227,6 @@ macro_rules! impl_display {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl slog::Value for $type {
|
||||
fn serialize(
|
||||
&self,
|
||||
record: &slog::Record,
|
||||
key: slog::Key,
|
||||
serializer: &mut dyn slog::Serializer,
|
||||
) -> slog::Result {
|
||||
slog::Value::serialize(&self.0, record, key, serializer)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use tree_hash_derive::TreeHash;
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
ArithError(ArithError),
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ impl<E: EthSpec> SyncAggregate<E> {
|
||||
sync_aggregate
|
||||
.sync_committee_bits
|
||||
.set(participant_index, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
}
|
||||
}
|
||||
sync_aggregate
|
||||
|
||||
@@ -9,6 +9,7 @@ use tree_hash_derive::TreeHash;
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SszTypesError(ssz_types::Error),
|
||||
BitfieldError(ssz::BitfieldError),
|
||||
AlreadySigned(usize),
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ impl<E: EthSpec> SyncCommitteeContribution<E> {
|
||||
) -> Result<Self, Error> {
|
||||
let mut bits = BitVector::new();
|
||||
bits.set(validator_sync_committee_index, true)
|
||||
.map_err(Error::SszTypesError)?;
|
||||
.map_err(Error::BitfieldError)?;
|
||||
Ok(Self {
|
||||
slot: message.slot,
|
||||
beacon_block_root: message.beacon_block_root,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::*;
|
||||
use eth2_interop_keypairs::{keypair, keypairs_from_yaml_file};
|
||||
use log::debug;
|
||||
use rayon::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
use tracing::debug;
|
||||
|
||||
/// Generates `validator_count` keypairs where the secret key is derived solely from the index of
|
||||
/// the validator.
|
||||
|
||||
Reference in New Issue
Block a user