mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 01:28:21 -05:00
perf: small access list perf (#4505)
This commit is contained in:
@@ -48,15 +48,17 @@ pub struct AccessList(
|
||||
impl AccessList {
|
||||
/// Converts the list into a vec, expected by revm
|
||||
pub fn flattened(self) -> Vec<(Address, Vec<U256>)> {
|
||||
self.0
|
||||
.into_iter()
|
||||
.map(|item| {
|
||||
(
|
||||
item.address,
|
||||
item.storage_keys.into_iter().map(|slot| U256::from_be_bytes(slot.0)).collect(),
|
||||
)
|
||||
})
|
||||
.collect()
|
||||
self.flatten().collect()
|
||||
}
|
||||
|
||||
/// Returns an iterator over the list's addresses and storage keys.
|
||||
pub fn flatten(self) -> impl Iterator<Item = (Address, Vec<U256>)> {
|
||||
self.0.into_iter().map(|item| {
|
||||
(
|
||||
item.address,
|
||||
item.storage_keys.into_iter().map(|slot| U256::from_be_bytes(slot.0)).collect(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Calculates a heuristic for the in-memory size of the [AccessList].
|
||||
|
||||
@@ -31,8 +31,8 @@ impl AccessListInspector {
|
||||
excluded: [from, to].iter().chain(precompiles.iter()).copied().collect(),
|
||||
access_list: access_list
|
||||
.0
|
||||
.iter()
|
||||
.map(|v| (v.address, v.storage_keys.iter().copied().collect()))
|
||||
.into_iter()
|
||||
.map(|v| (v.address, v.storage_keys.into_iter().collect()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ where
|
||||
|
||||
pub(crate) async fn create_access_list_at(
|
||||
&self,
|
||||
request: CallRequest,
|
||||
mut request: CallRequest,
|
||||
at: Option<BlockId>,
|
||||
) -> EthResult<AccessList> {
|
||||
let block_id = at.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest));
|
||||
@@ -373,7 +373,8 @@ where
|
||||
get_contract_address(from, nonce).into()
|
||||
};
|
||||
|
||||
let initial = request.access_list.clone().unwrap_or_default();
|
||||
// can consume the list since we're not using the request anymore
|
||||
let initial = request.access_list.take().unwrap_or_default();
|
||||
|
||||
let precompiles = get_precompiles(&env.cfg.spec_id);
|
||||
let mut inspector = AccessListInspector::new(initial, from, to, precompiles);
|
||||
|
||||
Reference in New Issue
Block a user