Skip to content

Commit

Permalink
Update precompiles to London
Browse files Browse the repository at this point in the history
  • Loading branch information
birchmd committed Oct 27, 2021
1 parent 44f2944 commit bfd0b37
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
41 changes: 38 additions & 3 deletions engine-precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,44 @@ impl Precompiles {
Precompiles(map)
}

#[allow(dead_code)]
fn new_berlin() -> Self {
Self::new_istanbul()
pub fn new_berlin() -> Self {
let addresses = prelude::vec![
ECRecover::ADDRESS,
SHA256::ADDRESS,
RIPEMD160::ADDRESS,
Identity::ADDRESS,
ModExp::<Berlin>::ADDRESS,
Bn128Add::<Istanbul>::ADDRESS,
Bn128Mul::<Istanbul>::ADDRESS,
Bn128Pair::<Istanbul>::ADDRESS,
Blake2F::ADDRESS,
ExitToNear::ADDRESS,
ExitToEthereum::ADDRESS,
];
let fun: prelude::Vec<PrecompileFn> = prelude::vec![
ECRecover::run,
SHA256::run,
RIPEMD160::run,
Identity::run,
ModExp::<Berlin>::run,
Bn128Add::<Istanbul>::run,
Bn128Mul::<Istanbul>::run,
Bn128Pair::<Istanbul>::run,
Blake2F::run,
ExitToNear::run,
ExitToEthereum::run,
];
let mut map = prelude::BTreeMap::new();
for (address, fun) in addresses.into_iter().zip(fun) {
map.insert(address, fun);
}

Precompiles(map)
}

pub fn new_london() -> Self {
// no precompile changes in London HF
Self::new_berlin()
}
}

Expand Down
2 changes: 1 addition & 1 deletion engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct StackExecutorParams {
impl StackExecutorParams {
fn new(gas_limit: u64) -> Self {
Self {
precompiles: Precompiles::new_istanbul(),
precompiles: Precompiles::new_london(),
gas_limit,
}
}
Expand Down

0 comments on commit bfd0b37

Please sign in to comment.