chore: use BlockId functions directly (#8417)

This commit is contained in:
Matthias Seitz
2024-05-28 02:06:09 +02:00
committed by GitHub
parent 66c072c928
commit 20aeb2be0d
3 changed files with 6 additions and 13 deletions

View File

@ -45,7 +45,7 @@ where
address: Address,
block_id: Option<BlockId>,
) -> EthResult<U256> {
if block_id == Some(BlockId::Number(BlockNumberOrTag::Pending)) {
if block_id == Some(BlockId::pending()) {
let address_txs = self.pool().get_transactions_by_sender(address);
if let Some(highest_nonce) =
address_txs.iter().map(|item| item.transaction.nonce()).max()

View File

@ -787,9 +787,7 @@ where
None => return Ok(None),
Some(tx) => {
let res = match tx {
tx @ TransactionSource::Pool(_) => {
(tx, BlockId::Number(BlockNumberOrTag::Pending))
}
tx @ TransactionSource::Pool(_) => (tx, BlockId::pending()),
TransactionSource::Block {
transaction,
index,
@ -873,17 +871,14 @@ where
// set nonce if not already set before
if request.nonce.is_none() {
let nonce =
self.get_transaction_count(from, Some(BlockId::Number(BlockNumberOrTag::Pending)))?;
let nonce = self.get_transaction_count(from, Some(BlockId::pending()))?;
// note: `.to()` can't panic because the nonce is constructed from a `u64`
request.nonce = Some(nonce.to::<u64>());
}
let chain_id = self.chain_id();
let estimated_gas = self
.estimate_gas_at(request.clone(), BlockId::Number(BlockNumberOrTag::Pending), None)
.await?;
let estimated_gas = self.estimate_gas_at(request.clone(), BlockId::pending(), None).await?;
let gas_limit = estimated_gas;
let TransactionRequest {

View File

@ -7,9 +7,7 @@ use crate::eth::{
use async_trait::async_trait;
use jsonrpsee::core::RpcResult as Result;
use reth_consensus_common::calc::{base_block_reward, block_reward};
use reth_primitives::{
revm::env::tx_env_with_recovered, BlockId, BlockNumberOrTag, Bytes, SealedHeader, B256, U256,
};
use reth_primitives::{revm::env::tx_env_with_recovered, BlockId, Bytes, SealedHeader, B256, U256};
use reth_provider::{BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_api::TraceApiServer;
@ -133,7 +131,7 @@ where
calls: Vec<(TransactionRequest, HashSet<TraceType>)>,
block_id: Option<BlockId>,
) -> EthResult<Vec<TraceResults>> {
let at = block_id.unwrap_or(BlockId::Number(BlockNumberOrTag::Pending));
let at = block_id.unwrap_or(BlockId::pending());
let (cfg, block_env, at) = self.inner.eth_api.evm_env_at(at).await?;
let gas_limit = self.inner.eth_api.call_gas_limit();