chore: simplify get precompiles (#4681)

This commit is contained in:
Matthias Seitz
2023-09-21 01:15:30 +02:00
committed by GitHub
parent 30b4ddb5f9
commit a29f102999
3 changed files with 7 additions and 23 deletions

View File

@ -376,7 +376,7 @@ where
// 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 precompiles = get_precompiles(env.cfg.spec_id);
let mut inspector = AccessListInspector::new(initial, from, to, precompiles);
let (result, _env) = inspect(&mut db, env, &mut inspector)?;

View File

@ -92,26 +92,10 @@ impl FillableTransaction for TransactionSigned {
}
/// Returns the addresses of the precompiles corresponding to the SpecId.
pub(crate) fn get_precompiles(spec_id: &SpecId) -> Vec<reth_primitives::H160> {
let spec = match spec_id {
SpecId::FRONTIER | SpecId::FRONTIER_THAWING => return vec![],
SpecId::HOMESTEAD | SpecId::DAO_FORK | SpecId::TANGERINE | SpecId::SPURIOUS_DRAGON => {
PrecompilesSpecId::HOMESTEAD
}
SpecId::BYZANTIUM | SpecId::CONSTANTINOPLE | SpecId::PETERSBURG => {
PrecompilesSpecId::BYZANTIUM
}
SpecId::ISTANBUL | SpecId::MUIR_GLACIER => PrecompilesSpecId::ISTANBUL,
SpecId::BERLIN |
SpecId::LONDON |
SpecId::ARROW_GLACIER |
SpecId::GRAY_GLACIER |
SpecId::MERGE |
SpecId::SHANGHAI => PrecompilesSpecId::BERLIN,
SpecId::CANCUN => PrecompilesSpecId::CANCUN,
SpecId::LATEST => PrecompilesSpecId::LATEST,
};
Precompiles::new(spec).addresses().into_iter().map(Address::from).collect()
#[inline]
pub(crate) fn get_precompiles(spec_id: SpecId) -> impl IntoIterator<Item = Address> {
let spec = PrecompilesSpecId::from_spec_id(spec_id);
Precompiles::new(spec).addresses().into_iter().copied().map(Address::from)
}
/// Executes the [Env] against the given [Database] without committing state changes.