From d30e39b2f833fb75f1e529cd405061fb6b548b8d Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Wed, 7 Sep 2022 13:09:52 +0200 Subject: [PATCH] core/vm: rename RANDOM to PREVRANDAO (#25691) See: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4399.md > This EIP supplants the semantics of the return value of existing DIFFICULTY (0x44) opcode and renames the opcode to PREVRANDAO (0x44). --- core/vm/evm.go | 2 +- core/vm/jump_table.go | 2 +- core/vm/opcodes.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index dd55618bf..888f4812a 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -75,7 +75,7 @@ type BlockContext struct { Time *big.Int // Provides information for TIME Difficulty *big.Int // Provides information for DIFFICULTY BaseFee *big.Int // Provides information for BASEFEE - Random *common.Hash // Provides information for RANDOM + Random *common.Hash // Provides information for PREVRANDAO } // TxContext provides the EVM with information about a transaction. diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 707b52e79..94229436d 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -80,7 +80,7 @@ func validate(jt JumpTable) JumpTable { func newMergeInstructionSet() JumpTable { instructionSet := newLondonInstructionSet() - instructionSet[RANDOM] = &operation{ + instructionSet[PREVRANDAO] = &operation{ execute: opRandom, constantGas: GasQuickStep, minStack: minStack(0, 1), diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index 77d619abb..70d854f15 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -99,6 +99,7 @@ const ( NUMBER OpCode = 0x43 DIFFICULTY OpCode = 0x44 RANDOM OpCode = 0x44 // Same as DIFFICULTY + PREVRANDAO OpCode = 0x44 // Same as DIFFICULTY GASLIMIT OpCode = 0x45 CHAINID OpCode = 0x46 SELFBALANCE OpCode = 0x47 @@ -280,7 +281,7 @@ var opCodeToString = map[OpCode]string{ COINBASE: "COINBASE", TIMESTAMP: "TIMESTAMP", NUMBER: "NUMBER", - DIFFICULTY: "DIFFICULTY", // TODO (MariusVanDerWijden) rename to RANDOM post merge + DIFFICULTY: "DIFFICULTY", // TODO (MariusVanDerWijden) rename to PREVRANDAO post merge GASLIMIT: "GASLIMIT", CHAINID: "CHAINID", SELFBALANCE: "SELFBALANCE",