Skip to content

Commit 3b788bf

Browse files
committed
Make max_blobs_per_block a config parameter (#6329)
Squashed commit of the following: commit 04b3743 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 17:36:58 2025 +1100 Add test commit 440e854 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 17:24:50 2025 +1100 Move RuntimeFixedVector into module and rename commit f66e179 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 17:17:17 2025 +1100 Fix release tests commit e4bfe71 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 17:05:30 2025 +1100 Thread through ChainSpec commit 063b79c Author: Michael Sproul <[email protected]> Date: Mon Jan 6 15:32:16 2025 +1100 Try fixing tests commit 88bedf0 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 15:04:37 2025 +1100 Revert "Remove footgun function" This reverts commit de01f92. commit 32483d3 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 15:04:32 2025 +1100 Fix typo commit 2e86585 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 15:04:15 2025 +1100 Move from preset to config commit 1095d60 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 14:38:40 2025 +1100 Minor simplifications commit de01f92 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 14:06:57 2025 +1100 Remove footgun function commit 0c2c8c4 Merge: 21ecb58 f51a292 Author: Michael Sproul <[email protected]> Date: Mon Jan 6 14:02:50 2025 +1100 Merge remote-tracking branch 'origin/unstable' into max-blobs-preset commit f51a292 Author: Daniel Knopik <[email protected]> Date: Fri Jan 3 20:27:21 2025 +0100 fully lint only explicitly to avoid unnecessary rebuilds (#6753) * fully lint only explicitly to avoid unnecessary rebuilds commit 7e0cdde Author: Akihito Nakano <[email protected]> Date: Tue Dec 24 10:38:56 2024 +0900 Make sure we have fanout peers when publish (#6738) * Ensure that `fanout_peers` is always non-empty if it's `Some` commit 21ecb58 Merge: 2fcb293 9aefb55 Author: Pawan Dhananjay <[email protected]> Date: Mon Oct 21 14:46:00 2024 -0700 Merge branch 'unstable' into max-blobs-preset commit 2fcb293 Author: Pawan Dhananjay <[email protected]> Date: Fri Sep 6 18:28:31 2024 -0700 Fix test from unstable commit 12c6ef1 Author: Pawan Dhananjay <[email protected]> Date: Wed Sep 4 16:16:36 2024 -0700 Fix some more tests commit d37733b Author: Pawan Dhananjay <[email protected]> Date: Wed Sep 4 12:47:36 2024 -0700 Fix test compilations commit 52bb581 Author: Pawan Dhananjay <[email protected]> Date: Tue Sep 3 18:38:19 2024 -0700 cleanup commit e71020e Author: Pawan Dhananjay <[email protected]> Date: Tue Sep 3 17:16:10 2024 -0700 Fix take impl on RuntimeFixedList commit 13f9bba Merge: 60100fc 4e675cf Author: Pawan Dhananjay <[email protected]> Date: Tue Sep 3 16:08:59 2024 -0700 Merge branch 'unstable' into max-blobs-preset commit 60100fc Author: Pawan Dhananjay <[email protected]> Date: Fri Aug 30 16:04:11 2024 -0700 Fix some todos commit a9cb329 Author: Pawan Dhananjay <[email protected]> Date: Fri Aug 30 15:54:00 2024 -0700 Use empty_uninitialized and fix warnings commit 4dc6e65 Author: Pawan Dhananjay <[email protected]> Date: Fri Aug 30 15:53:18 2024 -0700 Add restrictions to RuntimeVariableList api commit 25feedf Author: Pawan Dhananjay <[email protected]> Date: Thu Aug 29 16:11:19 2024 -0700 First pass
1 parent 2dbd3b7 commit 3b788bf

File tree

51 files changed

+559
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+559
-263
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[env]
22
# Set the number of arenas to 16 when using jemalloc.
33
JEMALLOC_SYS_WITH_MALLOC_CONF = "abort_conf:true,narenas:16"
4+

.github/workflows/test-suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ jobs:
350350
- name: Check formatting with cargo fmt
351351
run: make cargo-fmt
352352
- name: Lint code for quality and style with Clippy
353-
run: make lint
353+
run: make lint-full
354354
- name: Certify Cargo.lock freshness
355355
run: git diff --exit-code Cargo.lock
356356
- name: Typecheck benchmark code without running it

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ test-full: cargo-fmt test-release test-debug test-ef test-exec-engine
204204
# Lints the code for bad style and potentially unsafe arithmetic using Clippy.
205205
# Clippy lints are opt-in per-crate for now. By default, everything is allowed except for performance and correctness lints.
206206
lint:
207-
RUSTFLAGS="-C debug-assertions=no $(RUSTFLAGS)" cargo clippy --workspace --benches --tests $(EXTRA_CLIPPY_OPTS) --features "$(TEST_FEATURES)" -- \
207+
cargo clippy --workspace --benches --tests $(EXTRA_CLIPPY_OPTS) --features "$(TEST_FEATURES)" -- \
208208
-D clippy::fn_to_numeric_cast_any \
209209
-D clippy::manual_let_else \
210210
-D clippy::large_stack_frames \
@@ -220,6 +220,10 @@ lint:
220220
lint-fix:
221221
EXTRA_CLIPPY_OPTS="--fix --allow-staged --allow-dirty" $(MAKE) lint
222222

223+
# Also run the lints on the optimized-only tests
224+
lint-full:
225+
RUSTFLAGS="-C debug-assertions=no $(RUSTFLAGS)" $(MAKE) lint
226+
223227
# Runs the makefile in the `ef_tests` repo.
224228
#
225229
# May download and extract an archive of test vectors from the ethereum

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
12431243
pub fn get_blobs(&self, block_root: &Hash256) -> Result<BlobSidecarList<T::EthSpec>, Error> {
12441244
match self.store.get_blobs(block_root)? {
12451245
Some(blobs) => Ok(blobs),
1246-
None => Ok(BlobSidecarList::default()),
1246+
None => Ok(BlobSidecarList::empty_uninitialized()),
12471247
}
12481248
}
12491249

beacon_node/beacon_chain/src/blob_verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
400400
// since we only subscribe to `MaxBlobsPerBlock` subnets over gossip network.
401401
// We include this check only for completeness.
402402
// Getting this error would imply something very wrong with our networking decoding logic.
403-
if blob_index >= T::EthSpec::max_blobs_per_block() as u64 {
403+
if blob_index >= chain.spec.max_blobs_per_block(blob_epoch) {
404404
return Err(GossipBlobError::InvalidSubnet {
405405
expected: subnet,
406406
received: blob_index,

beacon_node/beacon_chain/src/block_verification_types.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ use crate::data_column_verification::{CustodyDataColumn, CustodyDataColumnList};
44
use crate::eth1_finalization_cache::Eth1FinalizationData;
55
use crate::{get_block_root, PayloadVerificationOutcome};
66
use derivative::Derivative;
7-
use ssz_types::VariableList;
87
use state_processing::ConsensusContext;
98
use std::fmt::{Debug, Formatter};
109
use std::sync::Arc;
11-
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
10+
use types::blob_sidecar::BlobIdentifier;
1211
use types::{
1312
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, ChainSpec, Epoch, EthSpec,
1413
Hash256, RuntimeVariableList, SignedBeaconBlock, SignedBeaconBlockHeader, Slot,
@@ -176,23 +175,6 @@ impl<E: EthSpec> RpcBlock<E> {
176175
})
177176
}
178177

179-
pub fn new_from_fixed(
180-
block_root: Hash256,
181-
block: Arc<SignedBeaconBlock<E>>,
182-
blobs: FixedBlobSidecarList<E>,
183-
) -> Result<Self, AvailabilityCheckError> {
184-
let filtered = blobs
185-
.into_iter()
186-
.filter_map(|b| b.clone())
187-
.collect::<Vec<_>>();
188-
let blobs = if filtered.is_empty() {
189-
None
190-
} else {
191-
Some(VariableList::from(filtered))
192-
};
193-
Self::new(Some(block_root), block, blobs)
194-
}
195-
196178
#[allow(clippy::type_complexity)]
197179
pub fn deconstruct(
198180
self,

beacon_node/beacon_chain/src/data_availability_checker.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
215215
// Note: currently not reporting which specific blob is invalid because we fetch all blobs
216216
// from the same peer for both lookup and range sync.
217217

218-
let verified_blobs =
219-
KzgVerifiedBlobList::new(blobs.iter().flatten().cloned(), &self.kzg, seen_timestamp)
220-
.map_err(AvailabilityCheckError::InvalidBlobs)?;
218+
let verified_blobs = KzgVerifiedBlobList::new(
219+
blobs.into_vec().into_iter().flatten(),
220+
&self.kzg,
221+
seen_timestamp,
222+
)
223+
.map_err(AvailabilityCheckError::InvalidBlobs)?;
221224

222225
self.availability_cache
223226
.put_kzg_verified_blobs(block_root, verified_blobs, &self.log)
@@ -400,14 +403,13 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
400403
blocks: Vec<RpcBlock<T::EthSpec>>,
401404
) -> Result<Vec<MaybeAvailableBlock<T::EthSpec>>, AvailabilityCheckError> {
402405
let mut results = Vec::with_capacity(blocks.len());
403-
let all_blobs: BlobSidecarList<T::EthSpec> = blocks
406+
let all_blobs = blocks
404407
.iter()
405408
.filter(|block| self.blobs_required_for_block(block.as_block()))
406409
// this clone is cheap as it's cloning an Arc
407410
.filter_map(|block| block.blobs().cloned())
408411
.flatten()
409-
.collect::<Vec<_>>()
410-
.into();
412+
.collect::<Vec<_>>();
411413

412414
// verify kzg for all blobs at once
413415
if !all_blobs.is_empty() {

0 commit comments

Comments
 (0)