Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use BlockId functions directly #8417

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/api/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 3 additions & 8 deletions crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions crates/rpc/rpc/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Loading