Skip to content

Commit 6e0308d

Browse files
authored
chore: ensure precompile bytecode is set for account (#65)
* chore: ensure precompile bytecode is set for account * chore: use reth primitives import * chore: use revm bytecode * chore: add rust-toolchain and fix compiler issues * chore: lint * Revert "chore: lint" This reverts commit 0818277. * chore: rm rust-toolchain to use existing ci workflow versions * chore: lint
1 parent a1584fc commit 6e0308d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

crates/ev-precompiles/src/mint.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use alloy_evm::{
77
EvmInternals, EvmInternalsError,
88
};
99
use alloy_primitives::{address, Address, Bytes, U256};
10-
use revm::precompile::PrecompileOutput;
10+
use revm::{bytecode::Bytecode, precompile::PrecompileOutput};
1111
use std::sync::OnceLock;
1212

1313
sol! {
@@ -34,6 +34,11 @@ impl MintPrecompile {
3434
ID.get_or_init(|| PrecompileId::custom("native_mint"))
3535
}
3636

37+
fn bytecode() -> &'static Bytecode {
38+
static BYTECODE: OnceLock<Bytecode> = OnceLock::new();
39+
BYTECODE.get_or_init(|| Bytecode::new_raw(Bytes::from_static(&[0xFE])))
40+
}
41+
3742
pub fn new(admin: Address) -> Self {
3843
Self { admin }
3944
}
@@ -54,7 +59,8 @@ impl MintPrecompile {
5459
if addr == MINT_PRECOMPILE_ADDR {
5560
// Ensure the mint precompile account is treated as non-empty so state pruning
5661
// does not wipe out its storage between blocks.
57-
account.info.nonce = 1;
62+
account.info.set_code(Self::bytecode().clone());
63+
account.info.set_nonce(1);
5864
}
5965
account.mark_created();
6066
internals.touch_account(addr);

0 commit comments

Comments
 (0)