Skip to content

Commit

Permalink
core/vm: move TSTORE,TLOAD to correct opcode nums (#7885)
Browse files Browse the repository at this point in the history
See ethereum/EIPs#7074. Also enable
[EIP-1153](https://eips.ethereum.org/EIPS/eip-1153) in
[Cancun](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md).

---------

Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de>
  • Loading branch information
2 people authored and AskAlexSharov committed Sep 6, 2023
1 parent 697c9f2 commit ce23689
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
3 changes: 2 additions & 1 deletion core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func newPragueInstructionSet() JumpTable {
// and cancun instructions.
func newCancunInstructionSet() JumpTable {
instructionSet := newShanghaiInstructionSet()
enable4844(&instructionSet) // DATAHASH
enable4844(&instructionSet) // BLOBHASH opcode
enable1153(&instructionSet) // Transient storage opcodes
validateAndFillMaxStack(&instructionSet)
return instructionSet
}
Expand Down
16 changes: 5 additions & 11 deletions core/vm/opcodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const (
MSIZE OpCode = 0x59
GAS OpCode = 0x5a
JUMPDEST OpCode = 0x5b
TLOAD OpCode = 0x5c
TSTORE OpCode = 0x5d
PUSH0 OpCode = 0x5f
)

Expand Down Expand Up @@ -215,12 +217,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 @@ -301,6 +297,8 @@ var opCodeToString = map[OpCode]string{
MSIZE: "MSIZE",
GAS: "GAS",
JUMPDEST: "JUMPDEST",
TLOAD: "TLOAD",
TSTORE: "TSTORE",
PUSH0: "PUSH0",

// 0x60 range - push.
Expand Down Expand Up @@ -376,10 +374,6 @@ var opCodeToString = map[OpCode]string{
LOG3: "LOG3",
LOG4: "LOG4",

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

// 0xf0 range.
CREATE: "CREATE",
CALL: "CALL",
Expand Down Expand Up @@ -470,9 +464,9 @@ var stringToOp = map[string]OpCode{
"MSIZE": MSIZE,
"GAS": GAS,
"JUMPDEST": JUMPDEST,
"PUSH0": PUSH0,
"TLOAD": TLOAD,
"TSTORE": TSTORE,
"PUSH0": PUSH0,
"PUSH1": PUSH1,
"PUSH2": PUSH2,
"PUSH3": PUSH3,
Expand Down

0 comments on commit ce23689

Please sign in to comment.