feat: use new engine in e2e tests for OP (#13558)

This commit is contained in:
Arsenii Kulikov
2024-12-27 15:00:21 +04:00
committed by GitHub
parent 0933e1b07d
commit 6049b6eb0a
2 changed files with 18 additions and 23 deletions

View File

@ -2,21 +2,26 @@ use crate::{OpBuiltPayload, OpNode as OtherOpNode, OpPayloadBuilderAttributes};
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_primitives::{Address, B256}; use alloy_primitives::{Address, B256};
use alloy_rpc_types_engine::PayloadAttributes; use alloy_rpc_types_engine::PayloadAttributes;
use reth_e2e_test_utils::{transaction::TransactionTestContext, wallet::Wallet, NodeHelperType}; use reth_e2e_test_utils::{
transaction::TransactionTestContext, wallet::Wallet, NodeHelperType, TmpDB,
};
use reth_node_api::NodeTypesWithDBAdapter;
use reth_optimism_chainspec::OpChainSpecBuilder; use reth_optimism_chainspec::OpChainSpecBuilder;
use reth_payload_builder::EthPayloadBuilderAttributes; use reth_payload_builder::EthPayloadBuilderAttributes;
use reth_provider::providers::BlockchainProvider2;
use reth_tasks::TaskManager; use reth_tasks::TaskManager;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;
/// Optimism Node Helper type /// Optimism Node Helper type
pub(crate) type OpNode = NodeHelperType<OtherOpNode>; pub(crate) type OpNode =
NodeHelperType<OtherOpNode, BlockchainProvider2<NodeTypesWithDBAdapter<OtherOpNode, TmpDB>>>;
/// Creates the initial setup with `num_nodes` of the node config, started and connected. /// Creates the initial setup with `num_nodes` of the node config, started and connected.
pub async fn setup(num_nodes: usize) -> eyre::Result<(Vec<OpNode>, TaskManager, Wallet)> { pub async fn setup(num_nodes: usize) -> eyre::Result<(Vec<OpNode>, TaskManager, Wallet)> {
let genesis: Genesis = let genesis: Genesis =
serde_json::from_str(include_str!("../tests/assets/genesis.json")).unwrap(); serde_json::from_str(include_str!("../tests/assets/genesis.json")).unwrap();
reth_e2e_test_utils::setup( reth_e2e_test_utils::setup_engine(
num_nodes, num_nodes,
Arc::new(OpChainSpecBuilder::base_mainnet().genesis(genesis).ecotone_activated().build()), Arc::new(OpChainSpecBuilder::base_mainnet().genesis(genesis).ecotone_activated().build()),
false, false,

View File

@ -43,13 +43,19 @@ async fn can_sync() -> eyre::Result<()> {
.update_optimistic_forkchoice(canonical_chain[tip_index - reorg_depth]) .update_optimistic_forkchoice(canonical_chain[tip_index - reorg_depth])
.await?; .await?;
second_node second_node
.wait_block((tip - reorg_depth) as u64, canonical_chain[tip_index - reorg_depth], true) .wait_block((tip - reorg_depth) as u64, canonical_chain[tip_index - reorg_depth], false)
.await?; .await?;
second_node.engine_api.canonical_stream.next().await.unwrap(); second_node.engine_api.canonical_stream.next().await.unwrap();
// On third node, sync optimistically up to block number 90a // Trigger backfil sync until block 80
third_node
.engine_api
.update_forkchoice(canonical_chain[tip_index - 10], canonical_chain[tip_index - 10])
.await?;
third_node.wait_block((tip - 10) as u64, canonical_chain[tip_index - 10], true).await?;
// Trigger live sync to block 90
third_node.engine_api.update_optimistic_forkchoice(canonical_chain[tip_index]).await?; third_node.engine_api.update_optimistic_forkchoice(canonical_chain[tip_index]).await?;
third_node.wait_block(tip as u64, canonical_chain[tip_index], true).await?; third_node.wait_block(tip as u64, canonical_chain[tip_index], false).await?;
// On second node, create a side chain: 88a -> 89b -> 90b // On second node, create a side chain: 88a -> 89b -> 90b
wallet.lock().await.inner_nonce -= reorg_depth as u64; wallet.lock().await.inner_nonce -= reorg_depth as u64;
@ -77,25 +83,9 @@ async fn can_sync() -> eyre::Result<()> {
.wait_block( .wait_block(
side_payload_chain[0].0.block().number, side_payload_chain[0].0.block().number,
side_payload_chain[0].0.block().hash(), side_payload_chain[0].0.block().hash(),
true, false,
) )
.await?; .await?;
// Make sure that trying to submit 89a again will result in an invalid payload status, since 89b
// has been set as finalized.
let _ = third_node
.engine_api
.submit_payload(
canonical_payload_chain[tip_index - reorg_depth + 1].0.clone(),
canonical_payload_chain[tip_index - reorg_depth + 1].1.clone(),
PayloadStatusEnum::Invalid {
validation_error: format!(
"block number is lower than the last finalized block number {}",
(tip - reorg_depth) as u64 + 1
),
},
)
.await;
Ok(()) Ok(())
} }