Skip to content

Commit

Permalink
Some EOF compactification
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Aug 17, 2024
1 parent f305d4d commit bebcc00
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions packages/evm/src/eof/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,19 @@ function validateOpcodes(
opcodeNumbers.add(0xfe)

// Remove CODESIZE, CODECOPY, EXTCODESIZE, EXTCODECOPY, EXTCODEHASH, GAS
opcodeNumbers.delete(0x38)
opcodeNumbers.delete(0x39)
opcodeNumbers.delete(0x5a)
opcodeNumbers.delete(0x3b)
opcodeNumbers.delete(0x3c)
opcodeNumbers.delete(0x3f)

const a1 = [0x38, 0x39, 0x5a, 0x3b, 0x3c, 0x3f]
// Remove CALLCODE and SELFDESTRUCT
opcodeNumbers.delete(0xf2)
opcodeNumbers.delete(0xff)

const a2 = [0xf2, 0xff]
// TODO omnibus https://github.com/ipsilon/eof/blob/main/spec/eof.md states
// JUMP / JUMPI / PC / CREATE / CREATE2 also banned
// This is not in the EIPs yet
// Add these opcodes here
// JUMP, JUMPI, PC, CREATE, CREATE2
const a3 = [0x56, 0x57, 0x58, 0xf0, 0xf5]

opcodeNumbers.delete(0x56) // JUMP
opcodeNumbers.delete(0x57) // JUMPI

opcodeNumbers.delete(0x58) // PC

opcodeNumbers.delete(0xf0) // CREATE
opcodeNumbers.delete(0xf5) // CREATE2
for (const op of a1.concat(a2, a3)) {
opcodeNumbers.delete(op)
}

// Note: this name might be misleading since this is the list of opcodes which are OK as final opcodes in a code section
// TODO if using stackDelta for EOF it is possible to add a "termination" boolean for the opcode to mark it as terminating
Expand Down

0 comments on commit bebcc00

Please sign in to comment.