Make max_blobs_per_block a config parameter (#6329)

* First pass

* Add restrictions to RuntimeVariableList api

* Use empty_uninitialized and fix warnings

* Fix some todos

* Merge branch 'unstable' into max-blobs-preset

* Fix take impl on RuntimeFixedList

* cleanup

* Fix test compilations

* Fix some more tests

* Fix test from unstable

* Merge branch 'unstable' into max-blobs-preset

* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset

* Remove footgun function

* Minor simplifications

* Move from preset to config

* Fix typo

* Revert "Remove footgun function"

This reverts commit de01f923c7.

* Try fixing tests

* Thread through ChainSpec

* Fix release tests

* Move RuntimeFixedVector into module and rename

* Add test

* Remove empty RuntimeVarList awefullness

* Fix tests

* Simplify BlobSidecarListFromRoot

* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset

* Bump quota to account for new target (6)

* Remove clone

* Fix issue from review

* Try to remove ugliness

* Merge branch 'unstable' into max-blobs-preset

* Fix max value

* Fix doctest

* Fix formatting

* Fix max check

* Delete hardcoded max_blobs_per_block in RPC limits

* Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
This commit is contained in:
Pawan Dhananjay
2025-01-10 12:04:58 +05:30
committed by GitHub
parent ecdf2d891f
commit 05727290fb
61 changed files with 655 additions and 335 deletions

View File

@@ -1383,7 +1383,8 @@ mod test {
impl Tester {
pub fn new(with_auth: bool) -> Self {
let server = MockServer::unit_testing();
let spec = Arc::new(MainnetEthSpec::default_spec());
let server = MockServer::unit_testing(spec);
let rpc_url = SensitiveUrl::parse(&server.url()).unwrap();
let echo_url = SensitiveUrl::parse(&format!("{}/echo", server.url())).unwrap();

View File

@@ -154,6 +154,7 @@ pub struct ExecutionBlockGenerator<E: EthSpec> {
pub blobs_bundles: HashMap<PayloadId, BlobsBundle<E>>,
pub kzg: Option<Arc<Kzg>>,
rng: Arc<Mutex<StdRng>>,
spec: Arc<ChainSpec>,
}
fn make_rng() -> Arc<Mutex<StdRng>> {
@@ -172,6 +173,7 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
cancun_time: Option<u64>,
prague_time: Option<u64>,
osaka_time: Option<u64>,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
let mut gen = Self {
@@ -192,6 +194,7 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
blobs_bundles: <_>::default(),
kzg,
rng: make_rng(),
spec,
};
gen.insert_pow_block(0).unwrap();
@@ -697,7 +700,11 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
if execution_payload.fork_name().deneb_enabled() {
// get random number between 0 and Max Blobs
let mut rng = self.rng.lock();
let num_blobs = rng.gen::<usize>() % (E::max_blobs_per_block() + 1);
let max_blobs = self
.spec
.max_blobs_per_block_by_fork(execution_payload.fork_name())
as usize;
let num_blobs = rng.gen::<usize>() % (max_blobs + 1);
let (bundle, transactions) = generate_blobs(num_blobs)?;
for tx in Vec::from(transactions) {
execution_payload
@@ -906,6 +913,7 @@ mod test {
const TERMINAL_DIFFICULTY: u64 = 10;
const TERMINAL_BLOCK: u64 = 10;
const DIFFICULTY_INCREMENT: u64 = 1;
let spec = Arc::new(MainnetEthSpec::default_spec());
let mut generator: ExecutionBlockGenerator<MainnetEthSpec> = ExecutionBlockGenerator::new(
Uint256::from(TERMINAL_DIFFICULTY),
@@ -915,6 +923,7 @@ mod test {
None,
None,
None,
spec,
None,
);

View File

@@ -13,7 +13,7 @@ pub struct MockExecutionLayer<E: EthSpec> {
pub server: MockServer<E>,
pub el: ExecutionLayer<E>,
pub executor: TaskExecutor,
pub spec: ChainSpec,
pub spec: Arc<ChainSpec>,
}
impl<E: EthSpec> MockExecutionLayer<E> {
@@ -30,7 +30,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
None,
None,
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
spec,
Arc::new(spec),
None,
)
}
@@ -44,7 +44,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
prague_time: Option<u64>,
osaka_time: Option<u64>,
jwt_key: Option<JwtKey>,
spec: ChainSpec,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
let handle = executor.handle().unwrap();
@@ -60,6 +60,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
cancun_time,
prague_time,
osaka_time,
spec.clone(),
kzg,
);
@@ -323,7 +324,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
pub async fn with_terminal_block<U, V>(self, func: U) -> Self
where
U: Fn(ChainSpec, ExecutionLayer<E>, Option<ExecutionBlock>) -> V,
U: Fn(Arc<ChainSpec>, ExecutionLayer<E>, Option<ExecutionBlock>) -> V,
V: Future<Output = ()>,
{
let terminal_block_number = self

View File

@@ -21,7 +21,7 @@ use std::marker::PhantomData;
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use std::sync::{Arc, LazyLock};
use tokio::{runtime, sync::oneshot};
use types::{EthSpec, ExecutionBlockHash, Uint256};
use types::{ChainSpec, EthSpec, ExecutionBlockHash, Uint256};
use warp::{http::StatusCode, Filter, Rejection};
use crate::EngineCapabilities;
@@ -111,7 +111,7 @@ pub struct MockServer<E: EthSpec> {
}
impl<E: EthSpec> MockServer<E> {
pub fn unit_testing() -> Self {
pub fn unit_testing(chain_spec: Arc<ChainSpec>) -> Self {
Self::new(
&runtime::Handle::current(),
JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap(),
@@ -122,6 +122,7 @@ impl<E: EthSpec> MockServer<E> {
None, // FIXME(deneb): should this be the default?
None, // FIXME(electra): should this be the default?
None, // FIXME(fulu): should this be the default?
chain_spec,
None,
)
}
@@ -129,6 +130,7 @@ impl<E: EthSpec> MockServer<E> {
pub fn new_with_config(
handle: &runtime::Handle,
config: MockExecutionConfig,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
let MockExecutionConfig {
@@ -152,6 +154,7 @@ impl<E: EthSpec> MockServer<E> {
cancun_time,
prague_time,
osaka_time,
spec,
kzg,
);
@@ -216,6 +219,7 @@ impl<E: EthSpec> MockServer<E> {
cancun_time: Option<u64>,
prague_time: Option<u64>,
osaka_time: Option<u64>,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
Self::new_with_config(
@@ -231,6 +235,7 @@ impl<E: EthSpec> MockServer<E> {
prague_time,
osaka_time,
},
spec,
kzg,
)
}