From fcf1e3f24f78b34b77692e9810849cbd401ecc7f Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 4 Mar 2025 09:17:32 +1100 Subject: [PATCH] Revert "Reuse milhouse subtrees to shrink inactivity_scores in memory (#7062)" This reverts commit 6399ad482ba500c18d81ea5d0bf11cc87419718c. --- Cargo.lock | 67 ++++------------- Cargo.toml | 12 ++-- beacon_node/beacon_chain/src/test_utils.rs | 20 +++--- beacon_node/beacon_chain/tests/rewards.rs | 6 +- .../lighthouse_network/src/rpc/codec.rs | 23 +++--- .../lighthouse_network/src/rpc/methods.rs | 2 +- .../lighthouse_network/src/service/mod.rs | 4 +- common/malloc_utils/src/jemalloc.rs | 72 +------------------ .../src/per_block_processing/errors.rs | 11 --- .../src/per_epoch_processing/errors.rs | 9 +-- .../src/per_epoch_processing/single_pass.rs | 5 -- consensus/types/src/attestation.rs | 23 +++--- consensus/types/src/beacon_state.rs | 5 -- consensus/types/src/sync_aggregate.rs | 3 +- .../types/src/sync_committee_contribution.rs | 3 +- 15 files changed, 63 insertions(+), 202 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4899a72338..760feb588c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2370,18 +2370,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "educe" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" -dependencies = [ - "enum-ordinalize", - "proc-macro2", - "quote", - "syn 2.0.98", -] - [[package]] name = "ef_tests" version = "0.2.0" @@ -2499,26 +2487,6 @@ dependencies = [ "syn 2.0.98", ] -[[package]] -name = "enum-ordinalize" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" -dependencies = [ - "enum-ordinalize-derive", -] - -[[package]] -name = "enum-ordinalize-derive" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.98", -] - [[package]] name = "env_logger" version = "0.8.4" @@ -2879,25 +2847,20 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.8.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86da3096d1304f5f28476ce383005385459afeaf0eea08592b65ddbc9b258d16" +checksum = "1e999563461faea0ab9bc0024e5e66adcee35881f3d5062f52f31a4070fe1522" dependencies = [ "alloy-primitives", - "arbitrary", - "ethereum_serde_utils", "itertools 0.13.0", - "serde", - "serde_derive", "smallvec", - "typenum", ] [[package]] name = "ethereum_ssz_derive" -version = "0.8.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d832a5c38eba0e7ad92592f7a22d693954637fbb332b4f669590d66a5c3183e5" +checksum = "f3deae99c8e74829a00ba7a92d49055732b3c1f093f2ccfa3cbc621679b6fa91" dependencies = [ "darling 0.20.10", "proc-macro2", @@ -5797,12 +5760,13 @@ dependencies = [ [[package]] name = "milhouse" -version = "0.5.0" -source = "git+https://github.com/sigp/milhouse?branch=main#e0389cbb8dce78d872ef2ad525e6702e37da6d71" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f68e33f98199224d1073f7c1468ea6abfea30736306fb79c7181a881e97ea32f" dependencies = [ "alloy-primitives", "arbitrary", - "educe", + "derivative", "ethereum_hashing", "ethereum_ssz", "ethereum_ssz_derive", @@ -8601,11 +8565,12 @@ dependencies = [ [[package]] name = "ssz_types" -version = "0.10.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22bc24c8a61256950632fb6b68ea09f6b5c988070924c6292eb5933635202e00" +checksum = "35e0719d2b86ac738a55ae71a8429f52aa2741da988f1fd0975b4cc610fd1e08" dependencies = [ "arbitrary", + "derivative", "ethereum_serde_utils", "ethereum_ssz", "itertools 0.13.0", @@ -9515,22 +9480,20 @@ dependencies = [ [[package]] name = "tree_hash" -version = "0.9.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58eb0f518840670270d90d97ffee702d8662d9c5494870c9e1e9e0fa00f668" +checksum = "373495c23db675a5192de8b610395e1bec324d596f9e6111192ce903dc11403a" dependencies = [ "alloy-primitives", "ethereum_hashing", - "ethereum_ssz", "smallvec", - "typenum", ] [[package]] name = "tree_hash_derive" -version = "0.9.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "699e7fb6b3fdfe0c809916f251cf5132d64966858601695c3736630a87e7166a" +checksum = "b0857056ca4eb5de8c417309be42bcff6017b47e86fbaddde609b4633f66061e" dependencies = [ "darling 0.20.10", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 5e811cd2e1..73912f6082 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -139,8 +139,8 @@ discv5 = { version = "0.9", features = ["libp2p"] } env_logger = "0.9" ethereum_hashing = "0.7.0" ethereum_serde_utils = "0.7" -ethereum_ssz = "0.8.2" -ethereum_ssz_derive = "0.8.2" +ethereum_ssz = "0.7" +ethereum_ssz_derive = "0.7" ethers-core = "1" ethers-providers = { version = "1", default-features = false } exit-future = "0.2" @@ -156,7 +156,7 @@ libsecp256k1 = "0.7" log = "0.4" lru = "0.12" maplit = "1" -milhouse = { git = "https://github.com/sigp/milhouse", branch = "main" } +milhouse = "0.3" mockito = "1.5.0" num_cpus = "1" parking_lot = "0.12" @@ -194,7 +194,7 @@ slog-term = "2" sloggers = { version = "2", features = ["json"] } smallvec = { version = "1.11.2", features = ["arbitrary"] } snap = "1" -ssz_types = "0.10" +ssz_types = "0.8" strum = { version = "0.24", features = ["derive"] } superstruct = "0.8" syn = "1" @@ -213,8 +213,8 @@ tracing-appender = "0.2" tracing-core = "0.1" tracing-log = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } -tree_hash = "0.9" -tree_hash_derive = "0.9" +tree_hash = "0.8" +tree_hash_derive = "0.8" url = "2" uuid = { version = "0.8", features = ["serde", "v4"] } warp = { version = "0.3.7", default-features = false, features = ["tls"] } diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index fcc9340715..24c85b3e07 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -2713,16 +2713,16 @@ where let mut block_hash_from_slot: HashMap = HashMap::new(); let mut state_hash_from_slot: HashMap = HashMap::new(); for slot in slots { - // Using a `Box::pin` to reduce the stack size. Clippy was raising a lints. - let (block_hash, new_state) = Box::pin(self.add_attested_block_at_slot_with_sync( - *slot, - state, - state_root, - validators, - sync_committee_strategy, - )) - .await - .unwrap(); + let (block_hash, new_state) = self + .add_attested_block_at_slot_with_sync( + *slot, + state, + state_root, + validators, + sync_committee_strategy, + ) + .await + .unwrap(); state = new_state; diff --git a/beacon_node/beacon_chain/tests/rewards.rs b/beacon_node/beacon_chain/tests/rewards.rs index 06e0cf890e..41e6467b0f 100644 --- a/beacon_node/beacon_chain/tests/rewards.rs +++ b/beacon_node/beacon_chain/tests/rewards.rs @@ -328,7 +328,8 @@ async fn test_rewards_base_multi_inclusion() { .extend_slots(E::slots_per_epoch() as usize * 2 - 4) .await; - check_all_base_rewards(&harness, initial_balances).await; + // pin to reduce stack size for clippy + Box::pin(check_all_base_rewards(&harness, initial_balances)).await; } #[tokio::test] @@ -691,8 +692,7 @@ async fn check_all_base_rewards( harness: &BeaconChainHarness>, balances: Vec, ) { - // The box reduces the size on the stack for a clippy lint. - Box::pin(check_all_base_rewards_for_subset(harness, balances, vec![])).await; + check_all_base_rewards_for_subset(harness, balances, vec![]).await; } async fn check_all_base_rewards_for_subset( diff --git a/beacon_node/lighthouse_network/src/rpc/codec.rs b/beacon_node/lighthouse_network/src/rpc/codec.rs index 3adc04eb6a..2bf35b0e35 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec.rs @@ -765,8 +765,8 @@ fn handle_rpc_response( SupportedProtocol::PingV1 => Ok(Some(RpcSuccessResponse::Pong(Ping { data: u64::from_ssz_bytes(decoded_buffer)?, }))), - SupportedProtocol::MetaDataV1 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new( - MetaData::V1(MetaDataV1::from_ssz_bytes(decoded_buffer)?), + SupportedProtocol::MetaDataV1 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V1( + MetaDataV1::from_ssz_bytes(decoded_buffer)?, )))), SupportedProtocol::LightClientBootstrapV1 => match fork_name { Some(fork_name) => Ok(Some(RpcSuccessResponse::LightClientBootstrap(Arc::new( @@ -826,11 +826,11 @@ fn handle_rpc_response( )), }, // MetaData V2/V3 responses have no context bytes, so behave similarly to V1 responses - SupportedProtocol::MetaDataV3 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new( - MetaData::V3(MetaDataV3::from_ssz_bytes(decoded_buffer)?), + SupportedProtocol::MetaDataV3 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V3( + MetaDataV3::from_ssz_bytes(decoded_buffer)?, )))), - SupportedProtocol::MetaDataV2 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new( - MetaData::V2(MetaDataV2::from_ssz_bytes(decoded_buffer)?), + SupportedProtocol::MetaDataV2 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V2( + MetaDataV2::from_ssz_bytes(decoded_buffer)?, )))), SupportedProtocol::BlocksByRangeV2 => match fork_name { Some(ForkName::Altair) => Ok(Some(RpcSuccessResponse::BlocksByRange(Arc::new( @@ -1008,7 +1008,6 @@ mod tests { ) -> SignedBeaconBlock { let mut block: BeaconBlockBellatrix<_, FullPayload> = BeaconBlockBellatrix::empty(&Spec::default_spec()); - let tx = VariableList::from(vec![0; 1024]); let txs = VariableList::from(std::iter::repeat(tx).take(5000).collect::>()); @@ -1028,7 +1027,6 @@ mod tests { ) -> SignedBeaconBlock { let mut block: BeaconBlockBellatrix<_, FullPayload> = BeaconBlockBellatrix::empty(&Spec::default_spec()); - let tx = VariableList::from(vec![0; 1024]); let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::>()); @@ -1107,31 +1105,28 @@ mod tests { Ping { data: 1 } } - fn metadata() -> Arc> { + fn metadata() -> MetaData { MetaData::V1(MetaDataV1 { seq_number: 1, attnets: EnrAttestationBitfield::::default(), }) - .into() } - fn metadata_v2() -> Arc> { + fn metadata_v2() -> MetaData { MetaData::V2(MetaDataV2 { seq_number: 1, attnets: EnrAttestationBitfield::::default(), syncnets: EnrSyncCommitteeBitfield::::default(), }) - .into() } - fn metadata_v3() -> Arc> { + fn metadata_v3() -> MetaData { MetaData::V3(MetaDataV3 { seq_number: 1, attnets: EnrAttestationBitfield::::default(), syncnets: EnrSyncCommitteeBitfield::::default(), custody_group_count: 1, }) - .into() } /// Encodes the given protocol response as bytes. diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index a2f866e59c..2f6200a836 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -578,7 +578,7 @@ pub enum RpcSuccessResponse { Pong(Ping), /// A response to a META_DATA request. - MetaData(Arc>), + MetaData(MetaData), } /// Indicates which response is being terminated by a stream termination response. diff --git a/beacon_node/lighthouse_network/src/service/mod.rs b/beacon_node/lighthouse_network/src/service/mod.rs index 9c3534aef9..8586fd9cd3 100644 --- a/beacon_node/lighthouse_network/src/service/mod.rs +++ b/beacon_node/lighthouse_network/src/service/mod.rs @@ -1186,7 +1186,7 @@ impl Network { ) { let metadata = self.network_globals.local_metadata.read().clone(); // The encoder is responsible for sending the negotiated version of the metadata - let event = RpcResponse::Success(RpcSuccessResponse::MetaData(Arc::new(metadata))); + let event = RpcResponse::Success(RpcSuccessResponse::MetaData(metadata)); self.eth2_rpc_mut() .send_response(peer_id, id, request_id, event); } @@ -1601,7 +1601,7 @@ impl Network { } RpcSuccessResponse::MetaData(meta_data) => { self.peer_manager_mut() - .meta_data_response(&peer_id, meta_data.as_ref().clone()); + .meta_data_response(&peer_id, meta_data); None } /* Network propagated protocols */ diff --git a/common/malloc_utils/src/jemalloc.rs b/common/malloc_utils/src/jemalloc.rs index 2e90c0ddf3..f3a35fc41c 100644 --- a/common/malloc_utils/src/jemalloc.rs +++ b/common/malloc_utils/src/jemalloc.rs @@ -7,11 +7,9 @@ //! //! A) `JEMALLOC_SYS_WITH_MALLOC_CONF` at compile-time. //! B) `_RJEM_MALLOC_CONF` at runtime. -use metrics::{ - set_gauge, set_gauge_vec, try_create_int_gauge, try_create_int_gauge_vec, IntGauge, IntGaugeVec, -}; +use metrics::{set_gauge, try_create_int_gauge, IntGauge}; use std::sync::LazyLock; -use tikv_jemalloc_ctl::{arenas, epoch, raw, stats, Access, AsName, Error}; +use tikv_jemalloc_ctl::{arenas, epoch, stats, Access, AsName, Error}; #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; @@ -35,38 +33,6 @@ pub static BYTES_RESIDENT: LazyLock> = LazyLock::new(| pub static BYTES_RETAINED: LazyLock> = LazyLock::new(|| { try_create_int_gauge("jemalloc_bytes_retained", "Equivalent to stats.retained") }); -pub static JEMALLOC_ARENAS_SMALL_NMALLOC: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge_vec( - "jemalloc_arenas_small_nmalloc", - "Equivalent to stats.arenas..small.nmalloc", - &["arena"], - ) - }); -pub static JEMALLOC_ARENAS_SMALL_NDALLOC: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge_vec( - "jemalloc_arenas_small_ndalloc", - "Equivalent to stats.arenas..small.ndalloc", - &["arena"], - ) - }); -pub static JEMALLOC_ARENAS_LARGE_NMALLOC: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge_vec( - "jemalloc_arenas_large_nmalloc", - "Equivalent to stats.arenas..large.nmalloc", - &["arena"], - ) - }); -pub static JEMALLOC_ARENAS_LARGE_NDALLOC: LazyLock> = - LazyLock::new(|| { - try_create_int_gauge_vec( - "jemalloc_arenas_large_ndalloc", - "Equivalent to stats.arenas..large.ndalloc", - &["arena"], - ) - }); pub fn scrape_jemalloc_metrics() { scrape_jemalloc_metrics_fallible().unwrap() @@ -76,8 +42,7 @@ pub fn scrape_jemalloc_metrics_fallible() -> Result<(), Error> { // Advance the epoch so that the underlying statistics are updated. epoch::advance()?; - let num_arenas = arenas::narenas::read()?; - set_gauge(&NUM_ARENAS, num_arenas as i64); + set_gauge(&NUM_ARENAS, arenas::narenas::read()? as i64); set_gauge(&BYTES_ALLOCATED, stats::allocated::read()? as i64); set_gauge(&BYTES_ACTIVE, stats::active::read()? as i64); set_gauge(&BYTES_MAPPED, stats::mapped::read()? as i64); @@ -85,40 +50,9 @@ pub fn scrape_jemalloc_metrics_fallible() -> Result<(), Error> { set_gauge(&BYTES_RESIDENT, stats::resident::read()? as i64); set_gauge(&BYTES_RETAINED, stats::retained::read()? as i64); - for arena in 0..num_arenas { - unsafe { - set_stats_gauge( - &JEMALLOC_ARENAS_SMALL_NMALLOC, - arena, - &format!("stats.arenas.{arena}.small.nmalloc\0"), - ); - set_stats_gauge( - &JEMALLOC_ARENAS_SMALL_NDALLOC, - arena, - &format!("stats.arenas.{arena}.small.ndalloc\0"), - ); - set_stats_gauge( - &JEMALLOC_ARENAS_LARGE_NMALLOC, - arena, - &format!("stats.arenas.{arena}.large.nmalloc\0"), - ); - set_stats_gauge( - &JEMALLOC_ARENAS_LARGE_NDALLOC, - arena, - &format!("stats.arenas.{arena}.large.ndalloc\0"), - ); - } - } - Ok(()) } -unsafe fn set_stats_gauge(metric: &metrics::Result, arena: u32, stat: &str) { - if let Ok(val) = raw::read::(stat.as_bytes()) { - set_gauge_vec(metric, &[&format!("arena_{arena}")], val as i64); - } -} - pub fn page_size() -> Result { // Full list of keys: https://jemalloc.net/jemalloc.3.html "arenas.page\0".name().read() diff --git a/consensus/state_processing/src/per_block_processing/errors.rs b/consensus/state_processing/src/per_block_processing/errors.rs index ff7c0204e2..fdeec6f08c 100644 --- a/consensus/state_processing/src/per_block_processing/errors.rs +++ b/consensus/state_processing/src/per_block_processing/errors.rs @@ -60,7 +60,6 @@ pub enum BlockProcessingError { SignatureSetError(SignatureSetError), SszTypesError(ssz_types::Error), SszDecodeError(DecodeError), - BitfieldError(ssz::BitfieldError), MerkleTreeError(MerkleTreeError), ArithError(ArithError), InconsistentBlockFork(InconsistentFork), @@ -154,7 +153,6 @@ impl From> for BlockProcessingError { BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e), BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e), BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e), - BlockOperationError::BitfieldError(e) => BlockProcessingError::BitfieldError(e), BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e), BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e), } @@ -183,7 +181,6 @@ macro_rules! impl_into_block_processing_error_with_index { BlockOperationError::BeaconStateError(e) => BlockProcessingError::BeaconStateError(e), BlockOperationError::SignatureSetError(e) => BlockProcessingError::SignatureSetError(e), BlockOperationError::SszTypesError(e) => BlockProcessingError::SszTypesError(e), - BlockOperationError::BitfieldError(e) => BlockProcessingError::BitfieldError(e), BlockOperationError::ConsensusContext(e) => BlockProcessingError::ConsensusContext(e), BlockOperationError::ArithError(e) => BlockProcessingError::ArithError(e), } @@ -218,7 +215,6 @@ pub enum BlockOperationError { BeaconStateError(BeaconStateError), SignatureSetError(SignatureSetError), SszTypesError(ssz_types::Error), - BitfieldError(ssz::BitfieldError), ConsensusContext(ContextError), ArithError(ArithError), } @@ -246,12 +242,6 @@ impl From for BlockOperationError { } } -impl From for BlockOperationError { - fn from(error: ssz::BitfieldError) -> Self { - BlockOperationError::BitfieldError(error) - } -} - impl From for BlockOperationError { fn from(e: ArithError) -> Self { BlockOperationError::ArithError(e) @@ -377,7 +367,6 @@ impl From> BlockOperationError::BeaconStateError(e) => BlockOperationError::BeaconStateError(e), BlockOperationError::SignatureSetError(e) => BlockOperationError::SignatureSetError(e), BlockOperationError::SszTypesError(e) => BlockOperationError::SszTypesError(e), - BlockOperationError::BitfieldError(e) => BlockOperationError::BitfieldError(e), BlockOperationError::ConsensusContext(e) => BlockOperationError::ConsensusContext(e), BlockOperationError::ArithError(e) => BlockOperationError::ArithError(e), } diff --git a/consensus/state_processing/src/per_epoch_processing/errors.rs b/consensus/state_processing/src/per_epoch_processing/errors.rs index 7485e365ec..f45c55a7ac 100644 --- a/consensus/state_processing/src/per_epoch_processing/errors.rs +++ b/consensus/state_processing/src/per_epoch_processing/errors.rs @@ -19,10 +19,9 @@ pub enum EpochProcessingError { BeaconStateError(BeaconStateError), InclusionError(InclusionError), SszTypesError(ssz_types::Error), - BitfieldError(ssz::BitfieldError), ArithError(safe_arith::ArithError), InconsistentStateFork(InconsistentFork), - InvalidJustificationBit(ssz::BitfieldError), + InvalidJustificationBit(ssz_types::Error), InvalidFlagIndex(usize), MilhouseError(milhouse::Error), EpochCache(EpochCacheError), @@ -50,12 +49,6 @@ impl From for EpochProcessingError { } } -impl From for EpochProcessingError { - fn from(e: ssz::BitfieldError) -> EpochProcessingError { - EpochProcessingError::BitfieldError(e) - } -} - impl From for EpochProcessingError { fn from(e: safe_arith::ArithError) -> EpochProcessingError { EpochProcessingError::ArithError(e) diff --git a/consensus/state_processing/src/per_epoch_processing/single_pass.rs b/consensus/state_processing/src/per_epoch_processing/single_pass.rs index 1757254d2c..5c31669a60 100644 --- a/consensus/state_processing/src/per_epoch_processing/single_pass.rs +++ b/consensus/state_processing/src/per_epoch_processing/single_pass.rs @@ -449,11 +449,6 @@ pub fn process_epoch_single_pass( next_epoch_cache.into_epoch_cache(next_epoch_activation_queue, spec)?; } - // As an optimisation, perform an intra-rebase on `inactivity_scores`. They have a tendency to - // be exactly the same for large swathes of consecutive validator indices, so this helps reduce - // memory usage quite a lot. - state.inactivity_scores_mut()?.intra_rebase()?; - Ok(summary) } diff --git a/consensus/types/src/attestation.rs b/consensus/types/src/attestation.rs index 5d147f1e86..1485842edb 100644 --- a/consensus/types/src/attestation.rs +++ b/consensus/types/src/attestation.rs @@ -18,7 +18,6 @@ use super::{ #[derive(Debug, PartialEq)] pub enum Error { SszTypesError(ssz_types::Error), - BitfieldError(ssz::BitfieldError), AlreadySigned(usize), IncorrectStateVariant, InvalidCommitteeLength, @@ -224,7 +223,7 @@ impl Attestation { } } - pub fn get_aggregation_bit(&self, index: usize) -> Result { + pub fn get_aggregation_bit(&self, index: usize) -> Result { match self { Attestation::Base(att) => att.aggregation_bits.get(index), Attestation::Electra(att) => att.aggregation_bits.get(index), @@ -354,13 +353,13 @@ impl AttestationElectra { if self .aggregation_bits .get(committee_position) - .map_err(Error::BitfieldError)? + .map_err(Error::SszTypesError)? { Err(Error::AlreadySigned(committee_position)) } else { self.aggregation_bits .set(committee_position, true) - .map_err(Error::BitfieldError)?; + .map_err(Error::SszTypesError)?; self.signature.add_assign(signature); @@ -428,13 +427,13 @@ impl AttestationBase { if self .aggregation_bits .get(committee_position) - .map_err(Error::BitfieldError)? + .map_err(Error::SszTypesError)? { Err(Error::AlreadySigned(committee_position)) } else { self.aggregation_bits .set(committee_position, true) - .map_err(Error::BitfieldError)?; + .map_err(Error::SszTypesError)?; self.signature.add_assign(signature); @@ -444,7 +443,7 @@ impl AttestationBase { pub fn extend_aggregation_bits( &self, - ) -> Result, ssz::BitfieldError> { + ) -> Result, ssz_types::Error> { self.aggregation_bits.resize::() } } @@ -601,12 +600,12 @@ mod tests { let attestation_data = size_of::(); let signature = size_of::(); - assert_eq!(aggregation_bits, 152); + assert_eq!(aggregation_bits, 56); assert_eq!(attestation_data, 128); assert_eq!(signature, 288 + 16); let attestation_expected = aggregation_bits + attestation_data + signature; - assert_eq!(attestation_expected, 584); + assert_eq!(attestation_expected, 488); assert_eq!( size_of::>(), attestation_expected @@ -624,13 +623,13 @@ mod tests { size_of::::MaxCommitteesPerSlot>>(); let signature = size_of::(); - assert_eq!(aggregation_bits, 152); - assert_eq!(committee_bits, 152); + assert_eq!(aggregation_bits, 56); + assert_eq!(committee_bits, 56); assert_eq!(attestation_data, 128); assert_eq!(signature, 288 + 16); let attestation_expected = aggregation_bits + committee_bits + attestation_data + signature; - assert_eq!(attestation_expected, 736); + assert_eq!(attestation_expected, 544); assert_eq!( size_of::>(), attestation_expected diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 7738002181..4aed79898d 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -2470,11 +2470,6 @@ impl BeaconState { // rebuild and likely to be re-usable from the base state. self.rebase_caches_on(base, spec)?; - // Perform an intra-rebase of the inactivity scores (if any). - if let Ok(inactivity_scores) = self.inactivity_scores_mut() { - inactivity_scores.intra_rebase()?; - } - Ok(()) } diff --git a/consensus/types/src/sync_aggregate.rs b/consensus/types/src/sync_aggregate.rs index 12b91501ae..43f72a3924 100644 --- a/consensus/types/src/sync_aggregate.rs +++ b/consensus/types/src/sync_aggregate.rs @@ -11,7 +11,6 @@ use tree_hash_derive::TreeHash; #[derive(Debug, PartialEq)] pub enum Error { SszTypesError(ssz_types::Error), - BitfieldError(ssz::BitfieldError), ArithError(ArithError), } @@ -69,7 +68,7 @@ impl SyncAggregate { sync_aggregate .sync_committee_bits .set(participant_index, true) - .map_err(Error::BitfieldError)?; + .map_err(Error::SszTypesError)?; } } sync_aggregate diff --git a/consensus/types/src/sync_committee_contribution.rs b/consensus/types/src/sync_committee_contribution.rs index 58983d26ec..9bae770fe5 100644 --- a/consensus/types/src/sync_committee_contribution.rs +++ b/consensus/types/src/sync_committee_contribution.rs @@ -9,7 +9,6 @@ use tree_hash_derive::TreeHash; #[derive(Debug, PartialEq)] pub enum Error { SszTypesError(ssz_types::Error), - BitfieldError(ssz::BitfieldError), AlreadySigned(usize), } @@ -52,7 +51,7 @@ impl SyncCommitteeContribution { ) -> Result { let mut bits = BitVector::new(); bits.set(validator_sync_committee_index, true) - .map_err(Error::BitfieldError)?; + .map_err(Error::SszTypesError)?; Ok(Self { slot: message.slot, beacon_block_root: message.beacon_block_root,