Skip to content

Commit

Permalink
Merge branch 'feat/prague-hard-fork' into feat/eip-7702
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed Aug 27, 2024
2 parents edcb019 + 1d9d1dc commit 8ddc8b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ pub enum ExitError {
/// `usize` casting overflow
#[cfg_attr(feature = "with-codec", codec(index = 15))]
UsizeOverflow,
#[cfg_attr(feature = "with-codec", codec(index = 16))]
CreateContractStartingWithEF,
}

impl From<ExitError> for ExitReason {
Expand Down
10 changes: 5 additions & 5 deletions src/executor/stack/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,10 +1131,10 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
reason: ExitReason,
return_data: Vec<u8>,
) -> (ExitReason, Option<H160>, Vec<u8>) {
fn check_first_byte(config: &Config, code: &[u8]) -> Result<(), ExitError> {
if config.disallow_executable_format && Some(&Opcode::EOFMAGIC.as_u8()) == code.first()
{
return Err(ExitError::InvalidCode(Opcode::EOFMAGIC));
// EIP-3541: Reject new contract code starting with the 0xEF byte (EOF Magic)
fn check_first_byte_eof_magic(config: &Config, code: &[u8]) -> Result<(), ExitError> {
if config.disallow_executable_format && Some(&0xEF) == code.first() {
return Err(ExitError::CreateContractStartingWithEF);
}
Ok(())
}
Expand All @@ -1146,7 +1146,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
let out = return_data;
let address = created_address;
// As of EIP-3541 code starting with 0xef cannot be deployed
if let Err(e) = check_first_byte(self.config, &out) {
if let Err(e) = check_first_byte_eof_magic(self.config, &out) {
self.state.metadata_mut().gasometer.fail();
let _ = self.exit_substate(&StackExitKind::Failed);
return (e.into(), None, Vec::new());
Expand Down

0 comments on commit 8ddc8b4

Please sign in to comment.