mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore(op): remove optimism feature from LoadPendingBlock (#9503)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
//! Loads OP pending block for a RPC response.
|
||||
|
||||
use reth_primitives::{
|
||||
revm_primitives::{BlockEnv, ExecutionResult},
|
||||
BlockNumber, Receipt, TransactionSignedEcRecovered, B256,
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_primitives::{revm_primitives::BlockEnv, BlockNumber, B256};
|
||||
use reth_provider::{
|
||||
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome, StateProviderFactory,
|
||||
};
|
||||
use reth_provider::{ChainSpecProvider, ExecutionOutcome};
|
||||
use reth_rpc_eth_api::helpers::LoadPendingBlock;
|
||||
use reth_rpc_eth_types::PendingBlock;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
|
||||
use crate::OpEthApi;
|
||||
|
||||
@ -17,15 +18,12 @@ where
|
||||
#[inline]
|
||||
fn provider(
|
||||
&self,
|
||||
) -> impl reth_provider::BlockReaderIdExt
|
||||
+ reth_provider::EvmEnvProvider
|
||||
+ reth_provider::ChainSpecProvider
|
||||
+ reth_provider::StateProviderFactory {
|
||||
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory {
|
||||
self.inner.provider()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn pool(&self) -> impl reth_transaction_pool::TransactionPool {
|
||||
fn pool(&self) -> impl TransactionPool {
|
||||
self.inner.pool()
|
||||
}
|
||||
|
||||
@ -35,26 +33,10 @@ where
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn evm_config(&self) -> &impl reth_evm::ConfigureEvm {
|
||||
fn evm_config(&self) -> &impl ConfigureEvm {
|
||||
self.inner.evm_config()
|
||||
}
|
||||
|
||||
fn assemble_receipt(
|
||||
&self,
|
||||
tx: &TransactionSignedEcRecovered,
|
||||
result: ExecutionResult,
|
||||
cumulative_gas_used: u64,
|
||||
) -> Receipt {
|
||||
Receipt {
|
||||
tx_type: tx.tx_type(),
|
||||
success: result.is_success(),
|
||||
cumulative_gas_used,
|
||||
logs: result.into_logs().into_iter().map(Into::into).collect(),
|
||||
deposit_nonce: None,
|
||||
deposit_receipt_version: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn receipts_root(
|
||||
&self,
|
||||
_block_env: &BlockEnv,
|
||||
|
||||
@ -823,6 +823,7 @@ pub trait Call: LoadState + SpawnBlocking {
|
||||
|
||||
let gas_limit = gas.unwrap_or_else(|| block_env.gas_limit.min(U256::from(u64::MAX)).to());
|
||||
|
||||
#[allow(clippy::needless_update)]
|
||||
let env = TxEnv {
|
||||
gas_limit: gas_limit
|
||||
.try_into()
|
||||
|
||||
@ -169,15 +169,13 @@ pub trait LoadPendingBlock {
|
||||
result: ExecutionResult,
|
||||
cumulative_gas_used: u64,
|
||||
) -> Receipt {
|
||||
#[allow(clippy::needless_update)]
|
||||
Receipt {
|
||||
tx_type: tx.tx_type(),
|
||||
success: result.is_success(),
|
||||
cumulative_gas_used,
|
||||
logs: result.into_logs().into_iter().map(Into::into).collect(),
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_nonce: None,
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_receipt_version: None,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ mod call;
|
||||
mod fees;
|
||||
#[cfg(feature = "optimism")]
|
||||
pub mod optimism;
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
mod pending_block;
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
mod receipt;
|
||||
|
||||
@ -1,23 +1,14 @@
|
||||
//! Loads and formats OP transaction RPC response.
|
||||
|
||||
use jsonrpsee_types::error::ErrorObject;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_evm_optimism::RethL1BlockInfo;
|
||||
use reth_primitives::{
|
||||
BlockNumber, Receipt, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, B256,
|
||||
};
|
||||
use reth_provider::{
|
||||
BlockIdReader, BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, ExecutionOutcome,
|
||||
StateProviderFactory,
|
||||
};
|
||||
use reth_rpc_types::{AnyTransactionReceipt, OptimismTransactionReceiptFields, ToRpcError};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use revm::L1BlockInfo;
|
||||
use revm_primitives::{BlockEnv, ExecutionResult};
|
||||
|
||||
use reth_rpc_eth_api::helpers::{LoadPendingBlock, LoadReceipt, SpawnBlocking};
|
||||
use reth_rpc_eth_types::{EthApiError, EthResult, EthStateCache, PendingBlock, ReceiptBuilder};
|
||||
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
|
||||
use reth_provider::{BlockIdReader, ChainSpecProvider};
|
||||
use reth_rpc_eth_api::helpers::LoadReceipt;
|
||||
use reth_rpc_eth_types::{EthApiError, EthResult, EthStateCache, ReceiptBuilder};
|
||||
use reth_rpc_server_types::result::internal_rpc_err;
|
||||
use reth_rpc_types::{AnyTransactionReceipt, OptimismTransactionReceiptFields, ToRpcError};
|
||||
use revm::L1BlockInfo;
|
||||
|
||||
use crate::EthApi;
|
||||
|
||||
@ -143,68 +134,6 @@ fn op_receipt_fields(
|
||||
resp_builder.add_other_fields(op_fields.into())
|
||||
}
|
||||
|
||||
impl<Provider, Pool, Network, EvmConfig> LoadPendingBlock
|
||||
for EthApi<Provider, Pool, Network, EvmConfig>
|
||||
where
|
||||
Self: SpawnBlocking,
|
||||
Provider: BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory,
|
||||
Pool: TransactionPool,
|
||||
EvmConfig: ConfigureEvm,
|
||||
{
|
||||
#[inline]
|
||||
fn provider(
|
||||
&self,
|
||||
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory {
|
||||
self.inner.provider()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn pool(&self) -> impl reth_transaction_pool::TransactionPool {
|
||||
self.inner.pool()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn pending_block(&self) -> &tokio::sync::Mutex<Option<PendingBlock>> {
|
||||
self.inner.pending_block()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn evm_config(&self) -> &impl reth_evm::ConfigureEvm {
|
||||
self.inner.evm_config()
|
||||
}
|
||||
|
||||
fn assemble_receipt(
|
||||
&self,
|
||||
tx: &TransactionSignedEcRecovered,
|
||||
result: ExecutionResult,
|
||||
cumulative_gas_used: u64,
|
||||
) -> Receipt {
|
||||
Receipt {
|
||||
tx_type: tx.tx_type(),
|
||||
success: result.is_success(),
|
||||
cumulative_gas_used,
|
||||
logs: result.into_logs().into_iter().map(Into::into).collect(),
|
||||
deposit_nonce: None,
|
||||
deposit_receipt_version: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn receipts_root(
|
||||
&self,
|
||||
_block_env: &BlockEnv,
|
||||
execution_outcome: &ExecutionOutcome,
|
||||
block_number: BlockNumber,
|
||||
) -> B256 {
|
||||
execution_outcome
|
||||
.optimism_receipts_root_slow(
|
||||
block_number,
|
||||
self.provider().chain_spec().as_ref(),
|
||||
_block_env.timestamp.to::<u64>(),
|
||||
)
|
||||
.expect("Block is present")
|
||||
}
|
||||
}
|
||||
|
||||
/// Optimism specific errors, that extend [`EthApiError`].
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum OptimismEthApiError {
|
||||
|
||||
Reference in New Issue
Block a user