From 5a779c09b7952ee65f35e162eb2fd96413da9af9 Mon Sep 17 00:00:00 2001 From: Ankit Date: Wed, 18 Oct 2023 17:26:12 +0100 Subject: [PATCH] bring the repo upto date with reth upstream changes --- Cargo.toml | 2 +- src/cli_ext.rs | 39 +++++++++------------------------------ src/rpc/types.rs | 32 ++++++++++++++------------------ 3 files changed, 24 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f856fc7..c87af64 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,6 @@ clap = "4.4.5" derivative = "2.2.0" eyre = "0.6.8" jsonrpsee = "0.20.1" -reth = { git = "https://github.com/ultrasoundmoney/reth-block-validator", branch = "changes-to-enable-validation-api-extension" } +reth = { git = "https://github.com/paradigmxyz/reth.git", rev = "1cccd09" } serde = "1.0.188" serde-this-or-that = "0.4.2" diff --git a/src/cli_ext.rs b/src/cli_ext.rs index 6082d96..3abdc9a 100644 --- a/src/cli_ext.rs +++ b/src/cli_ext.rs @@ -1,17 +1,8 @@ -use reth::{ - cli::{ +use reth::cli::{ config::RethRpcConfig, ext::{RethCliExt, RethNodeCommandConfig}, - }, - network::{NetworkInfo, Peers}, - providers::{ - AccountReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider, - ChangeSetReader, EvmEnvProvider, StateProviderFactory, - }, - rpc::builder::{RethModuleRegistry, TransportRpcModules}, - tasks::TaskSpawner, - transaction_pool::TransactionPool, -}; + components::{RethNodeComponents, RethRpcComponents}, + }; use crate::rpc::ValidationApiServer; use crate::ValidationApi; @@ -34,38 +25,26 @@ pub struct RethCliValidationApi { impl RethNodeCommandConfig for RethCliValidationApi { // This is the entrypoint for the CLI to extend the RPC server with custom rpc namespaces. - fn extend_rpc_modules( + fn extend_rpc_modules( &mut self, _config: &Conf, - registry: &mut RethModuleRegistry, - modules: &mut TransportRpcModules, + _components: &Reth, + rpc_components: RethRpcComponents<'_, Reth>, ) -> eyre::Result<()> where Conf: RethRpcConfig, - Provider: BlockReaderIdExt - + AccountReader - + StateProviderFactory - + EvmEnvProvider - + ChainSpecProvider - + ChangeSetReader - + Clone - + Unpin - + 'static, - Pool: TransactionPool + Clone + 'static, - Network: NetworkInfo + Peers + Clone + 'static, - Tasks: TaskSpawner + Clone + 'static, - Events: CanonStateSubscriptions + Clone + 'static, + Reth: RethNodeComponents, { if !self.enable_ext { return Ok(()); } // here we get the configured pool type from the CLI. - let provider = registry.provider().clone(); + let provider = rpc_components.registry.provider().clone(); let ext = ValidationApi::new(provider); // now we merge our extension namespace into all configured transports - modules.merge_configured(ext.into_rpc())?; + rpc_components.modules.merge_configured(ext.into_rpc())?; println!("validation extension enabled"); Ok(()) diff --git a/src/rpc/types.rs b/src/rpc/types.rs index 4fa4539..1a7509a 100644 --- a/src/rpc/types.rs +++ b/src/rpc/types.rs @@ -1,5 +1,5 @@ use derivative::Derivative; -use reth::primitives::{Address, Bloom, Bytes, H256, U256}; +use reth::primitives::{Address, Bloom, Bytes, B256, U256, U64}; use reth::rpc::types::{ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, Withdrawal}; use serde::{Deserialize, Serialize}; use serde_this_or_that::as_u64; @@ -11,23 +11,19 @@ use serde_this_or_that::as_u64; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] #[allow(missing_docs)] pub struct ExecutionPayloadValidation { - pub parent_hash: H256, + pub parent_hash: B256, pub fee_recipient: Address, - pub state_root: H256, - pub receipts_root: H256, + pub state_root: B256, + pub receipts_root: B256, pub logs_bloom: Bloom, - pub prev_randao: H256, - #[serde(deserialize_with = "as_u64")] - pub block_number: u64, - #[serde(deserialize_with = "as_u64")] - pub gas_limit: u64, - #[serde(deserialize_with = "as_u64")] - pub gas_used: u64, - #[serde(deserialize_with = "as_u64")] - pub timestamp: u64, + pub prev_randao: B256, + pub block_number: U64, + pub gas_limit: U64, + pub gas_used: U64, + pub timestamp: U64, pub extra_data: Bytes, pub base_fee_per_gas: U256, - pub block_hash: H256, + pub block_hash: B256, #[derivative(Debug = "ignore")] pub transactions: Vec, pub withdrawals: Vec, @@ -59,10 +55,10 @@ impl From for ExecutionPayload { receipts_root: val.receipts_root, logs_bloom: val.logs_bloom, prev_randao: val.prev_randao, - block_number: val.block_number.into(), - gas_limit: val.gas_limit.into(), - gas_used: val.gas_used.into(), - timestamp: val.timestamp.into(), + block_number: val.block_number, + gas_limit: val.gas_limit, + gas_used: val.gas_used, + timestamp: val.timestamp, extra_data: val.extra_data, base_fee_per_gas: val.base_fee_per_gas, block_hash: val.block_hash,