Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump SSZ version for larger bitfield SmallVec #6915

Open
wants to merge 45 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
896c40a
Add decode impl
paulhauner Nov 25, 2024
c124eac
Add encode impl
paulhauner Nov 25, 2024
603b4b2
Add todo impls
paulhauner Nov 25, 2024
6a81218
Fix compile errors
paulhauner Nov 25, 2024
8cd04c6
Fix decode impl
paulhauner Nov 25, 2024
89431fd
Use updated ssz_types repo
paulhauner Nov 25, 2024
3964cba
Avoid sanitize_offset fn
paulhauner Nov 25, 2024
6eaace5
Use ssz-types with bigger smallvec
paulhauner Nov 26, 2024
fe7e3f5
Impl tree hash
paulhauner Nov 26, 2024
b5b70b1
Tidy, add comments
paulhauner Nov 26, 2024
1e21198
Implement tests for tree_hash
paulhauner Dec 2, 2024
b51ccb1
Add ssz tests
paulhauner Dec 2, 2024
c75f203
Add malicious ssz tests
paulhauner Dec 3, 2024
7fabbc0
Add random vectors to tests
paulhauner Dec 3, 2024
1313255
Custom Checkpoint SSZ impls
paulhauner Dec 3, 2024
31ea1d5
Implement serde
paulhauner Dec 4, 2024
dd7b97e
Impl arbitrary
paulhauner Dec 4, 2024
56ad1ce
Rename struct, fix tests and lints
paulhauner Dec 4, 2024
ff5258d
Merge branch 'unstable' into tx-opaque
paulhauner Dec 4, 2024
e0fd189
Fix clippy lint
paulhauner Dec 4, 2024
3ca39f2
Bump some crate versions
paulhauner Dec 5, 2024
06f4b68
Merge branch 'unstable' into tx-opaque
paulhauner Dec 19, 2024
432755c
Bump ssz_types version
paulhauner Jan 6, 2025
9dffa74
Change milhouse commit
paulhauner Jan 6, 2025
07785d9
Bump ssz version
paulhauner Jan 6, 2025
c67f9b1
Fix bitfield compile errors
paulhauner Jan 6, 2025
af13240
Bump to milhouse 0.5
paulhauner Jan 16, 2025
0d81f1c
Merge remote-tracking branch 'origin/unstable' into tx-opaque
michaelsproul Jan 20, 2025
6fe58c9
Fix test_utils
michaelsproul Jan 20, 2025
01e1c17
Add ssz_fixed_len impl
paulhauner Feb 4, 2025
2d39282
Avoid clippy ignores with saturating math
paulhauner Feb 4, 2025
d9476f7
Merge branch 'unstable' into tx-opaque
paulhauner Feb 4, 2025
10cf10f
Use `String` for decoding
paulhauner Feb 4, 2025
9900ad8
Revert "Avoid clippy ignores with saturating math"
paulhauner Feb 4, 2025
88c85da
Use unchecked math
paulhauner Feb 4, 2025
91ecdde
Add test for ssz_bytes_len
paulhauner Feb 4, 2025
ebfdc0b
Fix tests
paulhauner Feb 4, 2025
505429b
Bump size tests
paulhauner Feb 5, 2025
200ff53
Wrap `MetaData` in an Arc
paulhauner Feb 5, 2025
adf95fa
Fix stack size clippy lint
paulhauner Feb 5, 2025
2eafcd4
Revert transaction and checkpoint changes
paulhauner Feb 5, 2025
70bd2ba
Empty commit for CI
paulhauner Feb 5, 2025
b07ee58
Add a high-level Box::pin for clippy stack size lints
paulhauner Feb 9, 2025
ffffae2
Merge branch 'unstable' into ssz-bitfield-bump
paulhauner Feb 9, 2025
e251346
Add BitfieldError to BlockProcessingError
paulhauner Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 52 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.7"
ethereum_ssz_derive = "0.7"
ethereum_ssz = "0.8.2"
ethereum_ssz_derive = "0.8.2"
ethers-core = "1"
ethers-providers = { version = "1", default-features = false }
exit-future = "0.2"
Expand All @@ -156,7 +156,7 @@ libsecp256k1 = "0.7"
log = "0.4"
lru = "0.12"
maplit = "1"
milhouse = "0.3"
milhouse = "0.5"
mockito = "1.5.0"
num_cpus = "1"
parking_lot = "0.12"
Expand Down Expand Up @@ -194,7 +194,7 @@ slog-term = "2"
sloggers = { version = "2", features = ["json"] }
smallvec = { version = "1.11.2", features = ["arbitrary"] }
snap = "1"
ssz_types = "0.8"
ssz_types = "0.10"
strum = { version = "0.24", features = ["derive"] }
superstruct = "0.8"
syn = "1"
Expand All @@ -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.8"
tree_hash_derive = "0.8"
tree_hash = "0.9"
tree_hash_derive = "0.9"
url = "2"
uuid = { version = "0.8", features = ["serde", "v4"] }
warp = { version = "0.3.7", default-features = false, features = ["tls"] }
Expand Down
20 changes: 10 additions & 10 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2712,16 +2712,16 @@ where
let mut block_hash_from_slot: HashMap<Slot, SignedBeaconBlockHash> = HashMap::new();
let mut state_hash_from_slot: HashMap<Slot, BeaconStateHash> = HashMap::new();
for slot in slots {
let (block_hash, new_state) = self
.add_attested_block_at_slot_with_sync(
*slot,
state,
state_root,
validators,
sync_committee_strategy,
)
.await
.unwrap();
// 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();

state = new_state;

Expand Down
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/tests/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ async fn test_rewards_base_multi_inclusion() {
.extend_slots(E::slots_per_epoch() as usize * 2 - 4)
.await;

// pin to reduce stack size for clippy
Box::pin(check_all_base_rewards(&harness, initial_balances)).await;
check_all_base_rewards(&harness, initial_balances).await;
}

#[tokio::test]
Expand Down Expand Up @@ -692,7 +691,8 @@ async fn check_all_base_rewards(
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
balances: Vec<u64>,
) {
check_all_base_rewards_for_subset(harness, balances, vec![]).await;
// The box reduces the size on the stack for a clippy lint.
Box::pin(check_all_base_rewards_for_subset(harness, balances, vec![])).await;
}

async fn check_all_base_rewards_for_subset(
Expand Down
23 changes: 14 additions & 9 deletions beacon_node/lighthouse_network/src/rpc/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ fn handle_rpc_response<E: EthSpec>(
SupportedProtocol::PingV1 => Ok(Some(RpcSuccessResponse::Pong(Ping {
data: u64::from_ssz_bytes(decoded_buffer)?,
}))),
SupportedProtocol::MetaDataV1 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V1(
MetaDataV1::from_ssz_bytes(decoded_buffer)?,
SupportedProtocol::MetaDataV1 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new(
MetaData::V1(MetaDataV1::from_ssz_bytes(decoded_buffer)?),
)))),
SupportedProtocol::LightClientBootstrapV1 => match fork_name {
Some(fork_name) => Ok(Some(RpcSuccessResponse::LightClientBootstrap(Arc::new(
Expand Down Expand Up @@ -826,11 +826,11 @@ fn handle_rpc_response<E: EthSpec>(
)),
},
// MetaData V2/V3 responses have no context bytes, so behave similarly to V1 responses
SupportedProtocol::MetaDataV3 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V3(
MetaDataV3::from_ssz_bytes(decoded_buffer)?,
SupportedProtocol::MetaDataV3 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new(
MetaData::V3(MetaDataV3::from_ssz_bytes(decoded_buffer)?),
)))),
SupportedProtocol::MetaDataV2 => Ok(Some(RpcSuccessResponse::MetaData(MetaData::V2(
MetaDataV2::from_ssz_bytes(decoded_buffer)?,
SupportedProtocol::MetaDataV2 => Ok(Some(RpcSuccessResponse::MetaData(Arc::new(
MetaData::V2(MetaDataV2::from_ssz_bytes(decoded_buffer)?),
)))),
SupportedProtocol::BlocksByRangeV2 => match fork_name {
Some(ForkName::Altair) => Ok(Some(RpcSuccessResponse::BlocksByRange(Arc::new(
Expand Down Expand Up @@ -1008,6 +1008,7 @@ mod tests {
) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockBellatrix<_, FullPayload<Spec>> =
BeaconBlockBellatrix::empty(&Spec::default_spec());

let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(5000).collect::<Vec<_>>());

Expand All @@ -1027,6 +1028,7 @@ mod tests {
) -> SignedBeaconBlock<Spec> {
let mut block: BeaconBlockBellatrix<_, FullPayload<Spec>> =
BeaconBlockBellatrix::empty(&Spec::default_spec());

let tx = VariableList::from(vec![0; 1024]);
let txs = VariableList::from(std::iter::repeat(tx).take(100000).collect::<Vec<_>>());

Expand Down Expand Up @@ -1105,28 +1107,31 @@ mod tests {
Ping { data: 1 }
}

fn metadata() -> MetaData<Spec> {
fn metadata() -> Arc<MetaData<Spec>> {
MetaData::V1(MetaDataV1 {
seq_number: 1,
attnets: EnrAttestationBitfield::<Spec>::default(),
})
.into()
}

fn metadata_v2() -> MetaData<Spec> {
fn metadata_v2() -> Arc<MetaData<Spec>> {
MetaData::V2(MetaDataV2 {
seq_number: 1,
attnets: EnrAttestationBitfield::<Spec>::default(),
syncnets: EnrSyncCommitteeBitfield::<Spec>::default(),
})
.into()
}

fn metadata_v3() -> MetaData<Spec> {
fn metadata_v3() -> Arc<MetaData<Spec>> {
MetaData::V3(MetaDataV3 {
seq_number: 1,
attnets: EnrAttestationBitfield::<Spec>::default(),
syncnets: EnrSyncCommitteeBitfield::<Spec>::default(),
custody_group_count: 1,
})
.into()
}

/// Encodes the given protocol response as bytes.
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/rpc/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ pub enum RpcSuccessResponse<E: EthSpec> {
Pong(Ping),

/// A response to a META_DATA request.
MetaData(MetaData<E>),
MetaData(Arc<MetaData<E>>),
}

/// Indicates which response is being terminated by a stream termination response.
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/lighthouse_network/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ impl<E: EthSpec> Network<E> {
) {
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(metadata));
let event = RpcResponse::Success(RpcSuccessResponse::MetaData(Arc::new(metadata)));
self.eth2_rpc_mut()
.send_response(peer_id, id, request_id, event);
}
Expand Down Expand Up @@ -1601,7 +1601,7 @@ impl<E: EthSpec> Network<E> {
}
RpcSuccessResponse::MetaData(meta_data) => {
self.peer_manager_mut()
.meta_data_response(&peer_id, meta_data);
.meta_data_response(&peer_id, meta_data.as_ref().clone());
None
}
/* Network propagated protocols */
Expand Down
11 changes: 11 additions & 0 deletions consensus/state_processing/src/per_block_processing/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub enum BlockProcessingError {
SignatureSetError(SignatureSetError),
SszTypesError(ssz_types::Error),
SszDecodeError(DecodeError),
BitfieldError(ssz::BitfieldError),
MerkleTreeError(MerkleTreeError),
ArithError(ArithError),
InconsistentBlockFork(InconsistentFork),
Expand Down Expand Up @@ -153,6 +154,7 @@ impl From<BlockOperationError<HeaderInvalid>> 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),
}
Expand Down Expand Up @@ -181,6 +183,7 @@ 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),
}
Expand Down Expand Up @@ -215,6 +218,7 @@ pub enum BlockOperationError<T> {
BeaconStateError(BeaconStateError),
SignatureSetError(SignatureSetError),
SszTypesError(ssz_types::Error),
BitfieldError(ssz::BitfieldError),
ConsensusContext(ContextError),
ArithError(ArithError),
}
Expand Down Expand Up @@ -242,6 +246,12 @@ impl<T> From<ssz_types::Error> for BlockOperationError<T> {
}
}

impl<T> From<ssz::BitfieldError> for BlockOperationError<T> {
fn from(error: ssz::BitfieldError) -> Self {
BlockOperationError::BitfieldError(error)
}
}

impl<T> From<ArithError> for BlockOperationError<T> {
fn from(e: ArithError) -> Self {
BlockOperationError::ArithError(e)
Expand Down Expand Up @@ -367,6 +377,7 @@ impl From<BlockOperationError<IndexedAttestationInvalid>>
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),
}
Expand Down
Loading