mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-01 10:35:05 -05:00
52 lines
1.9 KiB
Rust
52 lines
1.9 KiB
Rust
use reth::{primitives::Bytes, rpc::types::engine::PayloadAttributes, tasks::TaskManager};
|
|
use reth_e2e_test_utils::{wallet::Wallet, NodeHelperType};
|
|
use reth_node_optimism::{OptimismBuiltPayload, OptimismNode, OptimismPayloadBuilderAttributes};
|
|
use reth_payload_builder::EthPayloadBuilderAttributes;
|
|
use reth_primitives::{Address, ChainSpecBuilder, Genesis, B256, BASE_MAINNET};
|
|
use std::{future::Future, pin::Pin, sync::Arc};
|
|
|
|
/// Optimism Node Helper type
|
|
pub(crate) type OpNode = NodeHelperType<OptimismNode>;
|
|
|
|
pub(crate) async fn setup(num_nodes: usize) -> eyre::Result<(Vec<OpNode>, TaskManager, Wallet)> {
|
|
let genesis: Genesis = serde_json::from_str(include_str!("../assets/genesis.json")).unwrap();
|
|
reth_e2e_test_utils::setup(
|
|
num_nodes,
|
|
Arc::new(
|
|
ChainSpecBuilder::default()
|
|
.chain(BASE_MAINNET.chain)
|
|
.genesis(genesis)
|
|
.ecotone_activated()
|
|
.build(),
|
|
),
|
|
false,
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub(crate) async fn advance_chain(
|
|
length: usize,
|
|
node: &mut OpNode,
|
|
tx_generator: impl Fn(u64) -> Pin<Box<dyn Future<Output = Bytes>>>,
|
|
) -> eyre::Result<Vec<(OptimismBuiltPayload, OptimismPayloadBuilderAttributes)>> {
|
|
node.advance(length as u64, tx_generator, optimism_payload_attributes).await
|
|
}
|
|
|
|
/// Helper function to create a new eth payload attributes
|
|
pub(crate) fn optimism_payload_attributes(timestamp: u64) -> OptimismPayloadBuilderAttributes {
|
|
let attributes = PayloadAttributes {
|
|
timestamp,
|
|
prev_randao: B256::ZERO,
|
|
suggested_fee_recipient: Address::ZERO,
|
|
withdrawals: Some(vec![]),
|
|
parent_beacon_block_root: Some(B256::ZERO),
|
|
};
|
|
|
|
OptimismPayloadBuilderAttributes {
|
|
payload_attributes: EthPayloadBuilderAttributes::new(B256::ZERO, attributes),
|
|
transactions: vec![],
|
|
no_tx_pool: false,
|
|
gas_limit: Some(30_000_000),
|
|
}
|
|
}
|