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

Make max_blobs_per_block a config parameter #6329

Merged
merged 37 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
25feedf
First pass
pawanjay176 Aug 29, 2024
4dc6e65
Add restrictions to RuntimeVariableList api
pawanjay176 Aug 30, 2024
a9cb329
Use empty_uninitialized and fix warnings
pawanjay176 Aug 30, 2024
60100fc
Fix some todos
pawanjay176 Aug 30, 2024
13f9bba
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Sep 3, 2024
e71020e
Fix take impl on RuntimeFixedList
pawanjay176 Sep 4, 2024
52bb581
cleanup
pawanjay176 Sep 4, 2024
d37733b
Fix test compilations
pawanjay176 Sep 4, 2024
12c6ef1
Fix some more tests
pawanjay176 Sep 4, 2024
2fcb293
Fix test from unstable
pawanjay176 Sep 7, 2024
21ecb58
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Oct 21, 2024
0c2c8c4
Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
michaelsproul Jan 6, 2025
de01f92
Remove footgun function
michaelsproul Jan 6, 2025
1095d60
Minor simplifications
michaelsproul Jan 6, 2025
2e86585
Move from preset to config
michaelsproul Jan 6, 2025
32483d3
Fix typo
michaelsproul Jan 6, 2025
88bedf0
Revert "Remove footgun function"
michaelsproul Jan 6, 2025
063b79c
Try fixing tests
michaelsproul Jan 6, 2025
e4bfe71
Thread through ChainSpec
michaelsproul Jan 6, 2025
f66e179
Fix release tests
michaelsproul Jan 6, 2025
440e854
Move RuntimeFixedVector into module and rename
michaelsproul Jan 6, 2025
04b3743
Add test
michaelsproul Jan 6, 2025
0cd263f
Remove empty RuntimeVarList awefullness
pawanjay176 Jan 7, 2025
7c215f8
Fix tests
pawanjay176 Jan 7, 2025
26c409c
Simplify BlobSidecarListFromRoot
michaelsproul Jan 7, 2025
07c039c
Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
michaelsproul Jan 9, 2025
d4e152c
Bump quota to account for new target (6)
michaelsproul Jan 9, 2025
a73ecb5
Remove clone
michaelsproul Jan 9, 2025
f13bdfc
Fix issue from review
pawanjay176 Jan 9, 2025
70917f7
Try to remove ugliness
pawanjay176 Jan 10, 2025
22b7fcb
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Jan 10, 2025
56602c1
Fix max value
pawanjay176 Jan 10, 2025
e6ba98b
Fix doctest
michaelsproul Jan 10, 2025
dbad9d8
Fix formatting
michaelsproul Jan 10, 2025
97d8dab
Fix max check
michaelsproul Jan 10, 2025
a435b3b
Delete hardcoded max_blobs_per_block in RPC limits
michaelsproul Jan 10, 2025
7434d5b
Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
michaelsproul Jan 10, 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
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[env]
# Set the number of arenas to 16 when using jemalloc.
JEMALLOC_SYS_WITH_MALLOC_CONF = "abort_conf:true,narenas:16"

16 changes: 9 additions & 7 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ use std::sync::Arc;
use std::time::Duration;
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
use store::{
DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
BlobSidecarListFromRoot, DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore,
KeyValueStoreOp, StoreItem, StoreOp,
};
use task_executor::{ShutdownReason, TaskExecutor};
use tokio::sync::mpsc::Receiver;
Expand Down Expand Up @@ -1147,9 +1148,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
pub fn get_blobs_checking_early_attester_cache(
&self,
block_root: &Hash256,
) -> Result<BlobSidecarList<T::EthSpec>, Error> {
) -> Result<BlobSidecarListFromRoot<T::EthSpec>, Error> {
self.early_attester_cache
.get_blobs(*block_root)
.map(Into::into)
.map_or_else(|| self.get_blobs(block_root), Ok)
}

Expand Down Expand Up @@ -1240,11 +1242,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
///
/// ## Errors
/// May return a database error.
pub fn get_blobs(&self, block_root: &Hash256) -> Result<BlobSidecarList<T::EthSpec>, Error> {
match self.store.get_blobs(block_root)? {
Some(blobs) => Ok(blobs),
None => Ok(BlobSidecarList::default()),
}
pub fn get_blobs(
&self,
block_root: &Hash256,
) -> Result<BlobSidecarListFromRoot<T::EthSpec>, Error> {
self.store.get_blobs(block_root).map_err(Error::from)
}

/// Returns the data columns at the given root, if any.
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/blob_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ pub fn validate_blob_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrat
// since we only subscribe to `MaxBlobsPerBlock` subnets over gossip network.
// We include this check only for completeness.
// Getting this error would imply something very wrong with our networking decoding logic.
if blob_index >= T::EthSpec::max_blobs_per_block() as u64 {
if blob_index >= chain.spec.max_blobs_per_block(blob_epoch) {
return Err(GossipBlobError::InvalidSubnet {
expected: subnet,
received: blob_index,
Expand Down
20 changes: 1 addition & 19 deletions beacon_node/beacon_chain/src/block_verification_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ use crate::data_column_verification::{CustodyDataColumn, CustodyDataColumnList};
use crate::eth1_finalization_cache::Eth1FinalizationData;
use crate::{get_block_root, PayloadVerificationOutcome};
use derivative::Derivative;
use ssz_types::VariableList;
use state_processing::ConsensusContext;
use std::fmt::{Debug, Formatter};
use std::sync::Arc;
use types::blob_sidecar::{BlobIdentifier, FixedBlobSidecarList};
use types::blob_sidecar::BlobIdentifier;
use types::{
BeaconBlockRef, BeaconState, BlindedPayload, BlobSidecarList, ChainSpec, Epoch, EthSpec,
Hash256, RuntimeVariableList, SignedBeaconBlock, SignedBeaconBlockHeader, Slot,
Expand Down Expand Up @@ -176,23 +175,6 @@ impl<E: EthSpec> RpcBlock<E> {
})
}

pub fn new_from_fixed(
block_root: Hash256,
block: Arc<SignedBeaconBlock<E>>,
blobs: FixedBlobSidecarList<E>,
) -> Result<Self, AvailabilityCheckError> {
let filtered = blobs
.into_iter()
.filter_map(|b| b.clone())
.collect::<Vec<_>>();
let blobs = if filtered.is_empty() {
None
} else {
Some(VariableList::from(filtered))
};
Self::new(Some(block_root), block, blobs)
}

#[allow(clippy::type_complexity)]
pub fn deconstruct(
self,
Expand Down
14 changes: 8 additions & 6 deletions beacon_node/beacon_chain/src/data_availability_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
// Note: currently not reporting which specific blob is invalid because we fetch all blobs
// from the same peer for both lookup and range sync.

let verified_blobs =
KzgVerifiedBlobList::new(blobs.iter().flatten().cloned(), &self.kzg, seen_timestamp)
.map_err(AvailabilityCheckError::InvalidBlobs)?;
let verified_blobs = KzgVerifiedBlobList::new(
blobs.into_vec().into_iter().flatten(),
&self.kzg,
seen_timestamp,
)
.map_err(AvailabilityCheckError::InvalidBlobs)?;

self.availability_cache
.put_kzg_verified_blobs(block_root, verified_blobs, &self.log)
Expand Down Expand Up @@ -400,14 +403,13 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
blocks: Vec<RpcBlock<T::EthSpec>>,
) -> Result<Vec<MaybeAvailableBlock<T::EthSpec>>, AvailabilityCheckError> {
let mut results = Vec::with_capacity(blocks.len());
let all_blobs: BlobSidecarList<T::EthSpec> = blocks
let all_blobs = blocks
.iter()
.filter(|block| self.blobs_required_for_block(block.as_block()))
// this clone is cheap as it's cloning an Arc
.filter_map(|block| block.blobs().cloned())
.flatten()
.collect::<Vec<_>>()
.into();
.collect::<Vec<_>>();

// verify kzg for all blobs at once
if !all_blobs.is_empty() {
Expand Down
Loading
Loading