-
Notifications
You must be signed in to change notification settings - Fork 11
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(()) | ||
|
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; | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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>, | ||
|
@@ -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, | ||
|
There was a problem hiding this comment.
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.