resolve merge conflicts

This commit is contained in:
Eitan Seri-Levi
2025-01-07 13:57:22 +07:00
49 changed files with 545 additions and 261 deletions

View File

@@ -1321,7 +1321,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

@@ -153,6 +153,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>> {
@@ -162,6 +163,7 @@ fn make_rng() -> Arc<Mutex<StdRng>> {
}
impl<E: EthSpec> ExecutionBlockGenerator<E> {
#[allow(clippy::too_many_arguments)]
pub fn new(
terminal_total_difficulty: Uint256,
terminal_block_number: u64,
@@ -169,6 +171,7 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
shanghai_time: Option<u64>,
cancun_time: Option<u64>,
prague_time: Option<u64>,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
let mut gen = Self {
@@ -188,6 +191,7 @@ impl<E: EthSpec> ExecutionBlockGenerator<E> {
blobs_bundles: <_>::default(),
kzg,
rng: make_rng(),
spec,
};
gen.insert_pow_block(0).unwrap();
@@ -671,7 +675,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
@@ -874,6 +882,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),
@@ -882,6 +891,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> {
@@ -29,7 +29,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
None,
None,
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
spec,
Arc::new(spec),
None,
)
}
@@ -42,7 +42,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
cancun_time: Option<u64>,
prague_time: Option<u64>,
jwt_key: Option<JwtKey>,
spec: ChainSpec,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
let handle = executor.handle().unwrap();
@@ -57,6 +57,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
shanghai_time,
cancun_time,
prague_time,
spec.clone(),
kzg,
);
@@ -320,7 +321,7 @@ impl<E: EthSpec> MockExecutionLayer<E> {
pub async fn with_terminal_block<'a, 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;
@@ -107,7 +107,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(),
@@ -117,6 +117,7 @@ impl<E: EthSpec> MockServer<E> {
None, // FIXME(capella): should this be the default?
None, // FIXME(deneb): should this be the default?
None, // FIXME(electra): should this be the default?
chain_spec,
None,
)
}
@@ -124,6 +125,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 {
@@ -145,6 +147,7 @@ impl<E: EthSpec> MockServer<E> {
shanghai_time,
cancun_time,
prague_time,
spec,
kzg,
);
@@ -208,6 +211,7 @@ impl<E: EthSpec> MockServer<E> {
shanghai_time: Option<u64>,
cancun_time: Option<u64>,
prague_time: Option<u64>,
spec: Arc<ChainSpec>,
kzg: Option<Arc<Kzg>>,
) -> Self {
Self::new_with_config(
@@ -222,6 +226,7 @@ impl<E: EthSpec> MockServer<E> {
cancun_time,
prague_time,
},
spec,
kzg,
)
}