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(rpc): relax some types #11946

Merged
merged 2 commits into from
Oct 21, 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
11 changes: 6 additions & 5 deletions crates/rpc/rpc-eth-api/src/helpers/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,14 +655,14 @@ pub trait Call: LoadState + SpawnBlocking {
/// Returns the index of the target transaction in the given iterator.
fn replay_transactions_until<'a, DB, I>(
&self,
db: &mut CacheDB<DB>,
db: &mut DB,
cfg: CfgEnvWithHandlerCfg,
block_env: BlockEnv,
transactions: I,
target_tx_hash: B256,
) -> Result<usize, Self::Error>
where
DB: DatabaseRef,
DB: Database + DatabaseCommit,
EthApiError: From<DB::Error>,
I: IntoIterator<Item = (&'a Address, &'a TransactionSigned)>,
{
Expand Down Expand Up @@ -929,14 +929,15 @@ pub trait Call: LoadState + SpawnBlocking {
/// Executes the requests again after an out of gas error to check if the error is gas related
/// or not
#[inline]
fn map_out_of_gas_err<S>(
fn map_out_of_gas_err<DB>(
&self,
env_gas_limit: U256,
mut env: EnvWithHandlerCfg,
db: &mut CacheDB<StateProviderDatabase<S>>,
db: &mut DB,
) -> Self::Error
where
S: StateProvider,
DB: Database,
EthApiError: From<DB::Error>,
{
let req_gas_limit = env.tx.gas_limit;
env.tx.gas_limit = env_gas_limit.try_into().unwrap_or(u64::MAX);
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-api/src/helpers/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub trait Trace: LoadState {
self.spawn_with_state_at_block(at, move |state| {
let mut db = CacheDB::new(StateProviderDatabase::new(state));
let mut inspector = TracingInspector::new(config);
let (res, _) = this.inspect(StateCacheDbRefMutWrapper(&mut db), env, &mut inspector)?;
let (res, _) = this.inspect(&mut db, env, &mut inspector)?;
f(inspector, res, db)
})
}
Expand Down
50 changes: 25 additions & 25 deletions crates/rpc/rpc-eth-types/src/cache/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,36 @@ impl reth_storage_api::BlockHashReader for StateProviderTraitObjWrapper<'_> {
self.0.block_hash(block_number)
}

fn convert_block_hash(
&self,
hash_or_number: alloy_rpc_types::BlockHashOrNumber,
) -> reth_errors::ProviderResult<Option<B256>> {
self.0.convert_block_hash(hash_or_number)
}

fn canonical_hashes_range(
&self,
start: alloy_primitives::BlockNumber,
end: alloy_primitives::BlockNumber,
) -> reth_errors::ProviderResult<Vec<B256>> {
self.0.canonical_hashes_range(start, end)
}
}

fn convert_block_hash(
impl StateProvider for StateProviderTraitObjWrapper<'_> {
fn storage(
&self,
hash_or_number: alloy_rpc_types::BlockHashOrNumber,
) -> reth_errors::ProviderResult<Option<B256>> {
self.0.convert_block_hash(hash_or_number)
account: revm_primitives::Address,
storage_key: alloy_primitives::StorageKey,
) -> reth_errors::ProviderResult<Option<alloy_primitives::StorageValue>> {
self.0.storage(account, storage_key)
}
}

impl StateProvider for StateProviderTraitObjWrapper<'_> {
fn account_balance(
fn bytecode_by_hash(
&self,
addr: revm_primitives::Address,
) -> reth_errors::ProviderResult<Option<U256>> {
self.0.account_balance(addr)
code_hash: B256,
) -> reth_errors::ProviderResult<Option<reth_primitives::Bytecode>> {
self.0.bytecode_by_hash(code_hash)
}

fn account_code(
Expand All @@ -145,26 +153,18 @@ impl StateProvider for StateProviderTraitObjWrapper<'_> {
self.0.account_code(addr)
}

fn account_nonce(
fn account_balance(
&self,
addr: revm_primitives::Address,
) -> reth_errors::ProviderResult<Option<u64>> {
self.0.account_nonce(addr)
}

fn bytecode_by_hash(
&self,
code_hash: B256,
) -> reth_errors::ProviderResult<Option<reth_primitives::Bytecode>> {
self.0.bytecode_by_hash(code_hash)
) -> reth_errors::ProviderResult<Option<U256>> {
self.0.account_balance(addr)
}

fn storage(
fn account_nonce(
&self,
account: revm_primitives::Address,
storage_key: alloy_primitives::StorageKey,
) -> reth_errors::ProviderResult<Option<alloy_primitives::StorageValue>> {
self.0.storage(account, storage_key)
addr: revm_primitives::Address,
) -> reth_errors::ProviderResult<Option<u64>> {
self.0.account_nonce(addr)
}
}

Expand Down
Loading