Skip to content

Commit

Permalink
core/vm: order opcodes properly (ethereum#27113)
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and mmsqe committed Dec 7, 2023
1 parent 1de1ec8 commit 4ebf734
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions core/vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ const (
LOG4
)

// 0xb0 range.
const (
TLOAD OpCode = 0xb3
TSTORE OpCode = 0xb4
)

// 0xf0 range - closures.
const (
CREATE OpCode = 0xf0
Expand All @@ -219,12 +225,6 @@ const (
SELFDESTRUCT OpCode = 0xff
)

// 0xb0 range.
const (
TLOAD OpCode = 0xb3
TSTORE OpCode = 0xb4
)

// Since the opcodes aren't all in order we can't use a regular slice.
var opCodeToString = map[OpCode]string{
// 0x0 range - arithmetic ops.
Expand Down Expand Up @@ -290,9 +290,7 @@ var opCodeToString = map[OpCode]string{
BASEFEE: "BASEFEE",

// 0x50 range - 'storage' and execution.
POP: "POP",
//DUP: "DUP",
//SWAP: "SWAP",
POP: "POP",
MLOAD: "MLOAD",
MSTORE: "MSTORE",
MSTORE8: "MSTORE8",
Expand All @@ -306,7 +304,7 @@ var opCodeToString = map[OpCode]string{
JUMPDEST: "JUMPDEST",
PUSH0: "PUSH0",

// 0x60 range - push.
// 0x60 range - pushes.
PUSH1: "PUSH1",
PUSH2: "PUSH2",
PUSH3: "PUSH3",
Expand Down Expand Up @@ -340,6 +338,7 @@ var opCodeToString = map[OpCode]string{
PUSH31: "PUSH31",
PUSH32: "PUSH32",

// 0x80 - dups.
DUP1: "DUP1",
DUP2: "DUP2",
DUP3: "DUP3",
Expand All @@ -357,6 +356,7 @@ var opCodeToString = map[OpCode]string{
DUP15: "DUP15",
DUP16: "DUP16",

// 0x90 - swaps.
SWAP1: "SWAP1",
SWAP2: "SWAP2",
SWAP3: "SWAP3",
Expand All @@ -373,17 +373,19 @@ var opCodeToString = map[OpCode]string{
SWAP14: "SWAP14",
SWAP15: "SWAP15",
SWAP16: "SWAP16",
LOG0: "LOG0",
LOG1: "LOG1",
LOG2: "LOG2",
LOG3: "LOG3",
LOG4: "LOG4",

// 0xa0 range - logging ops.
LOG0: "LOG0",
LOG1: "LOG1",
LOG2: "LOG2",
LOG3: "LOG3",
LOG4: "LOG4",

// 0xb0 range.
TLOAD: "TLOAD",
TSTORE: "TSTORE",

// 0xf0 range.
// 0xf0 range - closures.
CREATE: "CREATE",
CALL: "CALL",
RETURN: "RETURN",
Expand Down Expand Up @@ -473,8 +475,6 @@ var stringToOp = map[string]OpCode{
"GAS": GAS,
"JUMPDEST": JUMPDEST,
"PUSH0": PUSH0,
"TLOAD": TLOAD,
"TSTORE": TSTORE,
"PUSH1": PUSH1,
"PUSH2": PUSH2,
"PUSH3": PUSH3,
Expand Down Expand Up @@ -544,6 +544,8 @@ var stringToOp = map[string]OpCode{
"LOG2": LOG2,
"LOG3": LOG3,
"LOG4": LOG4,
"TLOAD": TLOAD,
"TSTORE": TSTORE,
"CREATE": CREATE,
"CREATE2": CREATE2,
"CALL": CALL,
Expand Down

0 comments on commit 4ebf734

Please sign in to comment.