perf: query accounts with &Address to avoid copying address (#13554)

This commit is contained in:
Hai | RISE
2024-12-25 19:31:28 +07:00
committed by GitHub
parent 14c1c0be69
commit 031f430b8f
27 changed files with 74 additions and 71 deletions

View File

@ -87,7 +87,7 @@ pub trait EstimateCall: Call {
// Optimize for simple transfer transactions, potentially reducing the gas estimate.
if env.tx.data.is_empty() {
if let TransactTo::Call(to) = env.tx.transact_to {
if let Ok(code) = db.db.account_code(to) {
if let Ok(code) = db.db.account_code(&to) {
let no_code_callee = code.map(|code| code.is_empty()).unwrap_or(true);
if no_code_callee {
// If the tx is a simple transfer (call to an account with no code) we can

View File

@ -53,7 +53,7 @@ pub trait EthState: LoadState + SpawnBlocking {
self.spawn_blocking_io(move |this| {
Ok(this
.state_at_block_id_or_latest(block_id)?
.account_balance(address)
.account_balance(&address)
.map_err(Self::Error::from_eth_err)?
.unwrap_or_default())
})
@ -131,7 +131,7 @@ pub trait EthState: LoadState + SpawnBlocking {
) -> impl Future<Output = Result<Option<Account>, Self::Error>> + Send {
self.spawn_blocking_io(move |this| {
let state = this.state_at_block_id(block_id)?;
let account = state.basic_account(address).map_err(Self::Error::from_eth_err)?;
let account = state.basic_account(&address).map_err(Self::Error::from_eth_err)?;
let Some(account) = account else { return Ok(None) };
// Check whether the distance to the block exceeds the maximum configured proof window.
@ -252,7 +252,7 @@ pub trait LoadState:
// first fetch the on chain nonce of the account
let on_chain_account_nonce = this
.latest_state()?
.account_nonce(address)
.account_nonce(&address)
.map_err(Self::Error::from_eth_err)?
.unwrap_or_default();
@ -290,7 +290,7 @@ pub trait LoadState:
// first fetch the on chain nonce of the account
let on_chain_account_nonce = this
.state_at_block_id_or_latest(block_id)?
.account_nonce(address)
.account_nonce(&address)
.map_err(Self::Error::from_eth_err)?
.unwrap_or_default();
@ -333,7 +333,7 @@ pub trait LoadState:
self.spawn_blocking_io(move |this| {
Ok(this
.state_at_block_id_or_latest(block_id)?
.account_code(address)
.account_code(&address)
.map_err(Self::Error::from_eth_err)?
.unwrap_or_default()
.original_bytes())