Skip to content

Commit

Permalink
check for contract code ending in an empty push pre fork 10 (#1159)
Browse files Browse the repository at this point in the history
* check for contract code ending in an empty push pre fork 10

* fix: wrong case usage

* fixing panic on len == 0, going to -1

* remove hard coded 0x60 for push1 check

---------

Co-authored-by: Arthur Abeilice <afa7789@gmail.com>
  • Loading branch information
hexoscott and afa7789 authored Nov 26, 2024
1 parent 9f8ee17 commit 9b78a48
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/vm/evm_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ func (evm *EVM) call_zkevm(typ OpCode, caller ContractRef, addr libcommon.Addres
var code []byte
if !isPrecompile {
code = evm.intraBlockState.GetCode(addr)

// zk - up to fork 10 we cannot handle a contract code that ends with just a push and nothing to push to the stack
// so check for this scenario
if !evm.chainConfig.IsForkID10(evm.Context.BlockNumber) {
if len(code) > 0 && code[len(code)-1] == byte(PUSH1) {
return nil, gas, ErrInvalidCode
}
}
}

snapshot := evm.intraBlockState.Snapshot()
Expand Down

0 comments on commit 9b78a48

Please sign in to comment.