Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upto date with reth upstream changes #10

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the other pr (#8) I also changed to using the reth repo directly, without fixing the commit hash.

Looking at the frequency of breaking api changes on the reth side, it might be better though to go with the fixed commit as you did here.

serde = "1.0.188"
serde-this-or-that = "0.4.2"
39 changes: 9 additions & 30 deletions src/cli_ext.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Conf, Provider, Pool, Network, Tasks, Events>(
fn extend_rpc_modules<Conf, Reth>(
&mut self,
_config: &Conf,
registry: &mut RethModuleRegistry<Provider, Pool, Network, Tasks, Events>,
modules: &mut TransportRpcModules,
_components: &Reth,
rpc_components: RethRpcComponents<'_, Reth>,
) -> eyre::Result<()>
where
Conf: RethRpcConfig,
Provider: BlockReaderIdExt
+ AccountReader
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIce, this does remove a lot of verbose type noise. Good stuff 👍

+ 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(())
Expand Down
32 changes: 14 additions & 18 deletions src/rpc/types.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Copy link
Collaborator

@ckoopmann ckoopmann Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why we had the custom serialization above is because we are currently still aiming to be consistent with the current flashbots builder api. (See: #8)

In their api, numbers are encoded as decimal strings whereas the default deserialization of reth U64 type is hex. Therefore these changes would break the api.

I suggest removing these changes and limiting the PR to only what is necessary to make it compatible with the updated reth dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this referes to the u64 fields only. The change from H256 to B256 is fine imo.

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<Bytes>,
pub withdrawals: Vec<WithdrawalValidation>,
Expand Down Expand Up @@ -59,10 +55,10 @@ impl From<ExecutionPayloadValidation> 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,
Expand Down
Loading