mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(deps): bump alloy (#10537)
Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
530
Cargo.lock
generated
530
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
69
Cargo.toml
69
Cargo.toml
@ -395,59 +395,60 @@ reth-trie-db = { path = "crates/trie/db" }
|
||||
reth-trie-parallel = { path = "crates/trie/parallel" }
|
||||
|
||||
# revm
|
||||
revm = { version = "13.0.0", features = [
|
||||
revm = { version = "14.0.0", features = [
|
||||
"std",
|
||||
"secp256k1",
|
||||
"blst",
|
||||
], default-features = false }
|
||||
revm-inspectors = "0.5"
|
||||
revm-primitives = { version = "8.0.0", features = [
|
||||
revm-inspectors = "0.6"
|
||||
revm-primitives = { version = "9.0.0", features = [
|
||||
"std",
|
||||
], default-features = false }
|
||||
|
||||
# eth
|
||||
alloy-chains = "0.1.18"
|
||||
alloy-dyn-abi = "0.7.2"
|
||||
alloy-primitives = { version = "0.7.2", default-features = false }
|
||||
alloy-dyn-abi = "0.8.0"
|
||||
alloy-primitives = { version = "0.8.0", default-features = false }
|
||||
alloy-rlp = "0.3.4"
|
||||
alloy-sol-types = "0.7.2"
|
||||
alloy-trie = { version = "0.4", default-features = false }
|
||||
alloy-sol-types = "0.8.0"
|
||||
alloy-trie = { version = "0.5", default-features = false }
|
||||
|
||||
alloy-consensus = { version = "0.2.1", default-features = false }
|
||||
alloy-eips = { version = "0.2.1", default-features = false }
|
||||
alloy-genesis = { version = "0.2.1", default-features = false }
|
||||
alloy-json-rpc = { version = "0.2.1", default-features = false }
|
||||
alloy-network = { version = "0.2.1", default-features = false }
|
||||
alloy-node-bindings = { version = "0.2.1", default-features = false }
|
||||
alloy-provider = { version = "0.2.1", features = [
|
||||
alloy-consensus = { version = "0.3.0", default-features = false }
|
||||
alloy-eips = { version = "0.3.0", default-features = false }
|
||||
alloy-genesis = { version = "0.3.0", default-features = false }
|
||||
alloy-json-rpc = { version = "0.3.0", default-features = false }
|
||||
alloy-network = { version = "0.3.0", default-features = false }
|
||||
alloy-node-bindings = { version = "0.3.0", default-features = false }
|
||||
alloy-provider = { version = "0.3.0", features = [
|
||||
"reqwest",
|
||||
], default-features = false }
|
||||
alloy-pubsub = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-client = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types = { version = "0.2.1", features = [
|
||||
alloy-pubsub = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-client = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types = { version = "0.3.0", features = [
|
||||
"eth",
|
||||
], default-features = false }
|
||||
alloy-rpc-types-admin = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-anvil = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-beacon = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-engine = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-eth = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-mev = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-trace = { version = "0.2.1", default-features = false }
|
||||
alloy-rpc-types-txpool = { version = "0.2.1", default-features = false }
|
||||
alloy-serde = { version = "0.2.1", default-features = false }
|
||||
alloy-signer = { version = "0.2.1", default-features = false }
|
||||
alloy-signer-local = { version = "0.2.1", default-features = false }
|
||||
alloy-transport = { version = "0.2.1" }
|
||||
alloy-transport-http = { version = "0.2.1", features = [
|
||||
alloy-rpc-types-admin = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-anvil = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-beacon = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-engine = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-eth = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-mev = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-trace = { version = "0.3.0", default-features = false }
|
||||
alloy-rpc-types-txpool = { version = "0.3.0", default-features = false }
|
||||
alloy-serde = { version = "0.3.0", default-features = false }
|
||||
alloy-signer = { version = "0.3.0", default-features = false }
|
||||
alloy-signer-local = { version = "0.3.0", default-features = false }
|
||||
alloy-transport = { version = "0.3.0" }
|
||||
alloy-transport-http = { version = "0.3.0", features = [
|
||||
"reqwest-rustls-tls",
|
||||
], default-features = false }
|
||||
alloy-transport-ipc = { version = "0.2.1", default-features = false }
|
||||
alloy-transport-ws = { version = "0.2.1", default-features = false }
|
||||
alloy-transport-ipc = { version = "0.3.0", default-features = false }
|
||||
alloy-transport-ws = { version = "0.3.0", default-features = false }
|
||||
|
||||
# op
|
||||
op-alloy-rpc-types = "0.1"
|
||||
op-alloy-network = "0.1"
|
||||
op-alloy-rpc-types = "0.2"
|
||||
op-alloy-rpc-types-engine = "0.2"
|
||||
op-alloy-network = "0.2"
|
||||
|
||||
# misc
|
||||
aquamarine = "0.5"
|
||||
|
||||
@ -3,10 +3,7 @@
|
||||
|
||||
use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode};
|
||||
use alloy_eips::BlockNumberOrTag;
|
||||
use alloy_provider::{
|
||||
network::{AnyNetwork, Ethereum},
|
||||
Provider, ProviderBuilder, RootProvider,
|
||||
};
|
||||
use alloy_provider::{network::AnyNetwork, Provider, ProviderBuilder, RootProvider};
|
||||
use alloy_rpc_client::ClientBuilder;
|
||||
use alloy_rpc_types_engine::JwtSecret;
|
||||
use alloy_transport::BoxTransport;
|
||||
@ -24,7 +21,7 @@ pub(crate) struct BenchContext {
|
||||
/// The auth provider used for engine API queries.
|
||||
pub(crate) auth_provider: RootProvider<BoxTransport, AnyNetwork>,
|
||||
/// 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
|
||||
/// range of blocks.
|
||||
pub(crate) benchmark_mode: BenchMode,
|
||||
@ -46,7 +43,8 @@ impl BenchContext {
|
||||
}
|
||||
|
||||
// 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,
|
||||
// starting at the latest block.
|
||||
@ -95,17 +93,7 @@ impl BenchContext {
|
||||
}
|
||||
};
|
||||
|
||||
let next_block = match first_block.header.number {
|
||||
Some(number) => {
|
||||
// fetch next block
|
||||
number + 1
|
||||
}
|
||||
None => {
|
||||
// this should never happen
|
||||
return Err(eyre::eyre!("First block number is None"));
|
||||
}
|
||||
};
|
||||
|
||||
let next_block = first_block.header.number + 1;
|
||||
Ok(Self { auth_provider, block_provider, benchmark_mode, next_block })
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,17 +45,8 @@ impl Command {
|
||||
while benchmark_mode.contains(next_block) {
|
||||
let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
|
||||
let block = block_res.unwrap().unwrap();
|
||||
let block = match block.header.hash {
|
||||
Some(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 block_hash = block.header.hash;
|
||||
let block = Block::try_from(block.inner).unwrap().seal(block_hash);
|
||||
let head_block_hash = block.hash();
|
||||
let safe_block_hash = block_provider
|
||||
.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_block_hash = safe
|
||||
.unwrap()
|
||||
.expect("finalized block exists")
|
||||
.header
|
||||
.hash
|
||||
.expect("finalized block has hash");
|
||||
let finalized_block_hash = finalized
|
||||
.unwrap()
|
||||
.expect("finalized block exists")
|
||||
.header
|
||||
.hash
|
||||
.expect("finalized block has hash");
|
||||
let safe_block_hash = safe.unwrap().expect("finalized block exists").header.hash;
|
||||
let finalized_block_hash =
|
||||
finalized.unwrap().expect("finalized block exists").header.hash;
|
||||
|
||||
next_block += 1;
|
||||
sender
|
||||
|
||||
@ -45,16 +45,8 @@ impl Command {
|
||||
while benchmark_mode.contains(next_block) {
|
||||
let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
|
||||
let block = block_res.unwrap().unwrap();
|
||||
let block = match block.header.hash {
|
||||
Some(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 block_hash = block.header.hash;
|
||||
let block = Block::try_from(block.inner).unwrap().seal(block_hash);
|
||||
|
||||
next_block += 1;
|
||||
sender.send(block).await.unwrap();
|
||||
|
||||
@ -224,7 +224,7 @@ impl Command {
|
||||
#[cfg(feature = "optimism")]
|
||||
reth_node_optimism::OptimismPayloadBuilderAttributes::try_new(
|
||||
best_block.hash(),
|
||||
reth_rpc_types::engine::OptimismPayloadAttributes {
|
||||
reth_rpc_types::optimism::OptimismPayloadAttributes {
|
||||
payload_attributes: payload_attrs,
|
||||
transactions: None,
|
||||
no_tx_pool: None,
|
||||
|
||||
@ -47,7 +47,7 @@ pub trait BlockProvider: Send + Sync + 'static {
|
||||
None => return Ok(B256::default()),
|
||||
};
|
||||
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,
|
||||
logs_bloom: block.header.logs_bloom,
|
||||
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_used: block.header.gas_used.try_into().unwrap(),
|
||||
timestamp: block.header.timestamp,
|
||||
extra_data: block.header.extra_data.clone(),
|
||||
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
|
||||
.into_iter()
|
||||
.map(|tx| {
|
||||
|
||||
@ -63,7 +63,7 @@ impl BlockProvider for EtherscanBlockProvider {
|
||||
continue
|
||||
}
|
||||
};
|
||||
let block_number = block.header.number.unwrap();
|
||||
let block_number = block.header.number;
|
||||
if Some(block_number) == last_block_number {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ impl BlockProvider for RpcBlockProvider {
|
||||
|
||||
while let Some(block) = stream.next().await {
|
||||
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
|
||||
.expect("failed to get block")
|
||||
.expect("block not found");
|
||||
|
||||
@ -59,7 +59,9 @@ where
|
||||
N::AddOns: NodeAddOns<
|
||||
Adapter<N>,
|
||||
EthApi: FullEthApiServer<
|
||||
NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>,
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = reth_rpc_types::WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
> + AddDevSigners
|
||||
+ EthApiBuilderProvider<Adapter<N>>,
|
||||
>,
|
||||
|
||||
@ -17,6 +17,7 @@ use reth::{
|
||||
};
|
||||
use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypes};
|
||||
use reth_primitives::{BlockHash, BlockNumber, Bytes, B256};
|
||||
use reth_rpc_types::WithOtherFields;
|
||||
use reth_stages_types::StageId;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
@ -94,7 +95,7 @@ where
|
||||
From<<Node::Engine as PayloadTypes>::BuiltPayload> + PayloadEnvelopeExt,
|
||||
AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt,
|
||||
<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);
|
||||
for i in 0..length {
|
||||
|
||||
@ -9,6 +9,7 @@ use reth::{
|
||||
};
|
||||
use reth_node_builder::EthApiTypes;
|
||||
use reth_primitives::{Bytes, B256};
|
||||
use reth_rpc_types::WithOtherFields;
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {
|
||||
@ -19,8 +20,11 @@ impl<Node, EthApi> RpcTestContext<Node, EthApi>
|
||||
where
|
||||
Node: FullNodeComponents,
|
||||
EthApi: EthApiSpec
|
||||
+ EthTransactions<NetworkTypes: Network<TransactionResponse = alloy_rpc_types::Transaction>>
|
||||
+ TraceExt,
|
||||
+ EthTransactions<
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>,
|
||||
>,
|
||||
> + TraceExt,
|
||||
{
|
||||
/// 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> {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use reth::rpc::types::{
|
||||
engine::{ExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV3},
|
||||
engine::ExecutionPayloadEnvelopeV3, optimism::OptimismExecutionPayloadEnvelopeV3,
|
||||
ExecutionPayloadV3,
|
||||
};
|
||||
|
||||
|
||||
@ -203,9 +203,6 @@ mod tests {
|
||||
// Ensure that the logs database 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
|
||||
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
|
||||
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
|
||||
assert_eq!(evm.handler.cfg, HandlerCfg { spec_id: SpecId::LATEST, ..Default::default() });
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
pub mod add_ons;
|
||||
mod states;
|
||||
|
||||
use reth_rpc_types::WithOtherFields;
|
||||
pub use states::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
@ -330,7 +331,7 @@ where
|
||||
>
|
||||
+ FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<
|
||||
TransactionResponse = reth_rpc_types::Transaction
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
>
|
||||
+ AddDevSigners
|
||||
@ -479,7 +480,9 @@ where
|
||||
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>
|
||||
+ FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>,
|
||||
NetworkTypes: alloy_network::Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
{
|
||||
|
||||
@ -27,7 +27,7 @@ use reth_node_core::{
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_provider::providers::BlockchainProvider2;
|
||||
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_tokio_util::EventSender;
|
||||
use reth_tracing::tracing::{debug, error, info};
|
||||
@ -67,7 +67,9 @@ where
|
||||
NodeAdapter<T, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
|
||||
+ FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>,
|
||||
NetworkTypes: alloy_network::Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
{
|
||||
|
||||
@ -32,7 +32,7 @@ use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_primitives::format_ether;
|
||||
use reth_provider::providers::BlockchainProvider;
|
||||
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_tracing::tracing::{debug, info};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
@ -111,7 +111,9 @@ where
|
||||
NodeAdapter<T, CB::Components>,
|
||||
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
|
||||
+ FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<TransactionResponse = reth_rpc_types::Transaction>,
|
||||
NetworkTypes: alloy_network::Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
{
|
||||
|
||||
@ -21,6 +21,7 @@ use reth_rpc_builder::{
|
||||
RpcModuleBuilder, RpcRegistryInner, RpcServerHandle, TransportRpcModules,
|
||||
};
|
||||
use reth_rpc_layer::JwtSecret;
|
||||
use reth_rpc_types::WithOtherFields;
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tracing::tracing::{debug, info};
|
||||
|
||||
@ -300,7 +301,9 @@ where
|
||||
Engine: EngineApiServer<Node::Engine>,
|
||||
EthApi: EthApiBuilderProvider<Node>
|
||||
+ 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)?;
|
||||
|
||||
@ -223,9 +223,6 @@ mod tests {
|
||||
// Ensure that the logs database 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
|
||||
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
|
||||
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
|
||||
assert_eq!(evm.handler.spec_id(), SpecId::LATEST);
|
||||
|
||||
|
||||
@ -9,9 +9,10 @@ use reth_node_api::{
|
||||
};
|
||||
use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes};
|
||||
use reth_rpc_types::{
|
||||
engine::{
|
||||
ExecutionPayloadEnvelopeV2, OptimismExecutionPayloadEnvelopeV3,
|
||||
OptimismExecutionPayloadEnvelopeV4, OptimismPayloadAttributes,
|
||||
engine::ExecutionPayloadEnvelopeV2,
|
||||
optimism::{
|
||||
OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4,
|
||||
OptimismPayloadAttributes,
|
||||
},
|
||||
ExecutionPayloadV1,
|
||||
};
|
||||
|
||||
@ -15,10 +15,10 @@ use reth_primitives::{
|
||||
U256,
|
||||
};
|
||||
/// Re-export for use in downstream arguments.
|
||||
pub use reth_rpc_types::engine::OptimismPayloadAttributes;
|
||||
use reth_rpc_types::engine::{
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, OptimismExecutionPayloadEnvelopeV3,
|
||||
OptimismExecutionPayloadEnvelopeV4, PayloadId,
|
||||
pub use reth_rpc_types::optimism::OptimismPayloadAttributes;
|
||||
use reth_rpc_types::{
|
||||
engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId},
|
||||
optimism::{OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4},
|
||||
};
|
||||
use reth_rpc_types_compat::engine::payload::{
|
||||
block_to_payload_v1, block_to_payload_v3, block_to_payload_v4,
|
||||
|
||||
@ -60,7 +60,7 @@ where
|
||||
chain_id,
|
||||
blob_versioned_hashes,
|
||||
max_fee_per_blob_gas,
|
||||
// authorization_list,
|
||||
authorization_list,
|
||||
..
|
||||
} = request;
|
||||
|
||||
@ -98,7 +98,7 @@ where
|
||||
// EIP-4844 fields
|
||||
blob_hashes: blob_versioned_hashes.unwrap_or_default(),
|
||||
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() },
|
||||
};
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ use std::{fmt, sync::Arc};
|
||||
|
||||
use crate::eth::rpc::SequencerClient;
|
||||
use alloy_primitives::U256;
|
||||
use op_alloy_network::Optimism;
|
||||
use op_alloy_network::AnyNetwork;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_network_api::NetworkInfo;
|
||||
@ -107,7 +107,7 @@ where
|
||||
N: FullNodeComponents,
|
||||
{
|
||||
type Error = OpEthApiError;
|
||||
type NetworkTypes = Optimism;
|
||||
type NetworkTypes = AnyNetwork;
|
||||
}
|
||||
|
||||
impl<N> EthApiSpec for OpEthApi<N>
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_rpc_eth_api::{
|
||||
FromEthApiError,
|
||||
};
|
||||
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};
|
||||
|
||||
|
||||
@ -5,7 +5,8 @@ use reth_primitives::{
|
||||
Address, Header, SealedBlock, Withdrawals, B256, U256,
|
||||
};
|
||||
use reth_rpc_types::{
|
||||
engine::{OptimismPayloadAttributes, PayloadAttributes as EthPayloadAttributes, PayloadId},
|
||||
engine::{PayloadAttributes as EthPayloadAttributes, PayloadId},
|
||||
optimism::OptimismPayloadAttributes,
|
||||
Withdrawal,
|
||||
};
|
||||
|
||||
|
||||
@ -66,9 +66,14 @@ impl Compact for Bytecode {
|
||||
where
|
||||
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_slice(bytecode);
|
||||
buf.put_slice(bytecode.as_ref());
|
||||
let len = match &self.0 {
|
||||
RevmBytecode::LegacyRaw(_) => {
|
||||
buf.put_u8(0);
|
||||
@ -82,10 +87,13 @@ impl Compact for Bytecode {
|
||||
buf.put_slice(map);
|
||||
1 + 8 + map.len()
|
||||
}
|
||||
RevmBytecode::Eof(eof) => {
|
||||
RevmBytecode::Eof(_) => {
|
||||
buf.put_u8(3);
|
||||
buf.put_slice(eof.raw().as_ref());
|
||||
1 + eof.raw().as_ref().len()
|
||||
1
|
||||
}
|
||||
RevmBytecode::Eip7702(_) => {
|
||||
buf.put_u8(4);
|
||||
1
|
||||
}
|
||||
};
|
||||
len + bytecode.len() + 4
|
||||
@ -109,8 +117,8 @@ impl Compact for Bytecode {
|
||||
JumpTable::from_slice(buf),
|
||||
)
|
||||
}),
|
||||
3 => {
|
||||
// EOF bytecode object will be decoded from the raw bytecode
|
||||
3 | 4 => {
|
||||
// EOF and EIP-7702 bytecode objects will be decoded from the raw bytecode
|
||||
Self(RevmBytecode::new_raw(bytes))
|
||||
}
|
||||
_ => unreachable!("Junk data in database: unknown Bytecode variant"),
|
||||
|
||||
@ -32,7 +32,7 @@ impl TryFrom<RpcHeader> for Header {
|
||||
logs_bloom: header.logs_bloom,
|
||||
mix_hash: header.mix_hash.unwrap_or_default(),
|
||||
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,
|
||||
parent_beacon_block_root: header.parent_beacon_block_root,
|
||||
parent_hash: header.parent_hash,
|
||||
|
||||
@ -26,10 +26,14 @@ reth-optimism-chainspec = { workspace = true, optional = true }
|
||||
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
||||
alloy-rlp = { workspace = true, features = ["arrayvec"] }
|
||||
alloy-rpc-types = { workspace = true, optional = true }
|
||||
alloy-serde = { workspace = true, optional = true }
|
||||
alloy-genesis.workspace = true
|
||||
alloy-eips = { workspace = true, features = ["serde"] }
|
||||
alloy-consensus.workspace = true
|
||||
|
||||
# optimism
|
||||
op-alloy-rpc-types = { workspace = true, optional = true }
|
||||
|
||||
# crypto
|
||||
secp256k1 = { workspace = true, features = [
|
||||
"global-context",
|
||||
@ -103,7 +107,7 @@ optimism = [
|
||||
"revm-primitives/optimism",
|
||||
"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"]
|
||||
|
||||
[[bench]]
|
||||
|
||||
@ -7,37 +7,27 @@ use crate::{
|
||||
};
|
||||
use alloy_primitives::TxKind;
|
||||
use alloy_rlp::Error as RlpError;
|
||||
use alloy_serde::WithOtherFields;
|
||||
use op_alloy_rpc_types as _;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
let body = {
|
||||
let transactions: Result<Vec<TransactionSigned>, ConversionError> = match block
|
||||
.transactions
|
||||
{
|
||||
alloy_rpc_types::BlockTransactions::Full(transactions) => transactions
|
||||
.into_iter()
|
||||
.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::Full(transactions) => {
|
||||
transactions.into_iter().map(|tx| tx.try_into()).collect()
|
||||
}
|
||||
alloy_rpc_types::BlockTransactions::Hashes(_) |
|
||||
alloy_rpc_types::BlockTransactions::Uncle => {
|
||||
// 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;
|
||||
|
||||
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_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(|_| {
|
||||
ConversionError::Eip2718Error(Eip2718Error::UnexpectedType(
|
||||
tx.transaction_type.unwrap(),
|
||||
@ -211,9 +206,8 @@ impl TryFrom<alloy_rpc_types::Transaction> for Transaction {
|
||||
}
|
||||
#[cfg(feature = "optimism")]
|
||||
Some(TxType::Deposit) => {
|
||||
let fields = tx
|
||||
.other
|
||||
.deserialize_into::<alloy_rpc_types::optimism::OptimismTransactionFields>()
|
||||
let fields = other
|
||||
.deserialize_into::<op_alloy_rpc_types::OptimismTransactionFields>()
|
||||
.map_err(|e| ConversionError::Custom(e.to_string()))?;
|
||||
Ok(Self::Deposit(crate::transaction::TxDeposit {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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 {
|
||||
signature: tx.signature.ok_or(Self::Error::MissingSignature)?.try_into()?,
|
||||
transaction: tx.try_into()?,
|
||||
@ -337,7 +331,7 @@ mod tests {
|
||||
"v": "0x0",
|
||||
"value": "0x0"
|
||||
}"#;
|
||||
let alloy_tx: AlloyTransaction =
|
||||
let alloy_tx: WithOtherFields<AlloyTransaction> =
|
||||
serde_json::from_str(input).expect("failed to deserialize");
|
||||
|
||||
let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert");
|
||||
@ -387,7 +381,7 @@ mod tests {
|
||||
"v": "0x0",
|
||||
"value": "0x239c2e16a5ca590000"
|
||||
}"#;
|
||||
let alloy_tx: AlloyTransaction =
|
||||
let alloy_tx: WithOtherFields<AlloyTransaction> =
|
||||
serde_json::from_str(input).expect("failed to deserialize");
|
||||
|
||||
let reth_tx: Transaction = alloy_tx.try_into().expect("failed to convert");
|
||||
|
||||
@ -2,4 +2,4 @@
|
||||
|
||||
/// Re-export from `alloy_eips`.
|
||||
#[doc(inline)]
|
||||
pub use alloy_eips::eip7702::{Authorization, OptionalNonce, SignedAuthorization};
|
||||
pub use alloy_eips::eip7702::{Authorization, SignedAuthorization};
|
||||
|
||||
@ -227,7 +227,7 @@ impl From<alloy_consensus::TxType> for TxType {
|
||||
alloy_consensus::TxType::Eip2930 => Self::Eip2930,
|
||||
alloy_consensus::TxType::Eip1559 => Self::Eip1559,
|
||||
alloy_consensus::TxType::Eip4844 => Self::Eip4844,
|
||||
//alloy_consensus::TxType::Eip7702 => Self::Eip7702,
|
||||
alloy_consensus::TxType::Eip7702 => Self::Eip7702,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>
|
||||
#[cfg_attr(not(feature = "client"), rpc(server, 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.
|
||||
#[method(name = "syncing")]
|
||||
fn syncing(&self) -> RpcResult<SyncStatus>;
|
||||
|
||||
@ -5,7 +5,7 @@ use reth_rpc_types::{
|
||||
BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry,
|
||||
TransactionsWithReceipts,
|
||||
},
|
||||
Header,
|
||||
Header, Transaction, WithOtherFields,
|
||||
};
|
||||
|
||||
/// Otterscan rpc interface.
|
||||
@ -61,7 +61,7 @@ pub trait Otterscan {
|
||||
block_number: u64,
|
||||
page_number: usize,
|
||||
page_size: usize,
|
||||
) -> RpcResult<OtsBlockTransactions>;
|
||||
) -> RpcResult<OtsBlockTransactions<WithOtherFields<Transaction>>>;
|
||||
|
||||
/// Gets paginated inbound/outbound transaction calls for a certain address.
|
||||
#[method(name = "searchTransactionsBefore")]
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
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.
|
||||
#[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
|
||||
#[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
|
||||
/// 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
|
||||
#[method(name = "content")]
|
||||
async fn txpool_content(&self) -> RpcResult<TxpoolContent>;
|
||||
async fn txpool_content(&self) -> RpcResult<TxpoolContent<WithOtherFields<Transaction>>>;
|
||||
}
|
||||
|
||||
@ -169,6 +169,7 @@ use reth_rpc_eth_api::{
|
||||
};
|
||||
use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider};
|
||||
use reth_rpc_layer::{AuthLayer, Claims, JwtAuthValidator, JwtSecret};
|
||||
use reth_rpc_types::WithOtherFields;
|
||||
use reth_tasks::{pool::BlockingTaskGuard, TaskSpawner, TokioTaskExecutor};
|
||||
use reth_transaction_pool::{noop::NoopTransactionPool, TransactionPool};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -804,7 +805,10 @@ where
|
||||
/// If called outside of the tokio runtime. See also [`Self::eth_api`]
|
||||
pub fn register_ots(&mut self) -> &mut Self
|
||||
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();
|
||||
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`]
|
||||
pub fn otterscan_api(&self) -> OtterscanApi<EthApi>
|
||||
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();
|
||||
OtterscanApi::new(eth_api)
|
||||
|
||||
@ -853,7 +853,7 @@ pub trait Call: LoadState + SpawnBlocking {
|
||||
chain_id,
|
||||
blob_versioned_hashes,
|
||||
max_fee_per_blob_gas,
|
||||
// authorization_list,
|
||||
authorization_list,
|
||||
..
|
||||
} = request;
|
||||
|
||||
@ -892,7 +892,7 @@ pub trait Call: LoadState + SpawnBlocking {
|
||||
blob_hashes: blob_versioned_hashes.unwrap_or_default(),
|
||||
max_fee_per_blob_gas,
|
||||
// EIP-7702 fields
|
||||
// authorization_list: TODO
|
||||
authorization_list: authorization_list.map(Into::into),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
use alloy_network::{Ethereum, Network};
|
||||
use alloy_network::{AnyNetwork, Network};
|
||||
use reth_rpc_eth_types::EthApiError;
|
||||
use reth_rpc_types::{Block, Transaction};
|
||||
use reth_rpc_types::{Block, Transaction, WithOtherFields};
|
||||
|
||||
use crate::{AsEthApiError, FromEthApiError, FromEvmError};
|
||||
|
||||
@ -20,12 +20,12 @@ pub trait EthApiTypes: Send + Sync + Clone {
|
||||
+ Sync;
|
||||
/// Blockchain primitive types, specific to network, e.g. block and transaction.
|
||||
// todo: remove restriction `reth_rpc_types::Transaction`
|
||||
type NetworkTypes: Network<TransactionResponse = Transaction>;
|
||||
type NetworkTypes: Network<TransactionResponse = WithOtherFields<Transaction>>;
|
||||
}
|
||||
|
||||
impl EthApiTypes for () {
|
||||
type Error = EthApiError;
|
||||
type NetworkTypes = Ethereum;
|
||||
type NetworkTypes = AnyNetwork;
|
||||
}
|
||||
|
||||
/// Adapter for network specific transaction type.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! Transaction wrapper that labels transaction with its origin.
|
||||
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;
|
||||
|
||||
/// 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 {
|
||||
match value {
|
||||
TransactionSource::Pool(tx) => reth_rpc_types_compat::transaction::from_recovered(tx),
|
||||
|
||||
@ -11,7 +11,7 @@ repository.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
alloy-rpc-types-engine.workspace = true
|
||||
alloy-rpc-types-engine = { workspace = true, features = ["jwt"] }
|
||||
|
||||
http.workspace = true
|
||||
jsonrpsee-http-client.workspace = true
|
||||
|
||||
@ -6,7 +6,9 @@ use alloy_rpc_types::{Transaction, TransactionInfo};
|
||||
use reth_primitives::{
|
||||
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
|
||||
/// [`BlockTransactionsKind`]
|
||||
@ -17,7 +19,7 @@ pub fn from_block(
|
||||
total_difficulty: U256,
|
||||
kind: BlockTransactionsKind,
|
||||
block_hash: Option<B256>,
|
||||
) -> Result<Block, BlockError> {
|
||||
) -> Result<Block<WithOtherFields<Transaction>>, BlockError> {
|
||||
match kind {
|
||||
BlockTransactionsKind::Hashes => {
|
||||
Ok(from_block_with_tx_hashes(block, total_difficulty, block_hash))
|
||||
@ -35,7 +37,7 @@ pub fn from_block_with_tx_hashes(
|
||||
block: BlockWithSenders,
|
||||
total_difficulty: U256,
|
||||
block_hash: Option<B256>,
|
||||
) -> Block {
|
||||
) -> Block<WithOtherFields<Transaction>> {
|
||||
let block_hash = block_hash.unwrap_or_else(|| block.header.hash_slow());
|
||||
let transactions = block.body.iter().map(|tx| tx.hash()).collect();
|
||||
|
||||
@ -57,7 +59,7 @@ pub fn from_block_full(
|
||||
mut block: BlockWithSenders,
|
||||
total_difficulty: U256,
|
||||
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_number = block.block.number;
|
||||
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 {
|
||||
hash: Some(hash),
|
||||
hash,
|
||||
parent_hash,
|
||||
uncles_hash: ommers_hash,
|
||||
miner: beneficiary,
|
||||
@ -133,7 +135,7 @@ pub fn from_primitive_with_hash(primitive_header: reth_primitives::SealedHeader)
|
||||
transactions_root,
|
||||
receipts_root,
|
||||
withdrawals_root,
|
||||
number: Some(number),
|
||||
number,
|
||||
gas_used: gas_used as u128,
|
||||
gas_limit: gas_limit as u128,
|
||||
extra_data,
|
||||
@ -157,8 +159,8 @@ fn from_block_with_transactions(
|
||||
block_hash: B256,
|
||||
block: PrimitiveBlock,
|
||||
total_difficulty: U256,
|
||||
transactions: BlockTransactions<Transaction>,
|
||||
) -> Block {
|
||||
transactions: BlockTransactions<WithOtherFields<Transaction>>,
|
||||
) -> Block<WithOtherFields<Transaction>> {
|
||||
let uncles = block.ommers.into_iter().map(|h| h.hash_slow()).collect();
|
||||
let mut header = from_primitive_with_hash(block.header.seal(block_hash));
|
||||
header.total_difficulty = Some(total_difficulty);
|
||||
@ -169,19 +171,12 @@ fn from_block_with_transactions(
|
||||
.then(|| block.withdrawals.map(Withdrawals::into_inner))
|
||||
.flatten();
|
||||
|
||||
Block {
|
||||
header,
|
||||
uncles,
|
||||
transactions,
|
||||
size: Some(U256::from(block_length)),
|
||||
withdrawals,
|
||||
other: Default::default(),
|
||||
}
|
||||
Block { header, uncles, transactions, size: Some(U256::from(block_length)), withdrawals }
|
||||
}
|
||||
|
||||
/// Build an RPC block response representing
|
||||
/// 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 rpc_header = from_primitive_with_hash(header.clone().seal(hash));
|
||||
let uncle_block = PrimitiveBlock { header, ..Default::default() };
|
||||
@ -192,6 +187,5 @@ pub fn uncle_block_from_header(header: PrimitiveHeader) -> Block {
|
||||
transactions: BlockTransactions::Uncle,
|
||||
withdrawals: Some(vec![]),
|
||||
size,
|
||||
other: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ use alloy_rpc_types::{
|
||||
TransactionInfo,
|
||||
};
|
||||
use reth_primitives::{Address, TransactionSignedEcRecovered, TxKind, TxType};
|
||||
use reth_rpc_types::Transaction;
|
||||
use reth_rpc_types::{Transaction, WithOtherFields};
|
||||
use signature::from_primitive_signature;
|
||||
pub use typed::*;
|
||||
|
||||
@ -17,19 +17,22 @@ mod typed;
|
||||
pub fn from_recovered_with_block_context(
|
||||
tx: TransactionSignedEcRecovered,
|
||||
tx_info: TransactionInfo,
|
||||
) -> Transaction {
|
||||
) -> WithOtherFields<Transaction> {
|
||||
fill(tx, tx_info)
|
||||
}
|
||||
|
||||
/// Create a new rpc transaction result for a _pending_ signed transaction, setting block
|
||||
/// environment related fields to `None`.
|
||||
pub fn from_recovered(tx: TransactionSignedEcRecovered) -> Transaction {
|
||||
pub fn from_recovered(tx: TransactionSignedEcRecovered) -> WithOtherFields<Transaction> {
|
||||
fill(tx, TransactionInfo::default())
|
||||
}
|
||||
|
||||
/// Create a new rpc transaction result for a _pending_ signed transaction, setting block
|
||||
/// 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 signed_tx = tx.into_signed();
|
||||
|
||||
@ -41,7 +44,7 @@ fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transacti
|
||||
#[allow(unreachable_patterns)]
|
||||
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::Eip1559 | TxType::Eip4844 => {
|
||||
TxType::Eip1559 | TxType::Eip4844 | TxType::Eip7702 => {
|
||||
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
|
||||
// baseFee`
|
||||
let gas_price = tx_info
|
||||
@ -68,30 +71,32 @@ fn fill(tx: TransactionSignedEcRecovered, tx_info: TransactionInfo) -> Transacti
|
||||
let signature =
|
||||
from_primitive_signature(*signed_tx.signature(), signed_tx.tx_type(), signed_tx.chain_id());
|
||||
|
||||
Transaction {
|
||||
hash: signed_tx.hash(),
|
||||
nonce: signed_tx.nonce(),
|
||||
from: signer,
|
||||
to,
|
||||
value: signed_tx.value(),
|
||||
gas_price,
|
||||
max_fee_per_gas,
|
||||
max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas(),
|
||||
signature: Some(signature),
|
||||
gas: signed_tx.gas_limit() as u128,
|
||||
input: signed_tx.input().clone(),
|
||||
chain_id,
|
||||
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
|
||||
block_hash: tx_info.block_hash,
|
||||
block_number: tx_info.block_number,
|
||||
transaction_index: tx_info.index,
|
||||
// EIP-4844 fields
|
||||
max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas(),
|
||||
blob_versioned_hashes,
|
||||
authorization_list,
|
||||
WithOtherFields {
|
||||
inner: Transaction {
|
||||
hash: signed_tx.hash(),
|
||||
nonce: signed_tx.nonce(),
|
||||
from: signer,
|
||||
to,
|
||||
value: signed_tx.value(),
|
||||
gas_price,
|
||||
max_fee_per_gas,
|
||||
max_priority_fee_per_gas: signed_tx.max_priority_fee_per_gas(),
|
||||
signature: Some(signature),
|
||||
gas: signed_tx.gas_limit() as u128,
|
||||
input: signed_tx.input().clone(),
|
||||
chain_id,
|
||||
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
|
||||
block_hash: tx_info.block_hash,
|
||||
block_number: tx_info.block_number,
|
||||
transaction_index: tx_info.index,
|
||||
// EIP-4844 fields
|
||||
max_fee_per_blob_gas: signed_tx.max_fee_per_blob_gas(),
|
||||
blob_versioned_hashes,
|
||||
// EIP-7702 fields
|
||||
authorization_list,
|
||||
},
|
||||
// Optimism fields
|
||||
#[cfg(feature = "optimism")]
|
||||
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>
|
||||
is_system_tx: (signed_tx.is_deposit() && signed_tx.is_system_transaction())
|
||||
.then_some(true),
|
||||
deposit_receipt_version: None,
|
||||
}
|
||||
.into(),
|
||||
#[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 access_list = tx.transaction.access_list().cloned();
|
||||
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 tx_type = tx.transaction.tx_type();
|
||||
|
||||
@ -146,5 +152,6 @@ pub fn transaction_to_call_request(tx: TransactionSignedEcRecovered) -> Transact
|
||||
blob_versioned_hashes,
|
||||
transaction_type: Some(tx_type.into()),
|
||||
sidecar: None,
|
||||
authorization_list,
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,10 @@ alloy-rpc-types-txpool.workspace = true
|
||||
alloy-serde.workspace = 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
|
||||
jsonrpsee-types = { workspace = true, optional = true }
|
||||
|
||||
@ -41,6 +45,6 @@ jsonrpsee-types = [
|
||||
"dep:alloy-rpc-types-beacon",
|
||||
"dep:alloy-rpc-types-engine",
|
||||
"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"]
|
||||
|
||||
@ -57,3 +57,9 @@ pub use eth::{
|
||||
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::*;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ pub use reth_rpc_engine_api::EngineApi;
|
||||
use reth_rpc_eth_api::{EthApiTypes, RpcBlock, RpcTransaction};
|
||||
use reth_rpc_types::{
|
||||
state::StateOverride, BlockOverrides, EIP1186AccountProofResponse, Filter, JsonStorageKey, Log,
|
||||
SyncStatus, TransactionRequest,
|
||||
SyncStatus, TransactionRequest, WithOtherFields,
|
||||
};
|
||||
use tracing_futures::Instrument;
|
||||
|
||||
@ -33,15 +33,16 @@ impl<Eth, EthFilter> EngineEthApi<Eth, EthFilter> {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<Eth, EthFilter>
|
||||
EngineEthApiServer<
|
||||
reth_rpc_types::Transaction,
|
||||
reth_rpc_types::Block<reth_rpc_types::Transaction>,
|
||||
> for EngineEthApi<Eth, EthFilter>
|
||||
impl<Eth, EthFilter> EngineEthApiServer<RpcBlock<Eth::NetworkTypes>>
|
||||
for EngineEthApi<Eth, EthFilter>
|
||||
where
|
||||
Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>>
|
||||
+ EthApiTypes<NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>>,
|
||||
EthFilter: EthFilterApiServer<reth_rpc_types::Transaction>,
|
||||
+ EthApiTypes<
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
>,
|
||||
EthFilter: EthFilterApiServer<RpcTransaction<Eth::NetworkTypes>>,
|
||||
{
|
||||
/// Handler for: `eth_syncing`
|
||||
fn syncing(&self) -> Result<SyncStatus> {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use alloy_network::Ethereum;
|
||||
use alloy_network::AnyNetwork;
|
||||
use derive_more::Deref;
|
||||
use reth_node_api::{BuilderProvider, FullNodeComponents};
|
||||
use reth_primitives::{BlockNumberOrTag, U256};
|
||||
@ -123,7 +123,7 @@ where
|
||||
Self: Send + Sync,
|
||||
{
|
||||
type Error = EthApiError;
|
||||
type NetworkTypes = Ethereum;
|
||||
type NetworkTypes = AnyNetwork;
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> std::fmt::Debug
|
||||
|
||||
@ -22,7 +22,7 @@ use reth_rpc_eth_types::{
|
||||
use reth_rpc_server_types::ToRpcResult;
|
||||
use reth_rpc_types::{
|
||||
BlockNumHash, Filter, FilterBlockOption, FilterChanges, FilterId, FilteredParams, Log,
|
||||
PendingTransactionFilterKind,
|
||||
PendingTransactionFilterKind, Transaction, WithOtherFields,
|
||||
};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use reth_transaction_pool::{NewSubpoolTransactionStream, PoolTransaction, TransactionPool};
|
||||
@ -132,7 +132,10 @@ where
|
||||
<Pool as TransactionPool>::Transaction: 'static,
|
||||
{
|
||||
/// 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 best_number = info.best_number;
|
||||
|
||||
@ -222,7 +225,7 @@ where
|
||||
}
|
||||
|
||||
#[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
|
||||
Provider: BlockReader + BlockIdReader + EvmEnvProvider + 'static,
|
||||
Pool: TransactionPool + 'static,
|
||||
@ -268,7 +271,10 @@ where
|
||||
}
|
||||
|
||||
/// 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");
|
||||
Ok(Self::filter_changes(self, id).await?)
|
||||
}
|
||||
@ -547,7 +553,7 @@ impl PendingTransactionsReceiver {
|
||||
}
|
||||
|
||||
/// 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 prepared_stream = self.txs_receiver.lock().await;
|
||||
|
||||
@ -576,7 +582,7 @@ where
|
||||
}
|
||||
|
||||
/// Returns all new pending transactions received since the last poll.
|
||||
async fn drain(&self) -> FilterChanges
|
||||
async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>>
|
||||
where
|
||||
T: PoolTransaction<Consensus = TransactionSignedEcRecovered>,
|
||||
{
|
||||
@ -595,7 +601,7 @@ where
|
||||
/// Helper trait for [FullTransactionsReceiver] to erase the `Transaction` type.
|
||||
#[async_trait]
|
||||
trait FullTransactionsFilter: fmt::Debug + Send + Sync + Unpin + 'static {
|
||||
async fn drain(&self) -> FilterChanges;
|
||||
async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
@ -603,7 +609,7 @@ impl<T> FullTransactionsFilter for FullTransactionsReceiver<T>
|
||||
where
|
||||
T: PoolTransaction<Consensus = TransactionSignedEcRecovered> + 'static,
|
||||
{
|
||||
async fn drain(&self) -> FilterChanges {
|
||||
async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>> {
|
||||
Self::drain(self).await
|
||||
}
|
||||
}
|
||||
@ -620,7 +626,7 @@ enum PendingTransactionKind {
|
||||
}
|
||||
|
||||
impl PendingTransactionKind {
|
||||
async fn drain(&self) -> FilterChanges {
|
||||
async fn drain(&self) -> FilterChanges<WithOtherFields<Transaction>> {
|
||||
match self {
|
||||
Self::Hashes(receiver) => receiver.drain().await,
|
||||
Self::FullTransaction(receiver) => receiver.drain().await,
|
||||
|
||||
@ -17,7 +17,7 @@ use reth_rpc_types::{
|
||||
Params, PubSubSyncStatus, SubscriptionKind, SubscriptionResult as EthSubscriptionResult,
|
||||
SyncStatusMetadata,
|
||||
},
|
||||
FilteredParams, Header, Log,
|
||||
FilteredParams, Header, Log, Transaction, WithOtherFields,
|
||||
};
|
||||
use reth_tasks::{TaskSpawner, TokioTaskExecutor};
|
||||
use reth_transaction_pool::{NewTransactionEvent, TransactionPool};
|
||||
@ -108,9 +108,11 @@ where
|
||||
{
|
||||
match kind {
|
||||
SubscriptionKind::NewHeads => {
|
||||
let stream = pubsub
|
||||
.new_headers_stream()
|
||||
.map(|block| EthSubscriptionResult::Header(Box::new(block.into())));
|
||||
let stream = pubsub.new_headers_stream().map(|header| {
|
||||
EthSubscriptionResult::<WithOtherFields<Transaction>>::Header(Box::new(
|
||||
header.into(),
|
||||
))
|
||||
});
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::Logs => {
|
||||
@ -122,8 +124,9 @@ where
|
||||
}
|
||||
_ => FilteredParams::default(),
|
||||
};
|
||||
let stream =
|
||||
pubsub.log_stream(filter).map(|log| EthSubscriptionResult::Log(Box::new(log)));
|
||||
let stream = pubsub.log_stream(filter).map(|log| {
|
||||
EthSubscriptionResult::<WithOtherFields<Transaction>>::Log(Box::new(log))
|
||||
});
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::NewPendingTransactions => {
|
||||
@ -153,7 +156,7 @@ where
|
||||
|
||||
let stream = pubsub
|
||||
.pending_transaction_hashes_stream()
|
||||
.map(EthSubscriptionResult::TransactionHash);
|
||||
.map(EthSubscriptionResult::<WithOtherFields<Transaction>>::TransactionHash);
|
||||
pipe_from_stream(accepted_sink, stream).await
|
||||
}
|
||||
SubscriptionKind::Syncing => {
|
||||
|
||||
@ -15,7 +15,7 @@ use reth_rpc_types::{
|
||||
},
|
||||
parity::{Action, CreateAction, CreateOutput, TraceOutput},
|
||||
},
|
||||
AnyTransactionReceipt, BlockTransactions, Header, Rich,
|
||||
AnyTransactionReceipt, BlockTransactions, Header, Transaction, WithOtherFields,
|
||||
};
|
||||
use revm_inspectors::{
|
||||
tracing::{types::CallTraceNode, TracingInspectorConfig},
|
||||
@ -40,7 +40,9 @@ impl<Eth> OtterscanApi<Eth> {
|
||||
|
||||
impl<Eth> OtterscanApi<Eth>
|
||||
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.
|
||||
fn block_details(
|
||||
@ -57,11 +59,7 @@ where
|
||||
.map(|receipt| receipt.gas_used.saturating_mul(receipt.effective_gas_price))
|
||||
.sum::<u128>();
|
||||
|
||||
Ok(BlockDetails::new(
|
||||
Rich { inner: block, extra_info: Default::default() },
|
||||
Default::default(),
|
||||
U256::from(total_fees),
|
||||
))
|
||||
Ok(BlockDetails::new(block, Default::default(), U256::from(total_fees)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +67,11 @@ where
|
||||
impl<Eth> OtterscanServer for OtterscanApi<Eth>
|
||||
where
|
||||
Eth: EthApiServer<RpcTransaction<Eth::NetworkTypes>, RpcBlock<Eth::NetworkTypes>>
|
||||
+ EthApiTypes<NetworkTypes: Network<TransactionResponse = reth_rpc_types::Transaction>>
|
||||
+ TraceExt
|
||||
+ EthApiTypes<
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
>,
|
||||
> + TraceExt
|
||||
+ 'static,
|
||||
{
|
||||
/// Handler for `{ots,erigon}_getHeaderByNumber`
|
||||
@ -187,7 +188,7 @@ where
|
||||
block_number: u64,
|
||||
page_number: usize,
|
||||
page_size: usize,
|
||||
) -> RpcResult<OtsBlockTransactions> {
|
||||
) -> RpcResult<OtsBlockTransactions<WithOtherFields<Transaction>>> {
|
||||
// retrieve full block and its receipts
|
||||
let block = self.eth.block_by_number(block_number.into(), true);
|
||||
let receipts = self.eth.block_receipts(block_number.into());
|
||||
|
||||
@ -4,7 +4,7 @@ use reth_primitives::{Address, TransactionSignedEcRecovered};
|
||||
use reth_rpc_api::TxPoolApiServer;
|
||||
use reth_rpc_types::{
|
||||
txpool::{TxpoolContent, TxpoolContentFrom, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus},
|
||||
Transaction,
|
||||
Transaction, WithOtherFields,
|
||||
};
|
||||
use reth_transaction_pool::{AllPoolTransactions, PoolTransaction, TransactionPool};
|
||||
use std::collections::BTreeMap;
|
||||
@ -30,11 +30,11 @@ impl<Pool> TxPoolApi<Pool>
|
||||
where
|
||||
Pool: TransactionPool + 'static,
|
||||
{
|
||||
fn content(&self) -> TxpoolContent {
|
||||
fn content(&self) -> TxpoolContent<WithOtherFields<Transaction>> {
|
||||
#[inline]
|
||||
fn insert<T: PoolTransaction<Consensus = TransactionSignedEcRecovered>>(
|
||||
tx: &T,
|
||||
content: &mut BTreeMap<Address, BTreeMap<String, Transaction>>,
|
||||
content: &mut BTreeMap<Address, BTreeMap<String, WithOtherFields<Transaction>>>,
|
||||
) {
|
||||
content.entry(tx.sender()).or_default().insert(
|
||||
tx.nonce().to_string(),
|
||||
@ -118,7 +118,10 @@ where
|
||||
///
|
||||
/// See [here](https://geth.ethereum.org/docs/rpc/ns-txpool#txpool_contentFrom) for more details
|
||||
/// 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");
|
||||
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
|
||||
/// 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");
|
||||
Ok(self.content())
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ use core::ops::Deref;
|
||||
|
||||
use crate::Compact;
|
||||
use alloy_eips::eip7702::{Authorization as AlloyAuthorization, SignedAuthorization};
|
||||
use alloy_primitives::{Address, ChainId, U256};
|
||||
use alloy_primitives::{Address, U256};
|
||||
use bytes::Buf;
|
||||
use reth_codecs_derive::add_arbitrary_tests;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -14,9 +14,9 @@ use serde::{Deserialize, Serialize};
|
||||
#[cfg_attr(test, derive(arbitrary::Arbitrary))]
|
||||
#[add_arbitrary_tests(compact)]
|
||||
struct Authorization {
|
||||
chain_id: ChainId,
|
||||
chain_id: U256,
|
||||
address: Address,
|
||||
nonce: Option<u64>,
|
||||
nonce: u64,
|
||||
}
|
||||
|
||||
impl Compact for AlloyAuthorization {
|
||||
@ -34,7 +34,7 @@ impl Compact for AlloyAuthorization {
|
||||
let alloy_authorization = Self {
|
||||
chain_id: authorization.chain_id,
|
||||
address: authorization.address,
|
||||
nonce: authorization.nonce.into(),
|
||||
nonce: authorization.nonce,
|
||||
};
|
||||
(alloy_authorization, buf)
|
||||
}
|
||||
@ -79,9 +79,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_roundtrip_compact_authorization_list_item() {
|
||||
let authorization = AlloyAuthorization {
|
||||
chain_id: 1,
|
||||
chain_id: U256::from(1),
|
||||
address: address!("dac17f958d2ee523a2206206994597c13d831ec7"),
|
||||
nonce: None.into(),
|
||||
nonce: 1,
|
||||
}
|
||||
.into_signed(
|
||||
alloy_primitives::Signature::from_rs_and_parity(
|
||||
|
||||
Reference in New Issue
Block a user