chore: make op-node-testing- leaner (#12958)

This commit is contained in:
Matthias Seitz
2024-11-28 13:48:36 +01:00
committed by GitHub
parent c274462059
commit 1d5bd46594
13 changed files with 99 additions and 94 deletions

11
Cargo.lock generated
View File

@ -7106,21 +7106,27 @@ dependencies = [
"futures-util", "futures-util",
"jsonrpsee", "jsonrpsee",
"op-alloy-rpc-types-engine", "op-alloy-rpc-types-engine",
"reth",
"reth-chainspec", "reth-chainspec",
"reth-db", "reth-db",
"reth-engine-local", "reth-engine-local",
"reth-network",
"reth-network-api",
"reth-network-peers", "reth-network-peers",
"reth-node-api", "reth-node-api",
"reth-node-builder", "reth-node-builder",
"reth-node-core",
"reth-optimism-primitives", "reth-optimism-primitives",
"reth-payload-builder", "reth-payload-builder",
"reth-payload-builder-primitives", "reth-payload-builder-primitives",
"reth-payload-primitives", "reth-payload-primitives",
"reth-primitives", "reth-primitives",
"reth-provider", "reth-provider",
"reth-rpc-api",
"reth-rpc-eth-api",
"reth-rpc-layer", "reth-rpc-layer",
"reth-rpc-server-types",
"reth-stages-types", "reth-stages-types",
"reth-tasks",
"reth-tokio-util", "reth-tokio-util",
"reth-tracing", "reth-tracing",
"serde_json", "serde_json",
@ -8335,7 +8341,6 @@ dependencies = [
"op-alloy-consensus", "op-alloy-consensus",
"op-alloy-rpc-types-engine", "op-alloy-rpc-types-engine",
"parking_lot", "parking_lot",
"reth",
"reth-basic-payload-builder", "reth-basic-payload-builder",
"reth-beacon-consensus", "reth-beacon-consensus",
"reth-chainspec", "reth-chainspec",
@ -8347,6 +8352,7 @@ dependencies = [
"reth-network", "reth-network",
"reth-node-api", "reth-node-api",
"reth-node-builder", "reth-node-builder",
"reth-node-core",
"reth-optimism-chainspec", "reth-optimism-chainspec",
"reth-optimism-consensus", "reth-optimism-consensus",
"reth-optimism-evm", "reth-optimism-evm",
@ -8362,6 +8368,7 @@ dependencies = [
"reth-provider", "reth-provider",
"reth-revm", "reth-revm",
"reth-rpc-server-types", "reth-rpc-server-types",
"reth-tasks",
"reth-tracing", "reth-tracing",
"reth-transaction-pool", "reth-transaction-pool",
"reth-trie-db", "reth-trie-db",

View File

@ -11,22 +11,28 @@ repository.workspace = true
workspace = true workspace = true
[dependencies] [dependencies]
reth.workspace = true
reth-chainspec.workspace = true reth-chainspec.workspace = true
reth-tracing.workspace = true reth-tracing.workspace = true
reth-db = { workspace = true, features = ["test-utils"] } reth-db = { workspace = true, features = ["test-utils"] }
reth-rpc-layer.workspace = true reth-rpc-layer.workspace = true
reth-rpc-server-types.workspace = true
reth-rpc-eth-api.workspace = true
reth-rpc-api = { workspace = true, features = ["client"] }
reth-payload-builder = { workspace = true, features = ["test-utils"] } reth-payload-builder = { workspace = true, features = ["test-utils"] }
reth-payload-builder-primitives.workspace = true reth-payload-builder-primitives.workspace = true
reth-payload-primitives.workspace = true reth-payload-primitives.workspace = true
reth-primitives.workspace = true reth-primitives.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-network-api.workspace = true
reth-network.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-node-core.workspace = true
reth-node-builder = { workspace = true, features = ["test-utils"] } reth-node-builder = { workspace = true, features = ["test-utils"] }
reth-tokio-util.workspace = true reth-tokio-util.workspace = true
reth-stages-types.workspace = true reth-stages-types.workspace = true
reth-network-peers.workspace = true reth-network-peers.workspace = true
reth-engine-local.workspace = true reth-engine-local.workspace = true
reth-tasks.workspace = true
# currently need to enable this for workspace level # currently need to enable this for workspace level
reth-optimism-primitives = { workspace = true, features = ["arbitrary"] } reth-optimism-primitives = { workspace = true, features = ["arbitrary"] }

View File

@ -1,20 +1,17 @@
use crate::traits::PayloadEnvelopeExt; use crate::traits::PayloadEnvelopeExt;
use alloy_primitives::B256; use alloy_primitives::B256;
use alloy_rpc_types_engine::{ForkchoiceState, PayloadStatusEnum};
use jsonrpsee::{ use jsonrpsee::{
core::client::ClientT, core::client::ClientT,
http_client::{transport::HttpBackend, HttpClient}, http_client::{transport::HttpBackend, HttpClient},
}; };
use reth::{
api::{EngineTypes, PayloadBuilderAttributes},
providers::CanonStateNotificationStream,
rpc::{
api::EngineApiClient,
types::engine::{ForkchoiceState, PayloadStatusEnum},
},
};
use reth_chainspec::EthereumHardforks; use reth_chainspec::EthereumHardforks;
use reth_node_api::EngineTypes;
use reth_node_builder::BuiltPayload; use reth_node_builder::BuiltPayload;
use reth_payload_builder::PayloadId; use reth_payload_builder::PayloadId;
use reth_payload_primitives::PayloadBuilderAttributes;
use reth_provider::CanonStateNotificationStream;
use reth_rpc_api::EngineApiClient;
use reth_rpc_layer::AuthClientService; use reth_rpc_layer::AuthClientService;
use std::{marker::PhantomData, sync::Arc}; use std::{marker::PhantomData, sync::Arc};
@ -83,7 +80,7 @@ impl<E: EngineTypes, ChainSpec: EthereumHardforks> EngineApiTestContext<E, Chain
.await? .await?
}; };
assert_eq!(submission.status, expected_status); assert_eq!(submission.status.as_str(), expected_status.as_str());
Ok(submission.latest_valid_hash.unwrap_or_default()) Ok(submission.latest_valid_hash.unwrap_or_default())
} }

View File

@ -1,27 +1,25 @@
//! Utilities for end-to-end tests. //! Utilities for end-to-end tests.
use std::sync::Arc;
use node::NodeTestContext; use node::NodeTestContext;
use reth::{
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs},
blockchain_tree::externals::NodeTypesForTree,
builder::{NodeBuilder, NodeConfig, NodeHandle},
network::PeersHandleProvider,
primitives::EthPrimitives,
rpc::server_types::RpcModuleSelection,
tasks::TaskManager,
};
use reth_chainspec::EthChainSpec; use reth_chainspec::EthChainSpec;
use reth_db::{test_utils::TempDatabase, DatabaseEnv}; use reth_db::{test_utils::TempDatabase, DatabaseEnv};
use reth_engine_local::LocalPayloadAttributesBuilder; use reth_engine_local::LocalPayloadAttributesBuilder;
use reth_network_api::test_utils::PeersHandleProvider;
use reth_node_builder::{ use reth_node_builder::{
components::NodeComponentsBuilder, components::NodeComponentsBuilder,
rpc::{EngineValidatorAddOn, RethRpcAddOns}, rpc::{EngineValidatorAddOn, RethRpcAddOns},
EngineNodeLauncher, FullNodeTypesAdapter, Node, NodeAdapter, NodeComponents, EngineNodeLauncher, FullNodeTypesAdapter, Node, NodeAdapter, NodeBuilder, NodeComponents,
NodeTypesWithDBAdapter, NodeTypesWithEngine, PayloadAttributesBuilder, PayloadTypes, NodeConfig, NodeHandle, NodeTypesWithDBAdapter, NodeTypesWithEngine, PayloadAttributesBuilder,
PayloadTypes,
}; };
use reth_provider::providers::{BlockchainProvider, BlockchainProvider2, NodeTypesForProvider}; use reth_node_core::args::{DiscoveryArgs, NetworkArgs, RpcServerArgs};
use reth_primitives::EthPrimitives;
use reth_provider::providers::{
BlockchainProvider, BlockchainProvider2, NodeTypesForProvider, NodeTypesForTree,
};
use reth_rpc_server_types::RpcModuleSelection;
use reth_tasks::TaskManager;
use std::sync::Arc;
use tracing::{span, Level}; use tracing::{span, Level};
use wallet::Wallet; use wallet::Wallet;

View File

@ -1,5 +1,7 @@
use futures_util::StreamExt; use futures_util::StreamExt;
use reth::network::{NetworkEvent, NetworkEventListenerProvider, PeersHandleProvider, PeersInfo}; use reth_network_api::{
test_utils::PeersHandleProvider, NetworkEvent, NetworkEventListenerProvider, PeersInfo,
};
use reth_network_peers::{NodeRecord, PeerId}; use reth_network_peers::{NodeRecord, PeerId};
use reth_tokio_util::EventStream; use reth_tokio_util::EventStream;
use reth_tracing::tracing::info; use reth_tracing::tracing::info;

View File

@ -1,32 +1,27 @@
use std::{marker::PhantomData, pin::Pin};
use alloy_consensus::BlockHeader;
use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256};
use alloy_rpc_types_eth::BlockNumberOrTag;
use eyre::Ok;
use futures_util::Future;
use reth::{
api::{BuiltPayload, EngineTypes, FullNodeComponents, PayloadBuilderAttributes},
builder::FullNode,
network::PeersHandleProvider,
providers::{BlockReader, BlockReaderIdExt, CanonStateSubscriptions, StageCheckpointReader},
rpc::{
api::eth::helpers::{EthApiSpec, EthTransactions, TraceExt},
types::engine::PayloadStatusEnum,
},
};
use reth_chainspec::EthereumHardforks;
use reth_node_api::Block;
use reth_node_builder::{rpc::RethRpcAddOns, NodeTypes, NodeTypesWithEngine};
use reth_primitives::EthPrimitives;
use reth_stages_types::StageId;
use tokio_stream::StreamExt;
use url::Url;
use crate::{ use crate::{
engine_api::EngineApiTestContext, network::NetworkTestContext, payload::PayloadTestContext, engine_api::EngineApiTestContext, network::NetworkTestContext, payload::PayloadTestContext,
rpc::RpcTestContext, traits::PayloadEnvelopeExt, rpc::RpcTestContext, traits::PayloadEnvelopeExt,
}; };
use alloy_consensus::BlockHeader;
use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256};
use alloy_rpc_types_engine::PayloadStatusEnum;
use alloy_rpc_types_eth::BlockNumberOrTag;
use eyre::Ok;
use futures_util::Future;
use reth_chainspec::EthereumHardforks;
use reth_network_api::test_utils::PeersHandleProvider;
use reth_node_api::{Block, EngineTypes, FullNodeComponents};
use reth_node_builder::{rpc::RethRpcAddOns, FullNode, NodeTypes, NodeTypesWithEngine};
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
use reth_primitives::EthPrimitives;
use reth_provider::{
BlockReader, BlockReaderIdExt, CanonStateSubscriptions, StageCheckpointReader,
};
use reth_rpc_eth_api::helpers::{EthApiSpec, EthTransactions, TraceExt};
use reth_stages_types::StageId;
use std::{marker::PhantomData, pin::Pin};
use tokio_stream::StreamExt;
use url::Url;
/// An helper struct to handle node actions /// An helper struct to handle node actions
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]

View File

@ -1,8 +1,7 @@
use futures_util::StreamExt; use futures_util::StreamExt;
use reth::api::BuiltPayload;
use reth_payload_builder::{PayloadBuilderHandle, PayloadId}; use reth_payload_builder::{PayloadBuilderHandle, PayloadId};
use reth_payload_builder_primitives::{Events, PayloadBuilder}; use reth_payload_builder_primitives::{Events, PayloadBuilder};
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadTypes}; use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes, PayloadTypes};
use tokio_stream::wrappers::BroadcastStream; use tokio_stream::wrappers::BroadcastStream;
/// Helper for payload operations /// Helper for payload operations

View File

@ -2,19 +2,14 @@ use alloy_consensus::TxEnvelope;
use alloy_network::eip2718::Decodable2718; use alloy_network::eip2718::Decodable2718;
use alloy_primitives::{Bytes, B256}; use alloy_primitives::{Bytes, B256};
use alloy_rlp::Encodable; use alloy_rlp::Encodable;
use reth::{
builder::{rpc::RpcRegistry, FullNodeComponents},
rpc::api::{
eth::{
helpers::{EthApiSpec, EthTransactions, TraceExt},
EthApiTypes,
},
DebugApiServer,
},
};
use reth_chainspec::EthereumHardforks; use reth_chainspec::EthereumHardforks;
use reth_node_api::NodePrimitives; use reth_node_api::{FullNodeComponents, NodePrimitives};
use reth_node_builder::NodeTypes; use reth_node_builder::{rpc::RpcRegistry, NodeTypes};
use reth_rpc_api::DebugApiServer;
use reth_rpc_eth_api::{
helpers::{EthApiSpec, EthTransactions, TraceExt},
EthApiTypes,
};
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> { pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {

View File

@ -1,6 +1,7 @@
use alloy_rpc_types_engine::ExecutionPayloadEnvelopeV4; use alloy_rpc_types_engine::{
ExecutionPayloadEnvelopeV3, ExecutionPayloadEnvelopeV4, ExecutionPayloadV3,
};
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4}; use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
use reth::rpc::types::engine::{ExecutionPayloadEnvelopeV3, ExecutionPayloadV3};
/// The execution payload envelope type. /// The execution payload envelope type.
pub trait PayloadEnvelopeExt: Send + Sync + std::fmt::Debug { pub trait PayloadEnvelopeExt: Send + Sync + std::fmt::Debug {

View File

@ -32,6 +32,7 @@ reth-revm = { workspace = true, features = ["std"] }
reth-beacon-consensus.workspace = true reth-beacon-consensus.workspace = true
reth-trie-db.workspace = true reth-trie-db.workspace = true
reth-rpc-server-types.workspace = true reth-rpc-server-types.workspace = true
reth-tasks = { workspace = true, optional = true }
# op-reth # op-reth
reth-optimism-payload-builder.workspace = true reth-optimism-payload-builder.workspace = true
@ -62,7 +63,6 @@ parking_lot.workspace = true
serde_json.workspace = true serde_json.workspace = true
# test-utils dependencies # test-utils dependencies
reth = { workspace = true, optional = true }
reth-e2e-test-utils = { workspace = true, optional = true } reth-e2e-test-utils = { workspace = true, optional = true }
alloy-genesis = { workspace = true, optional = true } alloy-genesis = { workspace = true, optional = true }
tokio = { workspace = true, optional = true } tokio = { workspace = true, optional = true }
@ -70,9 +70,12 @@ tokio = { workspace = true, optional = true }
[dev-dependencies] [dev-dependencies]
reth-optimism-node = { workspace = true, features = ["test-utils"] } reth-optimism-node = { workspace = true, features = ["test-utils"] }
reth-db.workspace = true reth-db.workspace = true
reth-node-core.workspace = true
reth-node-builder = { workspace = true, features = ["test-utils"] } reth-node-builder = { workspace = true, features = ["test-utils"] }
reth-provider = { workspace = true, features = ["test-utils"] } reth-provider = { workspace = true, features = ["test-utils"] }
reth-revm = { workspace = true, features = ["test-utils"] } reth-revm = { workspace = true, features = ["test-utils"] }
reth-tasks.workspace = true
alloy-primitives.workspace = true alloy-primitives.workspace = true
op-alloy-consensus.workspace = true op-alloy-consensus.workspace = true
alloy-signer-local.workspace = true alloy-signer-local.workspace = true
@ -82,27 +85,28 @@ futures.workspace = true
[features] [features]
optimism = [ optimism = [
"reth-primitives/optimism", "reth-primitives/optimism",
"reth-provider/optimism", "reth-provider/optimism",
"reth-optimism-evm/optimism", "reth-optimism-evm/optimism",
"reth-optimism-payload-builder/optimism", "reth-optimism-payload-builder/optimism",
"reth-beacon-consensus/optimism", "reth-beacon-consensus/optimism",
"revm/optimism", "revm/optimism",
"reth-optimism-rpc/optimism", "reth-optimism-rpc/optimism",
"reth-engine-local/optimism", "reth-engine-local/optimism",
"reth-optimism-consensus/optimism", "reth-optimism-consensus/optimism",
"reth-db/optimism", "reth-db/optimism",
"reth-optimism-node/optimism", "reth-optimism-node/optimism",
"reth-node-core/optimism"
] ]
asm-keccak = [ asm-keccak = [
"reth-primitives/asm-keccak", "reth-primitives/asm-keccak",
"reth/asm-keccak", "alloy-primitives/asm-keccak",
"alloy-primitives/asm-keccak", "revm/asm-keccak",
"revm/asm-keccak", "reth-optimism-node/asm-keccak",
"reth-optimism-node/asm-keccak", "reth-node-core/asm-keccak"
] ]
test-utils = [ test-utils = [
"reth", "reth-tasks",
"reth-e2e-test-utils", "reth-e2e-test-utils",
"alloy-genesis", "alloy-genesis",
"tokio", "tokio",

View File

@ -1,12 +1,13 @@
use crate::{node::OpAddOns, OpBuiltPayload, OpNode as OtherOpNode, OpPayloadBuilderAttributes}; use crate::{node::OpAddOns, OpBuiltPayload, OpNode as OtherOpNode, OpPayloadBuilderAttributes};
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_primitives::{Address, B256}; use alloy_primitives::{Address, B256};
use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager}; use alloy_rpc_types_engine::PayloadAttributes;
use reth_e2e_test_utils::{ use reth_e2e_test_utils::{
transaction::TransactionTestContext, wallet::Wallet, Adapter, NodeHelperType, transaction::TransactionTestContext, wallet::Wallet, Adapter, NodeHelperType,
}; };
use reth_optimism_chainspec::OpChainSpecBuilder; use reth_optimism_chainspec::OpChainSpecBuilder;
use reth_payload_builder::EthPayloadBuilderAttributes; use reth_payload_builder::EthPayloadBuilderAttributes;
use reth_tasks::TaskManager;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;

View File

@ -1,6 +1,5 @@
use alloy_rpc_types_engine::PayloadStatusEnum; use alloy_rpc_types_engine::PayloadStatusEnum;
use futures::StreamExt; use futures::StreamExt;
use reth::blockchain_tree::error::BlockchainTreeError;
use reth_optimism_node::utils::{advance_chain, setup}; use reth_optimism_node::utils::{advance_chain, setup};
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;
@ -90,10 +89,10 @@ async fn can_sync() -> eyre::Result<()> {
canonical_payload_chain[tip_index - reorg_depth + 1].0.clone(), canonical_payload_chain[tip_index - reorg_depth + 1].0.clone(),
canonical_payload_chain[tip_index - reorg_depth + 1].1.clone(), canonical_payload_chain[tip_index - reorg_depth + 1].1.clone(),
PayloadStatusEnum::Invalid { PayloadStatusEnum::Invalid {
validation_error: BlockchainTreeError::PendingBlockIsFinalized { validation_error: format!(
last_finalized: (tip - reorg_depth) as u64 + 1, "block number is lower than the last finalized block number {}",
} (tip - reorg_depth) as u64 + 1
.to_string(), ),
}, },
) )
.await; .await;

View File

@ -4,7 +4,6 @@ use alloy_consensus::TxEip1559;
use alloy_genesis::Genesis; use alloy_genesis::Genesis;
use alloy_network::TxSignerSync; use alloy_network::TxSignerSync;
use alloy_primitives::{Address, ChainId, TxKind}; use alloy_primitives::{Address, ChainId, TxKind};
use reth::{args::DatadirArgs, tasks::TaskManager};
use reth_chainspec::EthChainSpec; use reth_chainspec::EthChainSpec;
use reth_db::test_utils::create_test_rw_db_with_path; use reth_db::test_utils::create_test_rw_db_with_path;
use reth_e2e_test_utils::{ use reth_e2e_test_utils::{
@ -14,6 +13,7 @@ use reth_node_api::{FullNodeTypes, NodeTypesWithEngine};
use reth_node_builder::{ use reth_node_builder::{
components::ComponentsBuilder, EngineNodeLauncher, NodeBuilder, NodeConfig, components::ComponentsBuilder, EngineNodeLauncher, NodeBuilder, NodeConfig,
}; };
use reth_node_core::args::DatadirArgs;
use reth_optimism_chainspec::{OpChainSpec, OpChainSpecBuilder}; use reth_optimism_chainspec::{OpChainSpec, OpChainSpecBuilder};
use reth_optimism_node::{ use reth_optimism_node::{
args::RollupArgs, args::RollupArgs,
@ -29,6 +29,7 @@ use reth_optimism_primitives::OpPrimitives;
use reth_payload_util::{PayloadTransactions, PayloadTransactionsChain, PayloadTransactionsFixed}; use reth_payload_util::{PayloadTransactions, PayloadTransactionsChain, PayloadTransactionsFixed};
use reth_primitives::{SealedBlock, Transaction, TransactionSigned, TransactionSignedEcRecovered}; use reth_primitives::{SealedBlock, Transaction, TransactionSigned, TransactionSignedEcRecovered};
use reth_provider::providers::BlockchainProvider2; use reth_provider::providers::BlockchainProvider2;
use reth_tasks::TaskManager;
use reth_transaction_pool::pool::BestPayloadTransactions; use reth_transaction_pool::pool::BestPayloadTransactions;
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;