chore(deps): bump alloy (#10537)

Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
Arsenii Kulikov
2024-08-29 17:23:04 +04:00
committed by GitHub
parent 019ec727a2
commit ec5ce21965
50 changed files with 530 additions and 580 deletions

530
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -395,59 +395,60 @@ reth-trie-db = { path = "crates/trie/db" }
reth-trie-parallel = { path = "crates/trie/parallel" } reth-trie-parallel = { path = "crates/trie/parallel" }
# revm # revm
revm = { version = "13.0.0", features = [ revm = { version = "14.0.0", features = [
"std", "std",
"secp256k1", "secp256k1",
"blst", "blst",
], default-features = false } ], default-features = false }
revm-inspectors = "0.5" revm-inspectors = "0.6"
revm-primitives = { version = "8.0.0", features = [ revm-primitives = { version = "9.0.0", features = [
"std", "std",
], default-features = false } ], default-features = false }
# eth # eth
alloy-chains = "0.1.18" alloy-chains = "0.1.18"
alloy-dyn-abi = "0.7.2" alloy-dyn-abi = "0.8.0"
alloy-primitives = { version = "0.7.2", default-features = false } alloy-primitives = { version = "0.8.0", default-features = false }
alloy-rlp = "0.3.4" alloy-rlp = "0.3.4"
alloy-sol-types = "0.7.2" alloy-sol-types = "0.8.0"
alloy-trie = { version = "0.4", default-features = false } alloy-trie = { version = "0.5", default-features = false }
alloy-consensus = { version = "0.2.1", default-features = false } alloy-consensus = { version = "0.3.0", default-features = false }
alloy-eips = { version = "0.2.1", default-features = false } alloy-eips = { version = "0.3.0", default-features = false }
alloy-genesis = { version = "0.2.1", default-features = false } alloy-genesis = { version = "0.3.0", default-features = false }
alloy-json-rpc = { version = "0.2.1", default-features = false } alloy-json-rpc = { version = "0.3.0", default-features = false }
alloy-network = { version = "0.2.1", default-features = false } alloy-network = { version = "0.3.0", default-features = false }
alloy-node-bindings = { version = "0.2.1", default-features = false } alloy-node-bindings = { version = "0.3.0", default-features = false }
alloy-provider = { version = "0.2.1", features = [ alloy-provider = { version = "0.3.0", features = [
"reqwest", "reqwest",
], default-features = false } ], default-features = false }
alloy-pubsub = { version = "0.2.1", default-features = false } alloy-pubsub = { version = "0.3.0", default-features = false }
alloy-rpc-client = { version = "0.2.1", default-features = false } alloy-rpc-client = { version = "0.3.0", default-features = false }
alloy-rpc-types = { version = "0.2.1", features = [ alloy-rpc-types = { version = "0.3.0", features = [
"eth", "eth",
], default-features = false } ], default-features = false }
alloy-rpc-types-admin = { version = "0.2.1", default-features = false } alloy-rpc-types-admin = { version = "0.3.0", default-features = false }
alloy-rpc-types-anvil = { version = "0.2.1", default-features = false } alloy-rpc-types-anvil = { version = "0.3.0", default-features = false }
alloy-rpc-types-beacon = { version = "0.2.1", default-features = false } alloy-rpc-types-beacon = { version = "0.3.0", default-features = false }
alloy-rpc-types-engine = { version = "0.2.1", default-features = false } alloy-rpc-types-engine = { version = "0.3.0", default-features = false }
alloy-rpc-types-eth = { version = "0.2.1", default-features = false } alloy-rpc-types-eth = { version = "0.3.0", default-features = false }
alloy-rpc-types-mev = { version = "0.2.1", default-features = false } alloy-rpc-types-mev = { version = "0.3.0", default-features = false }
alloy-rpc-types-trace = { version = "0.2.1", default-features = false } alloy-rpc-types-trace = { version = "0.3.0", default-features = false }
alloy-rpc-types-txpool = { version = "0.2.1", default-features = false } alloy-rpc-types-txpool = { version = "0.3.0", default-features = false }
alloy-serde = { version = "0.2.1", default-features = false } alloy-serde = { version = "0.3.0", default-features = false }
alloy-signer = { version = "0.2.1", default-features = false } alloy-signer = { version = "0.3.0", default-features = false }
alloy-signer-local = { version = "0.2.1", default-features = false } alloy-signer-local = { version = "0.3.0", default-features = false }
alloy-transport = { version = "0.2.1" } alloy-transport = { version = "0.3.0" }
alloy-transport-http = { version = "0.2.1", features = [ alloy-transport-http = { version = "0.3.0", features = [
"reqwest-rustls-tls", "reqwest-rustls-tls",
], default-features = false } ], default-features = false }
alloy-transport-ipc = { version = "0.2.1", default-features = false } alloy-transport-ipc = { version = "0.3.0", default-features = false }
alloy-transport-ws = { version = "0.2.1", default-features = false } alloy-transport-ws = { version = "0.3.0", default-features = false }
# op # op
op-alloy-rpc-types = "0.1" op-alloy-rpc-types = "0.2"
op-alloy-network = "0.1" op-alloy-rpc-types-engine = "0.2"
op-alloy-network = "0.2"
# misc # misc
aquamarine = "0.5" aquamarine = "0.5"

View File

@ -3,10 +3,7 @@
use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode}; use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode};
use alloy_eips::BlockNumberOrTag; use alloy_eips::BlockNumberOrTag;
use alloy_provider::{ use alloy_provider::{network::AnyNetwork, Provider, ProviderBuilder, RootProvider};
network::{AnyNetwork, Ethereum},
Provider, ProviderBuilder, RootProvider,
};
use alloy_rpc_client::ClientBuilder; use alloy_rpc_client::ClientBuilder;
use alloy_rpc_types_engine::JwtSecret; use alloy_rpc_types_engine::JwtSecret;
use alloy_transport::BoxTransport; use alloy_transport::BoxTransport;
@ -24,7 +21,7 @@ pub(crate) struct BenchContext {
/// The auth provider used for engine API queries. /// The auth provider used for engine API queries.
pub(crate) auth_provider: RootProvider<BoxTransport, AnyNetwork>, pub(crate) auth_provider: RootProvider<BoxTransport, AnyNetwork>,
/// The block provider used for block queries. /// The block provider used for block queries.
pub(crate) block_provider: RootProvider<Http<Client>, Ethereum>, pub(crate) block_provider: RootProvider<Http<Client>, AnyNetwork>,
/// The benchmark mode, which defines whether the benchmark should run for a closed or open /// The benchmark mode, which defines whether the benchmark should run for a closed or open
/// range of blocks. /// range of blocks.
pub(crate) benchmark_mode: BenchMode, pub(crate) benchmark_mode: BenchMode,
@ -46,7 +43,8 @@ impl BenchContext {
} }
// set up alloy client for blocks // set up alloy client for blocks
let block_provider = ProviderBuilder::new().on_http(rpc_url.parse()?); let block_provider =
ProviderBuilder::new().network::<AnyNetwork>().on_http(rpc_url.parse()?);
// If neither `--from` nor `--to` are provided, we will run the benchmark continuously, // If neither `--from` nor `--to` are provided, we will run the benchmark continuously,
// starting at the latest block. // starting at the latest block.
@ -95,17 +93,7 @@ impl BenchContext {
} }
}; };
let next_block = match first_block.header.number { let next_block = first_block.header.number + 1;
Some(number) => {
// fetch next block
number + 1
}
None => {
// this should never happen
return Err(eyre::eyre!("First block number is None"));
}
};
Ok(Self { auth_provider, block_provider, benchmark_mode, next_block }) Ok(Self { auth_provider, block_provider, benchmark_mode, next_block })
} }
} }

View File

@ -45,17 +45,8 @@ impl Command {
while benchmark_mode.contains(next_block) { while benchmark_mode.contains(next_block) {
let block_res = block_provider.get_block_by_number(next_block.into(), true).await; let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
let block = block_res.unwrap().unwrap(); let block = block_res.unwrap().unwrap();
let block = match block.header.hash { let block_hash = block.header.hash;
Some(block_hash) => { let block = Block::try_from(block.inner).unwrap().seal(block_hash);
// we can reuse the hash in the response
Block::try_from(block).unwrap().seal(block_hash)
}
None => {
// we don't have the hash, so let's just hash it
Block::try_from(block).unwrap().seal_slow()
}
};
let head_block_hash = block.hash(); let head_block_hash = block.hash();
let safe_block_hash = block_provider let safe_block_hash = block_provider
.get_block_by_number(block.number.saturating_sub(32).into(), false); .get_block_by_number(block.number.saturating_sub(32).into(), false);
@ -65,18 +56,9 @@ impl Command {
let (safe, finalized) = tokio::join!(safe_block_hash, finalized_block_hash,); let (safe, finalized) = tokio::join!(safe_block_hash, finalized_block_hash,);
let safe_block_hash = safe let safe_block_hash = safe.unwrap().expect("finalized block exists").header.hash;
.unwrap() let finalized_block_hash =
.expect("finalized block exists") finalized.unwrap().expect("finalized block exists").header.hash;
.header
.hash
.expect("finalized block has hash");
let finalized_block_hash = finalized
.unwrap()
.expect("finalized block exists")
.header
.hash
.expect("finalized block has hash");
next_block += 1; next_block += 1;
sender sender

View File

@ -45,16 +45,8 @@ impl Command {
while benchmark_mode.contains(next_block) { while benchmark_mode.contains(next_block) {
let block_res = block_provider.get_block_by_number(next_block.into(), true).await; let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
let block = block_res.unwrap().unwrap(); let block = block_res.unwrap().unwrap();
let block = match block.header.hash { let block_hash = block.header.hash;
Some(block_hash) => { let block = Block::try_from(block.inner).unwrap().seal(block_hash);
// we can reuse the hash in the response
Block::try_from(block).unwrap().seal(block_hash)
}
None => {
// we don't have the hash, so let's just hash it
Block::try_from(block).unwrap().seal_slow()
}
};
next_block += 1; next_block += 1;
sender.send(block).await.unwrap(); sender.send(block).await.unwrap();

View File

@ -224,7 +224,7 @@ impl Command {
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
reth_node_optimism::OptimismPayloadBuilderAttributes::try_new( reth_node_optimism::OptimismPayloadBuilderAttributes::try_new(
best_block.hash(), best_block.hash(),
reth_rpc_types::engine::OptimismPayloadAttributes { reth_rpc_types::optimism::OptimismPayloadAttributes {
payload_attributes: payload_attrs, payload_attributes: payload_attrs,
transactions: None, transactions: None,
no_tx_pool: None, no_tx_pool: None,

View File

@ -47,7 +47,7 @@ pub trait BlockProvider: Send + Sync + 'static {
None => return Ok(B256::default()), None => return Ok(B256::default()),
}; };
let block = self.get_block(previous_block_number).await?; let block = self.get_block(previous_block_number).await?;
block.header.hash.ok_or_else(|| eyre::eyre!("previous block does not have hash")) Ok(block.header.hash)
} }
} }
} }
@ -198,13 +198,13 @@ pub fn block_to_execution_payload_v3(block: Block) -> ExecutionNewPayload {
receipts_root: block.header.receipts_root, receipts_root: block.header.receipts_root,
logs_bloom: block.header.logs_bloom, logs_bloom: block.header.logs_bloom,
prev_randao: block.header.mix_hash.unwrap(), prev_randao: block.header.mix_hash.unwrap(),
block_number: block.header.number.unwrap(), block_number: block.header.number,
gas_limit: block.header.gas_limit.try_into().unwrap(), gas_limit: block.header.gas_limit.try_into().unwrap(),
gas_used: block.header.gas_used.try_into().unwrap(), gas_used: block.header.gas_used.try_into().unwrap(),
timestamp: block.header.timestamp, timestamp: block.header.timestamp,
extra_data: block.header.extra_data.clone(), extra_data: block.header.extra_data.clone(),
base_fee_per_gas: block.header.base_fee_per_gas.unwrap().try_into().unwrap(), base_fee_per_gas: block.header.base_fee_per_gas.unwrap().try_into().unwrap(),
block_hash: block.header.hash.unwrap(), block_hash: block.header.hash,
transactions: transactions transactions: transactions
.into_iter() .into_iter()
.map(|tx| { .map(|tx| {

View File

@ -63,7 +63,7 @@ impl BlockProvider for EtherscanBlockProvider {
continue continue
} }
}; };
let block_number = block.header.number.unwrap(); let block_number = block.header.number;
if Some(block_number) == last_block_number { if Some(block_number) == last_block_number {
continue; continue;
} }

View File

@ -33,7 +33,7 @@ impl BlockProvider for RpcBlockProvider {
while let Some(block) = stream.next().await { while let Some(block) = stream.next().await {
let full_block = ws_provider let full_block = ws_provider
.get_block_by_hash(block.header.hash.unwrap(), BlockTransactionsKind::Full) .get_block_by_hash(block.header.hash, BlockTransactionsKind::Full)
.await .await
.expect("failed to get block") .expect("failed to get block")
.expect("block not found"); .expect("block not found");

View File

@ -59,7 +59,9 @@ where
N::AddOns: NodeAddOns< N::AddOns: NodeAddOns<
Adapter<N>, Adapter<N>,
EthApi: FullEthApiServer< EthApi: FullEthApiServer<
NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>, NetworkTypes: Network<
TransactionResponse = reth_rpc_types::WithOtherFields<reth_rpc_types::Transaction>,
>,
> + AddDevSigners > + AddDevSigners
+ EthApiBuilderProvider<Adapter<N>>, + EthApiBuilderProvider<Adapter<N>>,
>, >,

View File

@ -17,6 +17,7 @@ use reth::{
}; };
use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypes}; use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypes};
use reth_primitives::{BlockHash, BlockNumber, Bytes, B256}; use reth_primitives::{BlockHash, BlockNumber, Bytes, B256};
use reth_rpc_types::WithOtherFields;
use reth_stages_types::StageId; use reth_stages_types::StageId;
use tokio_stream::StreamExt; use tokio_stream::StreamExt;
@ -94,7 +95,7 @@ where
From<<Node::Engine as PayloadTypes>::BuiltPayload> + PayloadEnvelopeExt, From<<Node::Engine as PayloadTypes>::BuiltPayload> + PayloadEnvelopeExt,
AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt, AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt,
<AddOns::EthApi as EthApiTypes>::NetworkTypes: <AddOns::EthApi as EthApiTypes>::NetworkTypes:
Network<TransactionResponse = alloy_rpc_types::Transaction>, Network<TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>>,
{ {
let mut chain = Vec::with_capacity(length as usize); let mut chain = Vec::with_capacity(length as usize);
for i in 0..length { for i in 0..length {

View File

@ -9,6 +9,7 @@ use reth::{
}; };
use reth_node_builder::EthApiTypes; use reth_node_builder::EthApiTypes;
use reth_primitives::{Bytes, B256}; use reth_primitives::{Bytes, B256};
use reth_rpc_types::WithOtherFields;
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> { pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {
@ -19,8 +20,11 @@ impl<Node, EthApi> RpcTestContext<Node, EthApi>
where where
Node: FullNodeComponents, Node: FullNodeComponents,
EthApi: EthApiSpec EthApi: EthApiSpec
+ EthTransactions<NetworkTypes: Network<TransactionResponse = alloy_rpc_types::Transaction>> + EthTransactions<
+ TraceExt, NetworkTypes: Network<
TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>,
>,
> + TraceExt,
{ {
/// Injects a raw transaction into the node tx pool via RPC server /// Injects a raw transaction into the node tx pool via RPC server
pub async fn inject_tx(&self, raw_tx: Bytes) -> Result<B256, EthApi::Error> { pub async fn inject_tx(&self, raw_tx: Bytes) -> Result<B256, EthApi::Error> {

View File

@ -1,5 +1,5 @@
use reth::rpc::types::{ use reth::rpc::types::{
engine::{ExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV3}, engine::ExecutionPayloadEnvelopeV3, optimism::OptimismExecutionPayloadEnvelopeV3,
ExecutionPayloadV3, ExecutionPayloadV3,
}; };

View File

@ -203,9 +203,6 @@ mod tests {
// Ensure that the logs database is empty // Ensure that the logs database is empty
assert!(evm.context.evm.inner.db.logs.is_empty()); assert!(evm.context.evm.inner.db.logs.is_empty());
// Ensure that there are no valid authorizations in the EVM context
assert!(evm.context.evm.inner.valid_authorizations.is_empty());
// No Optimism // No Optimism
assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() }); assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() });
} }
@ -357,9 +354,6 @@ mod tests {
// Ensure that the logs database is empty // Ensure that the logs database is empty
assert!(evm.context.evm.inner.db.logs.is_empty()); assert!(evm.context.evm.inner.db.logs.is_empty());
// Ensure that there are no valid authorizations in the EVM context
assert!(evm.context.evm.inner.valid_authorizations.is_empty());
// No Optimism // No Optimism
assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() }); assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() });
} }

View File

@ -5,6 +5,7 @@
pub mod add_ons; pub mod add_ons;
mod states; mod states;
use reth_rpc_types::WithOtherFields;
pub use states::*; pub use states::*;
use std::sync::Arc; use std::sync::Arc;
@ -330,7 +331,7 @@ where
> >
+ FullEthApiServer< + FullEthApiServer<
NetworkTypes: alloy_network::Network< NetworkTypes: alloy_network::Network<
TransactionResponse = reth_rpc_types::Transaction TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>, >,
> >
+ AddDevSigners + AddDevSigners
@ -479,7 +480,9 @@ where
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>, NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>> EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>
+ FullEthApiServer< + FullEthApiServer<
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>, NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
> + AddDevSigners, > + AddDevSigners,
>, >,
{ {

View File

@ -27,7 +27,7 @@ use reth_node_core::{
use reth_node_events::{cl::ConsensusLayerHealthEvents, node}; use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_provider::providers::BlockchainProvider2; use reth_provider::providers::BlockchainProvider2;
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi}; use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
use reth_rpc_types::engine::ClientVersionV1; use reth_rpc_types::{engine::ClientVersionV1, WithOtherFields};
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;
use reth_tokio_util::EventSender; use reth_tokio_util::EventSender;
use reth_tracing::tracing::{debug, error, info}; use reth_tracing::tracing::{debug, error, info};
@ -67,7 +67,9 @@ where
NodeAdapter<T, CB::Components>, NodeAdapter<T, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>> EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
+ FullEthApiServer< + FullEthApiServer<
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>, NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
> + AddDevSigners, > + AddDevSigners,
>, >,
{ {

View File

@ -32,7 +32,7 @@ use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_primitives::format_ether; use reth_primitives::format_ether;
use reth_provider::providers::BlockchainProvider; use reth_provider::providers::BlockchainProvider;
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi}; use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
use reth_rpc_types::engine::ClientVersionV1; use reth_rpc_types::{engine::ClientVersionV1, WithOtherFields};
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;
use reth_tracing::tracing::{debug, info}; use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::TransactionPool; use reth_transaction_pool::TransactionPool;
@ -111,7 +111,9 @@ where
NodeAdapter<T, CB::Components>, NodeAdapter<T, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>> EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
+ FullEthApiServer< + FullEthApiServer<
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>, NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
> + AddDevSigners, > + AddDevSigners,
>, >,
{ {

View File

@ -21,6 +21,7 @@ use reth_rpc_builder::{
RpcModuleBuilder, RpcRegistryInner, RpcServerHandle, TransportRpcModules, RpcModuleBuilder, RpcRegistryInner, RpcServerHandle, TransportRpcModules,
}; };
use reth_rpc_layer::JwtSecret; use reth_rpc_layer::JwtSecret;
use reth_rpc_types::WithOtherFields;
use reth_tasks::TaskExecutor; use reth_tasks::TaskExecutor;
use reth_tracing::tracing::{debug, info}; use reth_tracing::tracing::{debug, info};
@ -300,7 +301,9 @@ where
Engine: EngineApiServer<Node::Engine>, Engine: EngineApiServer<Node::Engine>,
EthApi: EthApiBuilderProvider<Node> EthApi: EthApiBuilderProvider<Node>
+ FullEthApiServer< + FullEthApiServer<
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>, NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
>, >,
{ {
let auth_config = config.rpc.auth_server_config(jwt_secret)?; let auth_config = config.rpc.auth_server_config(jwt_secret)?;

View File

@ -223,9 +223,6 @@ mod tests {
// Ensure that the logs database is empty // Ensure that the logs database is empty
assert!(evm.context.evm.inner.db.logs.is_empty()); assert!(evm.context.evm.inner.db.logs.is_empty());
// Ensure that there are no valid authorizations in the EVM context
assert!(evm.context.evm.inner.valid_authorizations.is_empty());
// Optimism in handler // Optimism in handler
assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true }); assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, is_optimism: true });
@ -372,9 +369,6 @@ mod tests {
// Ensure that the logs database is empty // Ensure that the logs database is empty
assert!(evm.context.evm.inner.db.logs.is_empty()); assert!(evm.context.evm.inner.db.logs.is_empty());
// Ensure that there are no valid authorizations in the EVM context
assert!(evm.context.evm.inner.valid_authorizations.is_empty());
// Default spec ID // Default spec ID
assert_eq!(evm.handler.spec_id(), SpecId::LATEST); assert_eq!(evm.handler.spec_id(), SpecId::LATEST);

View File

@ -9,9 +9,10 @@ use reth_node_api::{
}; };
use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes}; use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes};
use reth_rpc_types::{ use reth_rpc_types::{
engine::{ engine::ExecutionPayloadEnvelopeV2,
ExecutionPayloadEnvelopeV2, OptimismExecutionPayloadEnvelopeV3, optimism::{
OptimismExecutionPayloadEnvelopeV4, OptimismPayloadAttributes, OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4,
OptimismPayloadAttributes,
}, },
ExecutionPayloadV1, ExecutionPayloadV1,
}; };

View File

@ -15,10 +15,10 @@ use reth_primitives::{
U256, U256,
}; };
/// Re-export for use in downstream arguments. /// Re-export for use in downstream arguments.
pub use reth_rpc_types::engine::OptimismPayloadAttributes; pub use reth_rpc_types::optimism::OptimismPayloadAttributes;
use reth_rpc_types::engine::{ use reth_rpc_types::{
ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, OptimismExecutionPayloadEnvelopeV3, engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId},
OptimismExecutionPayloadEnvelopeV4, PayloadId, optimism::{OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4},
}; };
use reth_rpc_types_compat::engine::payload::{ use reth_rpc_types_compat::engine::payload::{
block_to_payload_v1, block_to_payload_v3, block_to_payload_v4, block_to_payload_v1, block_to_payload_v3, block_to_payload_v4,

View File

@ -60,7 +60,7 @@ where
chain_id, chain_id,
blob_versioned_hashes, blob_versioned_hashes,
max_fee_per_blob_gas, max_fee_per_blob_gas,
// authorization_list, authorization_list,
.. ..
} = request; } = request;
@ -98,7 +98,7 @@ where
// EIP-4844 fields // EIP-4844 fields
blob_hashes: blob_versioned_hashes.unwrap_or_default(), blob_hashes: blob_versioned_hashes.unwrap_or_default(),
max_fee_per_blob_gas, max_fee_per_blob_gas,
authorization_list: Default::default(), authorization_list: authorization_list.map(Into::into),
optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() }, optimism: OptimismFields { enveloped_tx: Some(Bytes::new()), ..Default::default() },
}; };

View File

@ -12,7 +12,7 @@ use std::{fmt, sync::Arc};
use crate::eth::rpc::SequencerClient; use crate::eth::rpc::SequencerClient;
use alloy_primitives::U256; use alloy_primitives::U256;
use op_alloy_network::Optimism; use op_alloy_network::AnyNetwork;
use reth_chainspec::ChainSpec; use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_network_api::NetworkInfo; use reth_network_api::NetworkInfo;
@ -107,7 +107,7 @@ where
N: FullNodeComponents, N: FullNodeComponents,
{ {
type Error = OpEthApiError; type Error = OpEthApiError;
type NetworkTypes = Optimism; type NetworkTypes = AnyNetwork;
} }
impl<N> EthApiSpec for OpEthApi<N> impl<N> EthApiSpec for OpEthApi<N>

View File

@ -7,7 +7,7 @@ use reth_rpc_eth_api::{
FromEthApiError, FromEthApiError,
}; };
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder}; use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
use reth_rpc_types::{AnyTransactionReceipt, OptimismTransactionReceiptFields}; use reth_rpc_types::{optimism::OptimismTransactionReceiptFields, AnyTransactionReceipt};
use crate::{OpEthApi, OpEthApiError, OptimismTxMeta}; use crate::{OpEthApi, OpEthApiError, OptimismTxMeta};

View File

@ -5,7 +5,8 @@ use reth_primitives::{
Address, Header, SealedBlock, Withdrawals, B256, U256, Address, Header, SealedBlock, Withdrawals, B256, U256,
}; };
use reth_rpc_types::{ use reth_rpc_types::{
engine::{OptimismPayloadAttributes, PayloadAttributes as EthPayloadAttributes, PayloadId}, engine::{PayloadAttributes as EthPayloadAttributes, PayloadId},
optimism::OptimismPayloadAttributes,
Withdrawal, Withdrawal,
}; };

View File

@ -66,9 +66,14 @@ impl Compact for Bytecode {
where where
B: bytes::BufMut + AsMut<[u8]>, B: bytes::BufMut + AsMut<[u8]>,
{ {
let bytecode = &self.0.bytecode()[..]; let bytecode = match &self.0 {
RevmBytecode::LegacyRaw(bytes) => bytes,
RevmBytecode::LegacyAnalyzed(analyzed) => analyzed.bytecode(),
RevmBytecode::Eof(eof) => eof.raw(),
RevmBytecode::Eip7702(eip7702) => eip7702.raw(),
};
buf.put_u32(bytecode.len() as u32); buf.put_u32(bytecode.len() as u32);
buf.put_slice(bytecode); buf.put_slice(bytecode.as_ref());
let len = match &self.0 { let len = match &self.0 {
RevmBytecode::LegacyRaw(_) => { RevmBytecode::LegacyRaw(_) => {
buf.put_u8(0); buf.put_u8(0);
@ -82,10 +87,13 @@ impl Compact for Bytecode {
buf.put_slice(map); buf.put_slice(map);
1 + 8 + map.len() 1 + 8 + map.len()
} }
RevmBytecode::Eof(eof) => { RevmBytecode::Eof(_) => {
buf.put_u8(3); buf.put_u8(3);
buf.put_slice(eof.raw().as_ref()); 1
1 + eof.raw().as_ref().len() }
RevmBytecode::Eip7702(_) => {
buf.put_u8(4);
1
} }
}; };
len + bytecode.len() + 4 len + bytecode.len() + 4
@ -109,8 +117,8 @@ impl Compact for Bytecode {
JumpTable::from_slice(buf), JumpTable::from_slice(buf),
) )
}), }),
3 => { 3 | 4 => {
// EOF bytecode object will be decoded from the raw bytecode // EOF and EIP-7702 bytecode objects will be decoded from the raw bytecode
Self(RevmBytecode::new_raw(bytes)) Self(RevmBytecode::new_raw(bytes))
} }
_ => unreachable!("Junk data in database: unknown Bytecode variant"), _ => unreachable!("Junk data in database: unknown Bytecode variant"),

View File

@ -32,7 +32,7 @@ impl TryFrom<RpcHeader> for Header {
logs_bloom: header.logs_bloom, logs_bloom: header.logs_bloom,
mix_hash: header.mix_hash.unwrap_or_default(), mix_hash: header.mix_hash.unwrap_or_default(),
nonce: u64::from_be_bytes(header.nonce.unwrap_or_default().0), nonce: u64::from_be_bytes(header.nonce.unwrap_or_default().0),
number: header.number.ok_or(ConversionError::MissingBlockNumber)?, number: header.number,
ommers_hash: header.uncles_hash, ommers_hash: header.uncles_hash,
parent_beacon_block_root: header.parent_beacon_block_root, parent_beacon_block_root: header.parent_beacon_block_root,
parent_hash: header.parent_hash, parent_hash: header.parent_hash,

View File

@ -26,10 +26,14 @@ reth-optimism-chainspec = { workspace = true, optional = true }
alloy-primitives = { workspace = true, features = ["rand", "rlp"] } alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
alloy-rlp = { workspace = true, features = ["arrayvec"] } alloy-rlp = { workspace = true, features = ["arrayvec"] }
alloy-rpc-types = { workspace = true, optional = true } alloy-rpc-types = { workspace = true, optional = true }
alloy-serde = { workspace = true, optional = true }
alloy-genesis.workspace = true alloy-genesis.workspace = true
alloy-eips = { workspace = true, features = ["serde"] } alloy-eips = { workspace = true, features = ["serde"] }
alloy-consensus.workspace = true alloy-consensus.workspace = true
# optimism
op-alloy-rpc-types = { workspace = true, optional = true }
# crypto # crypto
secp256k1 = { workspace = true, features = [ secp256k1 = { workspace = true, features = [
"global-context", "global-context",
@ -103,7 +107,7 @@ optimism = [
"revm-primitives/optimism", "revm-primitives/optimism",
"dep:reth-optimism-chainspec", "dep:reth-optimism-chainspec",
] ]
alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types"] alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types", "dep:alloy-serde", "dep:op-alloy-rpc-types"]
test-utils = ["reth-primitives-traits/test-utils"] test-utils = ["reth-primitives-traits/test-utils"]
[[bench]] [[bench]]

View File

@ -7,37 +7,27 @@ use crate::{
}; };
use alloy_primitives::TxKind; use alloy_primitives::TxKind;
use alloy_rlp::Error as RlpError; use alloy_rlp::Error as RlpError;
use alloy_serde::WithOtherFields;
use op_alloy_rpc_types as _;
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use alloc::{string::ToString, vec::Vec}; use alloc::{string::ToString, vec::Vec};
impl TryFrom<alloy_rpc_types::Block> for Block { impl TryFrom<alloy_rpc_types::Block<WithOtherFields<alloy_rpc_types::Transaction>>> for Block {
type Error = alloy_rpc_types::ConversionError; type Error = alloy_rpc_types::ConversionError;
fn try_from(block: alloy_rpc_types::Block) -> Result<Self, Self::Error> { fn try_from(
block: alloy_rpc_types::Block<WithOtherFields<alloy_rpc_types::Transaction>>,
) -> Result<Self, Self::Error> {
use alloy_rpc_types::ConversionError; use alloy_rpc_types::ConversionError;
let body = { let body = {
let transactions: Result<Vec<TransactionSigned>, ConversionError> = match block let transactions: Result<Vec<TransactionSigned>, ConversionError> = match block
.transactions .transactions
{ {
alloy_rpc_types::BlockTransactions::Full(transactions) => transactions alloy_rpc_types::BlockTransactions::Full(transactions) => {
.into_iter() transactions.into_iter().map(|tx| tx.try_into()).collect()
.map(|tx| { }
let signature = tx.signature.ok_or(ConversionError::MissingSignature)?;
Ok(TransactionSigned::from_transaction_and_signature(
tx.try_into()?,
crate::Signature {
r: signature.r,
s: signature.s,
odd_y_parity: signature
.y_parity
.unwrap_or_else(|| alloy_rpc_types::Parity(!signature.v.bit(0)))
.0,
},
))
})
.collect(),
alloy_rpc_types::BlockTransactions::Hashes(_) | alloy_rpc_types::BlockTransactions::Hashes(_) |
alloy_rpc_types::BlockTransactions::Uncle => { alloy_rpc_types::BlockTransactions::Uncle => {
// alloy deserializes empty blocks into `BlockTransactions::Hashes`, if the tx // alloy deserializes empty blocks into `BlockTransactions::Hashes`, if the tx
@ -64,13 +54,18 @@ impl TryFrom<alloy_rpc_types::Block> for Block {
} }
} }
impl TryFrom<alloy_rpc_types::Transaction> for Transaction { impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for Transaction {
type Error = alloy_rpc_types::ConversionError; type Error = alloy_rpc_types::ConversionError;
fn try_from(tx: alloy_rpc_types::Transaction) -> Result<Self, Self::Error> { fn try_from(tx: WithOtherFields<alloy_rpc_types::Transaction>) -> Result<Self, Self::Error> {
use alloy_eips::eip2718::Eip2718Error; use alloy_eips::eip2718::Eip2718Error;
use alloy_rpc_types::ConversionError; use alloy_rpc_types::ConversionError;
#[cfg(feature = "optimism")]
let WithOtherFields { inner: tx, other } = tx;
#[cfg(not(feature = "optimism"))]
let WithOtherFields { inner: tx, other: _ } = tx;
match tx.transaction_type.map(TryInto::try_into).transpose().map_err(|_| { match tx.transaction_type.map(TryInto::try_into).transpose().map_err(|_| {
ConversionError::Eip2718Error(Eip2718Error::UnexpectedType( ConversionError::Eip2718Error(Eip2718Error::UnexpectedType(
tx.transaction_type.unwrap(), tx.transaction_type.unwrap(),
@ -211,9 +206,8 @@ impl TryFrom<alloy_rpc_types::Transaction> for Transaction {
} }
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
Some(TxType::Deposit) => { Some(TxType::Deposit) => {
let fields = tx let fields = other
.other .deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>()
.deserialize_into::<alloy_rpc_types::optimism::OptimismTransactionFields>()
.map_err(|e| ConversionError::Custom(e.to_string()))?; .map_err(|e| ConversionError::Custom(e.to_string()))?;
Ok(Self::Deposit(crate::transaction::TxDeposit { Ok(Self::Deposit(crate::transaction::TxDeposit {
source_hash: fields source_hash: fields
@ -235,10 +229,10 @@ impl TryFrom<alloy_rpc_types::Transaction> for Transaction {
} }
} }
impl TryFrom<alloy_rpc_types::Transaction> for TransactionSigned { impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for TransactionSigned {
type Error = alloy_rpc_types::ConversionError; type Error = alloy_rpc_types::ConversionError;
fn try_from(tx: alloy_rpc_types::Transaction) -> Result<Self, Self::Error> { fn try_from(tx: WithOtherFields<alloy_rpc_types::Transaction>) -> Result<Self, Self::Error> {
use alloy_rpc_types::ConversionError; use alloy_rpc_types::ConversionError;
let signature = tx.signature.ok_or(ConversionError::MissingSignature)?; let signature = tx.signature.ok_or(ConversionError::MissingSignature)?;
@ -268,10 +262,10 @@ impl TryFrom<alloy_rpc_types::Transaction> for TransactionSigned {
} }
} }
impl TryFrom<alloy_rpc_types::Transaction> for TransactionSignedEcRecovered { impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for TransactionSignedEcRecovered {
type Error = alloy_rpc_types::ConversionError; type Error = alloy_rpc_types::ConversionError;
fn try_from(tx: alloy_rpc_types::Transaction) -> Result<Self, Self::Error> { fn try_from(tx: WithOtherFields<alloy_rpc_types::Transaction>) -> Result<Self, Self::Error> {
use alloy_rpc_types::ConversionError; use alloy_rpc_types::ConversionError;
let transaction: TransactionSigned = tx.try_into()?; let transaction: TransactionSigned = tx.try_into()?;
@ -296,10 +290,10 @@ impl TryFrom<alloy_rpc_types::Signature> for Signature {
} }
} }
impl TryFrom<alloy_rpc_types::Transaction> for TransactionSignedNoHash { impl TryFrom<WithOtherFields<alloy_rpc_types::Transaction>> for TransactionSignedNoHash {
type Error = alloy_rpc_types::ConversionError; type Error = alloy_rpc_types::ConversionError;
fn try_from(tx: alloy_rpc_types::Transaction) -> Result<Self, Self::Error> { fn try_from(tx: WithOtherFields<alloy_rpc_types::Transaction>) -> Result<Self, Self::Error> {
Ok(Self { Ok(Self {
signature: tx.signature.ok_or(Self::Error::MissingSignature)?.try_into()?, signature: tx.signature.ok_or(Self::Error::MissingSignature)?.try_into()?,
transaction: tx.try_into()?, transaction: tx.try_into()?,
@ -337,7 +331,7 @@ mod tests {
"v": "0x0", "v": "0x0",
"value": "0x0" "value": "0x0"
}"#; }"#;
let alloy_tx: AlloyTransaction = let alloy_tx: WithOtherFields<AlloyTransaction> =
serde_json::from_str(input).expect("failed to deserialize"); serde_json::from_str(input).expect("failed to deserialize");
let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert"); let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert");
@ -387,7 +381,7 @@ mod tests {
"v": "0x0", "v": "0x0",
"value": "0x239c2e16a5ca590000" "value": "0x239c2e16a5ca590000"
}"#; }"#;
let alloy_tx: AlloyTransaction = let alloy_tx: WithOtherFields<AlloyTransaction> =
serde_json::from_str(input).expect("failed to deserialize"); serde_json::from_str(input).expect("failed to deserialize");
let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert"); let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert");

View File

@ -2,4 +2,4 @@
/// Re-export from `alloy_eips`. /// Re-export from `alloy_eips`.
#[doc(inline)] #[doc(inline)]
pub use alloy_eips::eip7702::{Authorization, OptionalNonce, SignedAuthorization}; pub use alloy_eips::eip7702::{Authorization, SignedAuthorization};

View File

@ -227,7 +227,7 @@ impl From<alloy_consensus::TxType> for TxType {
alloy_consensus::TxType::Eip2930 => Self::Eip2930, alloy_consensus::TxType::Eip2930 => Self::Eip2930,
alloy_consensus::TxType::Eip1559 => Self::Eip1559, alloy_consensus::TxType::Eip1559 => Self::Eip1559,
alloy_consensus::TxType::Eip4844 => Self::Eip4844, alloy_consensus::TxType::Eip4844 => Self::Eip4844,
//alloy_consensus::TxType::Eip7702 => Self::Eip7702, alloy_consensus::TxType::Eip7702 => Self::Eip7702,
} }
} }
} }

View File

@ -220,7 +220,7 @@ pub trait EngineApi<Engine: EngineTypes> {
/// Specifically for the engine auth server: <https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#underlying-protocol> /// Specifically for the engine auth server: <https://github.com/ethereum/execution-apis/blob/main/src/engine/common.md#underlying-protocol>
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))] #[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))] #[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
pub trait EngineEthApi<T: RpcObject, B: RpcObject> { pub trait EngineEthApi<B: RpcObject> {
/// Returns an object with data about the sync status or false. /// Returns an object with data about the sync status or false.
#[method(name = "syncing")] #[method(name = "syncing")]
fn syncing(&self) -> RpcResult<SyncStatus>; fn syncing(&self) -> RpcResult<SyncStatus>;

View File

@ -5,7 +5,7 @@ use reth_rpc_types::{
BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry, BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry,
TransactionsWithReceipts, TransactionsWithReceipts,
}, },
Header, Header, Transaction, WithOtherFields,
}; };
/// Otterscan rpc interface. /// Otterscan rpc interface.
@ -61,7 +61,7 @@ pub trait Otterscan {
block_number: u64, block_number: u64,
page_number: usize, page_number: usize,
page_size: usize, page_size: usize,
) -> RpcResult<OtsBlockTransactions>; ) -> RpcResult<OtsBlockTransactions<WithOtherFields<Transaction>>>;
/// Gets paginated inbound/outbound transaction calls for a certain address. /// Gets paginated inbound/outbound transaction calls for a certain address.
#[method(name = "searchTransactionsBefore")] #[method(name = "searchTransactionsBefore")]

View File

@ -1,6 +1,9 @@
use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::Address; use reth_primitives::Address;
use reth_rpc_types::txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolStatus}; use reth_rpc_types::{
txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolStatus},
Transaction, WithOtherFields,
};
/// Txpool rpc interface. /// Txpool rpc interface.
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "txpool"))] #[cfg_attr(not(feature = "client"), rpc(server, namespace = "txpool"))]
@ -25,12 +28,15 @@ pub trait TxPoolApi {
/// ///
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details /// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details
#[method(name = "contentFrom")] #[method(name = "contentFrom")]
async fn txpool_content_from(&self, from: Address) -> RpcResult<TxpoolContentFrom>; async fn txpool_content_from(
&self,
from: Address,
) -> RpcResult<TxpoolContentFrom<WithOtherFields<Transaction>>>;
/// Returns the details of all transactions currently pending for inclusion in the next /// Returns the details of all transactions currently pending for inclusion in the next
/// block(s), as well as the ones that are being scheduled for future execution only. /// block(s), as well as the ones that are being scheduled for future execution only.
/// ///
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details /// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details
#[method(name = "content")] #[method(name = "content")]
async fn txpool_content(&self) -> RpcResult<TxpoolContent>; async fn txpool_content(&self) -> RpcResult<TxpoolContent<WithOtherFields<Transaction>>>;
} }

View File

@ -169,6 +169,7 @@ use reth_rpc_eth_api::{
}; };
use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider}; use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider};
use reth_rpc_layer::{AuthLayer, Claims, JwtAuthValidator, JwtSecret}; use reth_rpc_layer::{AuthLayer, Claims, JwtAuthValidator, JwtSecret};
use reth_rpc_types::WithOtherFields;
use reth_tasks::{pool::BlockingTaskGuard, TaskSpawner, TokioTaskExecutor}; use reth_tasks::{pool::BlockingTaskGuard, TaskSpawner, TokioTaskExecutor};
use reth_transaction_pool::{noop::NoopTransactionPool, TransactionPool}; use reth_transaction_pool::{noop::NoopTransactionPool, TransactionPool};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -804,7 +805,10 @@ where
/// If called outside of the tokio runtime. See also [`Self::eth_api`] /// If called outside of the tokio runtime. See also [`Self::eth_api`]
pub fn register_ots(&mut self) -> &mut Self pub fn register_ots(&mut self) -> &mut Self
where where
EthApi: EthApiServer<reth_rpc_types::Transaction, reth_rpc_types::Block> + TraceExt, EthApi: EthApiServer<
WithOtherFields<reth_rpc_types::Transaction>,
reth_rpc_types::Block<WithOtherFields<reth_rpc_types::Transaction>>,
> + TraceExt,
{ {
let otterscan_api = self.otterscan_api(); let otterscan_api = self.otterscan_api();
self.modules.insert(RethRpcModule::Ots, otterscan_api.into_rpc().into()); self.modules.insert(RethRpcModule::Ots, otterscan_api.into_rpc().into());
@ -904,7 +908,10 @@ where
/// If called outside of the tokio runtime. See also [`Self::eth_api`] /// If called outside of the tokio runtime. See also [`Self::eth_api`]
pub fn otterscan_api(&self) -> OtterscanApi<EthApi> pub fn otterscan_api(&self) -> OtterscanApi<EthApi>
where where
EthApi: EthApiServer<reth_rpc_types::Transaction, reth_rpc_types::Block>, EthApi: EthApiServer<
WithOtherFields<reth_rpc_types::Transaction>,
reth_rpc_types::Block<WithOtherFields<reth_rpc_types::Transaction>>,
> + TraceExt,
{ {
let eth_api = self.eth_api().clone(); let eth_api = self.eth_api().clone();
OtterscanApi::new(eth_api) OtterscanApi::new(eth_api)

View File

@ -853,7 +853,7 @@ pub trait Call: LoadState + SpawnBlocking {
chain_id, chain_id,
blob_versioned_hashes, blob_versioned_hashes,
max_fee_per_blob_gas, max_fee_per_blob_gas,
// authorization_list, authorization_list,
.. ..
} = request; } = request;
@ -892,7 +892,7 @@ pub trait Call: LoadState + SpawnBlocking {
blob_hashes: blob_versioned_hashes.unwrap_or_default(), blob_hashes: blob_versioned_hashes.unwrap_or_default(),
max_fee_per_blob_gas, max_fee_per_blob_gas,
// EIP-7702 fields // EIP-7702 fields
// authorization_list: TODO authorization_list: authorization_list.map(Into::into),
..Default::default() ..Default::default()
}; };

View File

@ -2,9 +2,9 @@
use std::error::Error; use std::error::Error;
use alloy_network::{Ethereum, Network}; use alloy_network::{AnyNetwork, Network};
use reth_rpc_eth_types::EthApiError; use reth_rpc_eth_types::EthApiError;
use reth_rpc_types::{Block, Transaction}; use reth_rpc_types::{Block, Transaction, WithOtherFields};
use crate::{AsEthApiError, FromEthApiError, FromEvmError}; use crate::{AsEthApiError, FromEthApiError, FromEvmError};
@ -20,12 +20,12 @@ pub trait EthApiTypes: Send + Sync + Clone {
+ Sync; + Sync;
/// Blockchain primitive types, specific to network, e.g. block and transaction. /// Blockchain primitive types, specific to network, e.g. block and transaction.
// todo: remove restriction `reth_rpc_types::Transaction` // todo: remove restriction `reth_rpc_types::Transaction`
type NetworkTypes: Network<TransactionResponse = Transaction>; type NetworkTypes: Network<TransactionResponse = WithOtherFields<Transaction>>;
} }
impl EthApiTypes for () { impl EthApiTypes for () {
type Error = EthApiError; type Error = EthApiError;
type NetworkTypes = Ethereum; type NetworkTypes = AnyNetwork;
} }
/// Adapter for network specific transaction type. /// Adapter for network specific transaction type.

View File

@ -2,7 +2,7 @@
//! //!
//! Transaction wrapper that labels transaction with its origin. //! Transaction wrapper that labels transaction with its origin.
use reth_primitives::{TransactionSignedEcRecovered, B256}; use reth_primitives::{TransactionSignedEcRecovered, B256};
use reth_rpc_types::{Transaction, TransactionInfo}; use reth_rpc_types::{Transaction, TransactionInfo, WithOtherFields};
use reth_rpc_types_compat::transaction::from_recovered_with_block_context; use reth_rpc_types_compat::transaction::from_recovered_with_block_context;
/// Represents from where a transaction was fetched. /// Represents from where a transaction was fetched.
@ -77,7 +77,7 @@ impl From<TransactionSource> for TransactionSignedEcRecovered {
} }
} }
impl From<TransactionSource> for Transaction { impl From<TransactionSource> for WithOtherFields<Transaction> {
fn from(value: TransactionSource) -> Self { fn from(value: TransactionSource) -> Self {
match value { match value {
TransactionSource::Pool(tx) => reth_rpc_types_compat::transaction::from_recovered(tx), TransactionSource::Pool(tx) => reth_rpc_types_compat::transaction::from_recovered(tx),

View File

@ -11,7 +11,7 @@ repository.workspace = true
workspace = true workspace = true
[dependencies] [dependencies]
alloy-rpc-types-engine.workspace = true alloy-rpc-types-engine = { workspace = true, features = ["jwt"] }
http.workspace = true http.workspace = true
jsonrpsee-http-client.workspace = true jsonrpsee-http-client.workspace = true

View File

@ -6,7 +6,9 @@ use alloy_rpc_types::{Transaction, TransactionInfo};
use reth_primitives::{ use reth_primitives::{
Block as PrimitiveBlock, BlockWithSenders, Header as PrimitiveHeader, Withdrawals, B256, U256, Block as PrimitiveBlock, BlockWithSenders, Header as PrimitiveHeader, Withdrawals, B256, U256,
}; };
use reth_rpc_types::{Block, BlockError, BlockTransactions, BlockTransactionsKind, Header}; use reth_rpc_types::{
Block, BlockError, BlockTransactions, BlockTransactionsKind, Header, WithOtherFields,
};
/// Converts the given primitive block into a [`Block`] response with the given /// Converts the given primitive block into a [`Block`] response with the given
/// [`BlockTransactionsKind`] /// [`BlockTransactionsKind`]
@ -17,7 +19,7 @@ pub fn from_block(
total_difficulty: U256, total_difficulty: U256,
kind: BlockTransactionsKind, kind: BlockTransactionsKind,
block_hash: Option<B256>, block_hash: Option<B256>,
) -> Result<Block, BlockError> { ) -> Result<Block<WithOtherFields<Transaction>>, BlockError> {
match kind { match kind {
BlockTransactionsKind::Hashes => { BlockTransactionsKind::Hashes => {
Ok(from_block_with_tx_hashes(block, total_difficulty, block_hash)) Ok(from_block_with_tx_hashes(block, total_difficulty, block_hash))
@ -35,7 +37,7 @@ pub fn from_block_with_tx_hashes(
block: BlockWithSenders, block: BlockWithSenders,
total_difficulty: U256, total_difficulty: U256,
block_hash: Option<B256>, block_hash: Option<B256>,
) -> Block { ) -> Block<WithOtherFields<Transaction>> {
let block_hash = block_hash.unwrap_or_else(|| block.header.hash_slow()); let block_hash = block_hash.unwrap_or_else(|| block.header.hash_slow());
let transactions = block.body.iter().map(|tx| tx.hash()).collect(); let transactions = block.body.iter().map(|tx| tx.hash()).collect();
@ -57,7 +59,7 @@ pub fn from_block_full(
mut block: BlockWithSenders, mut block: BlockWithSenders,
total_difficulty: U256, total_difficulty: U256,
block_hash: Option<B256>, block_hash: Option<B256>,
) -> Result<Block, BlockError> { ) -> Result<Block<WithOtherFields<Transaction>>, BlockError> {
let block_hash = block_hash.unwrap_or_else(|| block.block.header.hash_slow()); let block_hash = block_hash.unwrap_or_else(|| block.block.header.hash_slow());
let block_number = block.block.number; let block_number = block.block.number;
let base_fee_per_gas = block.block.base_fee_per_gas; let base_fee_per_gas = block.block.base_fee_per_gas;
@ -125,7 +127,7 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader)
} = header; } = header;
Header { Header {
hash: Some(hash), hash,
parent_hash, parent_hash,
uncles_hash: ommers_hash, uncles_hash: ommers_hash,
miner: beneficiary, miner: beneficiary,
@ -133,7 +135,7 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader)
transactions_root, transactions_root,
receipts_root, receipts_root,
withdrawals_root, withdrawals_root,
number: Some(number), number,
gas_used: gas_used as u128, gas_used: gas_used as u128,
gas_limit: gas_limit as u128, gas_limit: gas_limit as u128,
extra_data, extra_data,
@ -157,8 +159,8 @@ fn from_block_with_transactions(
block_hash: B256, block_hash: B256,
block: PrimitiveBlock, block: PrimitiveBlock,
total_difficulty: U256, total_difficulty: U256,
transactions: BlockTransactions<Transaction>, transactions: BlockTransactions<WithOtherFields<Transaction>>,
) -> Block { ) -> Block<WithOtherFields<Transaction>> {
let uncles = block.ommers.into_iter().map(|h| h.hash_slow()).collect(); let uncles = block.ommers.into_iter().map(|h| h.hash_slow()).collect();
let mut header = from_primitive_with_hash(block.header.seal(block_hash)); let mut header = from_primitive_with_hash(block.header.seal(block_hash));
header.total_difficulty = Some(total_difficulty); header.total_difficulty = Some(total_difficulty);
@ -169,19 +171,12 @@ fn from_block_with_transactions(
.then(|| block.withdrawals.map(Withdrawals::into_inner)) .then(|| block.withdrawals.map(Withdrawals::into_inner))
.flatten(); .flatten();
Block { Block { header, uncles, transactions, size: Some(U256::from(block_length)), withdrawals }
header,
uncles,
transactions,
size: Some(U256::from(block_length)),
withdrawals,
other: Default::default(),
}
} }
/// Build an RPC block response representing /// Build an RPC block response representing
/// an Uncle from its header. /// an Uncle from its header.
pub fn uncle_block_from_header(header: PrimitiveHeader) -> Block { pub fn uncle_block_from_header(header: PrimitiveHeader) -> Block<WithOtherFields<Transaction>> {
let hash = header.hash_slow(); let hash = header.hash_slow();
let rpc_header = from_primitive_with_hash(header.clone().seal(hash)); let rpc_header = from_primitive_with_hash(header.clone().seal(hash));
let uncle_block = PrimitiveBlock { header, ..Default::default() }; let uncle_block = PrimitiveBlock { header, ..Default::default() };
@ -192,6 +187,5 @@ pub fn uncle_block_from_header(header: PrimitiveHeader) -> Block {
transactions: BlockTransactions::Uncle, transactions: BlockTransactions::Uncle,
withdrawals: Some(vec![]), withdrawals: Some(vec![]),
size, size,
other: Default::default(),
} }
} }

View File

@ -5,7 +5,7 @@ use alloy_rpc_types::{
TransactionInfo, TransactionInfo,
}; };
use reth_primitives::{Address, TransactionSignedEcRecovered, TxKind, TxType}; use reth_primitives::{Address, TransactionSignedEcRecovered, TxKind, TxType};
use reth_rpc_types::Transaction; use reth_rpc_types::{Transaction, WithOtherFields};
use signature::from_primitive_signature; use signature::from_primitive_signature;
pub use typed::*; pub use typed::*;
@ -17,19 +17,22 @@ mod typed;
pub fn from_recovered_with_block_context( pub fn from_recovered_with_block_context(
tx: TransactionSignedEcRecovered, tx: TransactionSignedEcRecovered,
tx_info: TransactionInfo, tx_info: TransactionInfo,
) -> Transaction { ) -> WithOtherFields<Transaction> {
fill(tx, tx_info) fill(tx, tx_info)
} }
/// Create a new rpc transaction result for a _pending_ signed transaction, setting block /// Create a new rpc transaction result for a _pending_ signed transaction, setting block
/// environment related fields to `None`. /// environment related fields to `None`.
pub fn from_recovered(tx: TransactionSignedEcRecovered) -> Transaction { pub fn from_recovered(tx: TransactionSignedEcRecovered) -> WithOtherFields<Transaction> {
fill(tx, TransactionInfo::default()) fill(tx, TransactionInfo::default())
} }
/// Create a new rpc transaction result for a _pending_ signed transaction, setting block /// Create a new rpc transaction result for a _pending_ signed transaction, setting block
/// environment related fields to `None`. /// environment related fields to `None`.
fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transaction { fn fill(
tx: TransactionSignedEcRecovered,
tx_info: TransactionInfo,
) -> WithOtherFields<Transaction> {
let signer = tx.signer(); let signer = tx.signer();
let signed_tx = tx.into_signed(); let signed_tx = tx.into_signed();
@ -41,7 +44,7 @@ fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transacti
#[allow(unreachable_patterns)] #[allow(unreachable_patterns)]
let (gas_price, max_fee_per_gas) = match signed_tx.tx_type() { let (gas_price, max_fee_per_gas) = match signed_tx.tx_type() {
TxType::Legacy | TxType::Eip2930 => (Some(signed_tx.max_fee_per_gas()), None), TxType::Legacy | TxType::Eip2930 => (Some(signed_tx.max_fee_per_gas()), None),
TxType::Eip1559 | TxType::Eip4844 => { TxType::Eip1559 | TxType::Eip4844 | TxType::Eip7702 => {
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) + // the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
// baseFee` // baseFee`
let gas_price = tx_info let gas_price = tx_info
@ -68,30 +71,32 @@ fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transacti
let signature = let signature =
from_primitive_signature(*signed_tx.signature(), signed_tx.tx_type(), signed_tx.chain_id()); from_primitive_signature(*signed_tx.signature(), signed_tx.tx_type(), signed_tx.chain_id());
Transaction { WithOtherFields {
hash: signed_tx.hash(), inner: Transaction {
nonce: signed_tx.nonce(), hash: signed_tx.hash(),
from: signer, nonce: signed_tx.nonce(),
to, from: signer,
value: signed_tx.value(), to,
gas_price, value: signed_tx.value(),
max_fee_per_gas, gas_price,
max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas(), max_fee_per_gas,
signature: Some(signature), max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas(),
gas: signed_tx.gas_limit() as u128, signature: Some(signature),
input: signed_tx.input().clone(), gas: signed_tx.gas_limit() as u128,
chain_id, input: signed_tx.input().clone(),
access_list, chain_id,
transaction_type: Some(signed_tx.tx_type() as u8), access_list,
transaction_type: Some(signed_tx.tx_type() as u8),
// These fields are set to None because they are not stored as part of the transaction // These fields are set to None because they are not stored as part of the transaction
block_hash: tx_info.block_hash, block_hash: tx_info.block_hash,
block_number: tx_info.block_number, block_number: tx_info.block_number,
transaction_index: tx_info.index, transaction_index: tx_info.index,
// EIP-4844 fields // EIP-4844 fields
max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas(), max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas(),
blob_versioned_hashes, blob_versioned_hashes,
authorization_list, // EIP-7702 fields
authorization_list,
},
// Optimism fields // Optimism fields
#[cfg(feature = "optimism")] #[cfg(feature = "optimism")]
other: reth_rpc_types::optimism::OptimismTransactionFields { other: reth_rpc_types::optimism::OptimismTransactionFields {
@ -100,6 +105,7 @@ fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transacti
// only include is_system_tx if true: <https://github.com/ethereum-optimism/op-geth/blob/641e996a2dcf1f81bac9416cb6124f86a69f1de7/internal/ethapi/api.go#L1518-L1518> // only include is_system_tx if true: <https://github.com/ethereum-optimism/op-geth/blob/641e996a2dcf1f81bac9416cb6124f86a69f1de7/internal/ethapi/api.go#L1518-L1518>
is_system_tx: (signed_tx.is_deposit() && signed_tx.is_system_transaction()) is_system_tx: (signed_tx.is_deposit() && signed_tx.is_system_transaction())
.then_some(true), .then_some(true),
deposit_receipt_version: None,
} }
.into(), .into(),
#[cfg(not(feature = "optimism"))] #[cfg(not(feature = "optimism"))]
@ -118,7 +124,7 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact
let chain_id = tx.transaction.chain_id(); let chain_id = tx.transaction.chain_id();
let access_list = tx.transaction.access_list().cloned(); let access_list = tx.transaction.access_list().cloned();
let max_fee_per_blob_gas = tx.transaction.max_fee_per_blob_gas(); let max_fee_per_blob_gas = tx.transaction.max_fee_per_blob_gas();
let _authorization_list = tx.transaction.authorization_list(); let authorization_list = tx.transaction.authorization_list().map(|l| l.to_vec());
let blob_versioned_hashes = tx.transaction.blob_versioned_hashes(); let blob_versioned_hashes = tx.transaction.blob_versioned_hashes();
let tx_type = tx.transaction.tx_type(); let tx_type = tx.transaction.tx_type();
@ -146,5 +152,6 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact
blob_versioned_hashes, blob_versioned_hashes,
transaction_type: Some(tx_type.into()), transaction_type: Some(tx_type.into()),
sidecar: None, sidecar: None,
authorization_list,
} }
} }

View File

@ -25,6 +25,10 @@ alloy-rpc-types-txpool.workspace = true
alloy-serde.workspace = true alloy-serde.workspace = true
alloy-rpc-types-engine = { workspace = true, features = ["jsonrpsee-types"], optional = true } alloy-rpc-types-engine = { workspace = true, features = ["jsonrpsee-types"], optional = true }
# optimism
op-alloy-rpc-types.workspace = true
op-alloy-rpc-types-engine.workspace = true
# misc # misc
jsonrpsee-types = { workspace = true, optional = true } jsonrpsee-types = { workspace = true, optional = true }
@ -41,6 +45,6 @@ jsonrpsee-types = [
"dep:alloy-rpc-types-beacon", "dep:alloy-rpc-types-beacon",
"dep:alloy-rpc-types-engine", "dep:alloy-rpc-types-engine",
"alloy-rpc-types/jsonrpsee-types", "alloy-rpc-types/jsonrpsee-types",
"alloy-rpc-types-engine/jsonrpsee-types" "alloy-rpc-types-engine/jsonrpsee-types",
] ]
arbitrary = ["alloy-primitives/arbitrary", "alloy-rpc-types/arbitrary"] arbitrary = ["alloy-primitives/arbitrary", "alloy-rpc-types/arbitrary"]

View File

@ -57,3 +57,9 @@ pub use eth::{
ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError, ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError,
}, },
}; };
/// Optimism specific rpc types.
pub mod optimism {
pub use op_alloy_rpc_types::*;
pub use op_alloy_rpc_types_engine::*;
}

View File

@ -7,7 +7,7 @@ pub use reth_rpc_engine_api::EngineApi;
use reth_rpc_eth_api::{EthApiTypes, RpcBlock, RpcTransaction}; use reth_rpc_eth_api::{EthApiTypes, RpcBlock, RpcTransaction};
use reth_rpc_types::{ use reth_rpc_types::{
state::StateOverride, BlockOverrides, EIP1186AccountProofResponse, Filter, JsonStorageKey, Log, state::StateOverride, BlockOverrides, EIP1186AccountProofResponse, Filter, JsonStorageKey, Log,
SyncStatus, TransactionRequest, SyncStatus, TransactionRequest, WithOtherFields,
}; };
use tracing_futures::Instrument; use tracing_futures::Instrument;
@ -33,15 +33,16 @@ impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl<Eth, EthFilter> impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>>
EngineEthApiServer< for EngineEthApi<Eth, EthFilter>
reth_rpc_types::Transaction,
reth_rpc_types::Block<reth_rpc_types::Transaction>,
> for EngineEthApi<Eth, EthFilter>
where where
Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>> Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>>
+ EthApiTypes<NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>>, + EthApiTypes<
EthFilter: EthFilterApiServer<reth_rpc_types::Transaction>, NetworkTypes: Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
>,
EthFilter: EthFilterApiServer<RpcTransaction<Eth::NetworkTypes>>,
{ {
/// Handler for: `eth_syncing` /// Handler for: `eth_syncing`
fn syncing(&self) -> Result<SyncStatus> { fn syncing(&self) -> Result<SyncStatus> {

View File

@ -3,7 +3,7 @@
use std::sync::Arc; use std::sync::Arc;
use alloy_network::Ethereum; use alloy_network::AnyNetwork;
use derive_more::Deref; use derive_more::Deref;
use reth_node_api::{BuilderProvider, FullNodeComponents}; use reth_node_api::{BuilderProvider, FullNodeComponents};
use reth_primitives::{BlockNumberOrTag, U256}; use reth_primitives::{BlockNumberOrTag, U256};
@ -123,7 +123,7 @@ where
Self: Send + Sync, Self: Send + Sync,
{ {
type Error = EthApiError; type Error = EthApiError;
type NetworkTypes = Ethereum; type NetworkTypes = AnyNetwork;
} }
impl<Provider, Pool, Network, EvmConfig> std::fmt::Debug impl<Provider, Pool, Network, EvmConfig> std::fmt::Debug

View File

@ -22,7 +22,7 @@ use reth_rpc_eth_types::{
use reth_rpc_server_types::ToRpcResult; use reth_rpc_server_types::ToRpcResult;
use reth_rpc_types::{ use reth_rpc_types::{
BlockNumHash, Filter, FilterBlockOption, FilterChanges, FilterId, FilteredParams, Log, BlockNumHash, Filter, FilterBlockOption, FilterChanges, FilterId, FilteredParams, Log,
PendingTransactionFilterKind, PendingTransactionFilterKind, Transaction, WithOtherFields,
}; };
use reth_tasks::TaskSpawner; use reth_tasks::TaskSpawner;
use reth_transaction_pool::{NewSubpoolTransactionStream, PoolTransaction, TransactionPool}; use reth_transaction_pool::{NewSubpoolTransactionStream, PoolTransaction, TransactionPool};
@ -132,7 +132,10 @@ where
<Pool as TransactionPool>::Transaction: 'static, <Pool as TransactionPool>::Transaction: 'static,
{ {
/// Returns all the filter changes for the given id, if any /// Returns all the filter changes for the given id, if any
pub async fn filter_changes(&self, id: FilterId) -> Result<FilterChanges, EthFilterError> { pub async fn filter_changes(
&self,
id: FilterId,
) -> Result<FilterChanges<WithOtherFields<Transaction>>, EthFilterError> {
let info = self.inner.provider.chain_info()?; let info = self.inner.provider.chain_info()?;
let best_number = info.best_number; let best_number = info.best_number;
@ -222,7 +225,7 @@ where
} }
#[async_trait] #[async_trait]
impl<Provider, Pool> EthFilterApiServer<reth_rpc_types::Transaction> for EthFilter<Provider, Pool> impl<Provider, Pool> EthFilterApiServer<WithOtherFields<Transaction>> for EthFilter<Provider, Pool>
where where
Provider: BlockReader + BlockIdReader + EvmEnvProvider + 'static, Provider: BlockReader + BlockIdReader + EvmEnvProvider + 'static,
Pool: TransactionPool + 'static, Pool: TransactionPool + 'static,
@ -268,7 +271,10 @@ where
} }
/// Handler for `eth_getFilterChanges` /// Handler for `eth_getFilterChanges`
async fn filter_changes(&self, id: FilterId) -> RpcResult<FilterChanges> { async fn filter_changes(
&self,
id: FilterId,
) -> RpcResult<FilterChanges<WithOtherFields<Transaction>>> {
trace!(target: "rpc::eth", "Serving eth_getFilterChanges"); trace!(target: "rpc::eth", "Serving eth_getFilterChanges");
Ok(Self::filter_changes(self, id).await?) Ok(Self::filter_changes(self, id).await?)
} }
@ -547,7 +553,7 @@ impl PendingTransactionsReceiver {
} }
/// Returns all new pending transactions received since the last poll. /// Returns all new pending transactions received since the last poll.
async fn drain(&self) -> FilterChanges { async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>> {
let mut pending_txs = Vec::new(); let mut pending_txs = Vec::new();
let mut prepared_stream = self.txs_receiver.lock().await; let mut prepared_stream = self.txs_receiver.lock().await;
@ -576,7 +582,7 @@ where
} }
/// Returns all new pending transactions received since the last poll. /// Returns all new pending transactions received since the last poll.
async fn drain(&self) -> FilterChanges async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>>
where where
T: PoolTransaction<Consensus = TransactionSignedEcRecovered>, T: PoolTransaction<Consensus = TransactionSignedEcRecovered>,
{ {
@ -595,7 +601,7 @@ where
/// Helper trait for [FullTransactionsReceiver] to erase the `Transaction` type. /// Helper trait for [FullTransactionsReceiver] to erase the `Transaction` type.
#[async_trait] #[async_trait]
trait FullTransactionsFilter: fmt::Debug + Send + Sync + Unpin + 'static { trait FullTransactionsFilter: fmt::Debug + Send + Sync + Unpin + 'static {
async fn drain(&self) -> FilterChanges; async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>>;
} }
#[async_trait] #[async_trait]
@ -603,7 +609,7 @@ impl<T> FullTransactionsFilter for FullTransactionsReceiver<T>
where where
T: PoolTransaction<Consensus = TransactionSignedEcRecovered> + 'static, T: PoolTransaction<Consensus = TransactionSignedEcRecovered> + 'static,
{ {
async fn drain(&self) -> FilterChanges { async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>> {
Self::drain(self).await Self::drain(self).await
} }
} }
@ -620,7 +626,7 @@ enum PendingTransactionKind {
} }
impl PendingTransactionKind { impl PendingTransactionKind {
async fn drain(&self) -> FilterChanges { async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>> {
match self { match self {
Self::Hashes(receiver) => receiver.drain().await, Self::Hashes(receiver) => receiver.drain().await,
Self::FullTransaction(receiver) => receiver.drain().await, Self::FullTransaction(receiver) => receiver.drain().await,

View File

@ -17,7 +17,7 @@ use reth_rpc_types::{
Params, PubSubSyncStatus, SubscriptionKind, SubscriptionResult as EthSubscriptionResult, Params, PubSubSyncStatus, SubscriptionKind, SubscriptionResult as EthSubscriptionResult,
SyncStatusMetadata, SyncStatusMetadata,
}, },
FilteredParams, Header, Log, FilteredParams, Header, Log, Transaction, WithOtherFields,
}; };
use reth_tasks::{TaskSpawner, TokioTaskExecutor}; use reth_tasks::{TaskSpawner, TokioTaskExecutor};
use reth_transaction_pool::{NewTransactionEvent, TransactionPool}; use reth_transaction_pool::{NewTransactionEvent, TransactionPool};
@ -108,9 +108,11 @@ where
{ {
match kind { match kind {
SubscriptionKind::NewHeads => { SubscriptionKind::NewHeads => {
let stream = pubsub let stream = pubsub.new_headers_stream().map(|header| {
.new_headers_stream() EthSubscriptionResult::<WithOtherFields<Transaction>>::Header(Box::new(
.map(|block| EthSubscriptionResult::Header(Box::new(block.into()))); header.into(),
))
});
pipe_from_stream(accepted_sink, stream).await pipe_from_stream(accepted_sink, stream).await
} }
SubscriptionKind::Logs => { SubscriptionKind::Logs => {
@ -122,8 +124,9 @@ where
} }
_ => FilteredParams::default(), _ => FilteredParams::default(),
}; };
let stream = let stream = pubsub.log_stream(filter).map(|log| {
pubsub.log_stream(filter).map(|log| EthSubscriptionResult::Log(Box::new(log))); EthSubscriptionResult::<WithOtherFields<Transaction>>::Log(Box::new(log))
});
pipe_from_stream(accepted_sink, stream).await pipe_from_stream(accepted_sink, stream).await
} }
SubscriptionKind::NewPendingTransactions => { SubscriptionKind::NewPendingTransactions => {
@ -153,7 +156,7 @@ where
let stream = pubsub let stream = pubsub
.pending_transaction_hashes_stream() .pending_transaction_hashes_stream()
.map(EthSubscriptionResult::TransactionHash); .map(EthSubscriptionResult::<WithOtherFields<Transaction>>::TransactionHash);
pipe_from_stream(accepted_sink, stream).await pipe_from_stream(accepted_sink, stream).await
} }
SubscriptionKind::Syncing => { SubscriptionKind::Syncing => {

View File

@ -15,7 +15,7 @@ use reth_rpc_types::{
}, },
parity::{Action, CreateAction, CreateOutput, TraceOutput}, parity::{Action, CreateAction, CreateOutput, TraceOutput},
}, },
AnyTransactionReceipt, BlockTransactions, Header, Rich, AnyTransactionReceipt, BlockTransactions, Header, Transaction, WithOtherFields,
}; };
use revm_inspectors::{ use revm_inspectors::{
tracing::{types::CallTraceNode, TracingInspectorConfig}, tracing::{types::CallTraceNode, TracingInspectorConfig},
@ -40,7 +40,9 @@ impl<Eth> OtterscanApi<Eth> {
impl<Eth> OtterscanApi<Eth> impl<Eth> OtterscanApi<Eth>
where where
Eth: EthApiTypes<NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>>, Eth: EthApiTypes<
NetworkTypes: Network<TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>>,
>,
{ {
/// Constructs a `BlockDetails` from a block and its receipts. /// Constructs a `BlockDetails` from a block and its receipts.
fn block_details( fn block_details(
@ -57,11 +59,7 @@ where
.map(|receipt| receipt.gas_used.saturating_mul(receipt.effective_gas_price)) .map(|receipt| receipt.gas_used.saturating_mul(receipt.effective_gas_price))
.sum::<u128>(); .sum::<u128>();
Ok(BlockDetails::new( Ok(BlockDetails::new(block, Default::default(), U256::from(total_fees)))
Rich { inner: block, extra_info: Default::default() },
Default::default(),
U256::from(total_fees),
))
} }
} }
@ -69,8 +67,11 @@ where
impl<Eth> OtterscanServer for OtterscanApi<Eth> impl<Eth> OtterscanServer for OtterscanApi<Eth>
where where
Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>> Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>>
+ EthApiTypes<NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>> + EthApiTypes<
+ TraceExt NetworkTypes: Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
>,
> + TraceExt
+ 'static, + 'static,
{ {
/// Handler for `{ots,erigon}_getHeaderByNumber` /// Handler for `{ots,erigon}_getHeaderByNumber`
@ -187,7 +188,7 @@ where
block_number: u64, block_number: u64,
page_number: usize, page_number: usize,
page_size: usize, page_size: usize,
) -> RpcResult<OtsBlockTransactions> { ) -> RpcResult<OtsBlockTransactions<WithOtherFields<Transaction>>> {
// retrieve full block and its receipts // retrieve full block and its receipts
let block = self.eth.block_by_number(block_number.into(), true); let block = self.eth.block_by_number(block_number.into(), true);
let receipts = self.eth.block_receipts(block_number.into()); let receipts = self.eth.block_receipts(block_number.into());

View File

@ -4,7 +4,7 @@ use reth_primitives::{Address, TransactionSignedEcRecovered};
use reth_rpc_api::TxPoolApiServer; use reth_rpc_api::TxPoolApiServer;
use reth_rpc_types::{ use reth_rpc_types::{
txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus}, txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus},
Transaction, Transaction, WithOtherFields,
}; };
use reth_transaction_pool::{AllPoolTransactions, PoolTransaction, TransactionPool}; use reth_transaction_pool::{AllPoolTransactions, PoolTransaction, TransactionPool};
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -30,11 +30,11 @@ impl<Pool> TxPoolApi<Pool>
where where
Pool: TransactionPool + 'static, Pool: TransactionPool + 'static,
{ {
fn content(&self) -> TxpoolContent { fn content(&self) -> TxpoolContent<WithOtherFields<Transaction>> {
#[inline] #[inline]
fn insert<T: PoolTransaction<Consensus = TransactionSignedEcRecovered>>( fn insert<T: PoolTransaction<Consensus = TransactionSignedEcRecovered>>(
tx: &T, tx: &T,
content: &mut BTreeMap<Address, BTreeMap<String, Transaction>>, content: &mut BTreeMap<Address, BTreeMap<String, WithOtherFields<Transaction>>>,
) { ) {
content.entry(tx.sender()).or_default().insert( content.entry(tx.sender()).or_default().insert(
tx.nonce().to_string(), tx.nonce().to_string(),
@ -118,7 +118,10 @@ where
/// ///
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details /// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details
/// Handler for `txpool_contentFrom` /// Handler for `txpool_contentFrom`
async fn txpool_content_from(&self, from: Address) -> Result<TxpoolContentFrom> { async fn txpool_content_from(
&self,
from: Address,
) -> Result<TxpoolContentFrom<WithOtherFields<Transaction>>> {
trace!(target: "rpc::eth", ?from, "Serving txpool_contentFrom"); trace!(target: "rpc::eth", ?from, "Serving txpool_contentFrom");
Ok(self.content().remove_from(&from)) Ok(self.content().remove_from(&from))
} }
@ -128,7 +131,7 @@ where
/// ///
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details /// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_content) for more details
/// Handler for `txpool_content` /// Handler for `txpool_content`
async fn txpool_content(&self) -> Result<TxpoolContent> { async fn txpool_content(&self) -> Result<TxpoolContent<WithOtherFields<Transaction>>> {
trace!(target: "rpc::eth", "Serving txpool_content"); trace!(target: "rpc::eth", "Serving txpool_content");
Ok(self.content()) Ok(self.content())
} }

View File

@ -2,7 +2,7 @@ use core::ops::Deref;
use crate::Compact; use crate::Compact;
use alloy_eips::eip7702::{Authorization as AlloyAuthorization, SignedAuthorization}; use alloy_eips::eip7702::{Authorization as AlloyAuthorization, SignedAuthorization};
use alloy_primitives::{Address, ChainId, U256}; use alloy_primitives::{Address, U256};
use bytes::Buf; use bytes::Buf;
use reth_codecs_derive::add_arbitrary_tests; use reth_codecs_derive::add_arbitrary_tests;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -14,9 +14,9 @@ use serde::{Deserialize, Serialize};
#[cfg_attr(test, derive(arbitrary::Arbitrary))] #[cfg_attr(test, derive(arbitrary::Arbitrary))]
#[add_arbitrary_tests(compact)] #[add_arbitrary_tests(compact)]
struct Authorization { struct Authorization {
chain_id: ChainId, chain_id: U256,
address: Address, address: Address,
nonce: Option<u64>, nonce: u64,
} }
impl Compact for AlloyAuthorization { impl Compact for AlloyAuthorization {
@ -34,7 +34,7 @@ impl Compact for AlloyAuthorization {
let alloy_authorization = Self { let alloy_authorization = Self {
chain_id: authorization.chain_id, chain_id: authorization.chain_id,
address: authorization.address, address: authorization.address,
nonce: authorization.nonce.into(), nonce: authorization.nonce,
}; };
(alloy_authorization, buf) (alloy_authorization, buf)
} }
@ -79,9 +79,9 @@ mod tests {
#[test] #[test]
fn test_roundtrip_compact_authorization_list_item() { fn test_roundtrip_compact_authorization_list_item() {
let authorization = AlloyAuthorization { let authorization = AlloyAuthorization {
chain_id: 1, chain_id: U256::from(1),
address: address!("dac17f958d2ee523a2206206994597c13d831ec7"), address: address!("dac17f958d2ee523a2206206994597c13d831ec7"),
nonce: None.into(), nonce: 1,
} }
.into_signed( .into_signed(
alloy_primitives::Signature::from_rs_and_parity( alloy_primitives::Signature::from_rs_and_parity(