From 69486605090a55c0cf4069792ceb025b49a01e90 Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 13 Jun 2024 10:14:50 +0300 Subject: [PATCH] fix: make operation public --- core/vm/eips.go | 8 ++++---- core/vm/jump_table.go | 46 +++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/core/vm/eips.go b/core/vm/eips.go index 7dca26578257..63ee9e0042da 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -72,7 +72,7 @@ func enable1884(jt *JumpTable) { jt[EXTCODEHASH].constantGas = params.ExtcodeHashGasEIP1884 // New opcode - jt[SELFBALANCE] = &operation{ + jt[SELFBALANCE] = &Operation{ execute: opSelfBalance, constantGas: GasFastStep, minStack: minStack(0, 1), @@ -90,7 +90,7 @@ func opSelfBalance(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) // - Adds an opcode that returns the current chain’s EIP-155 unique identifier func enable1344(jt *JumpTable) { // New opcode - jt[CHAINID] = &operation{ + jt[CHAINID] = &Operation{ execute: opChainID, constantGas: GasQuickStep, minStack: minStack(0, 1), @@ -162,7 +162,7 @@ func enable3529(jt *JumpTable) { // - Adds an opcode that returns the current block's base fee. func enable3198(jt *JumpTable) { // New opcode - jt[BASEFEE] = &operation{ + jt[BASEFEE] = &Operation{ execute: opBaseFee, constantGas: GasQuickStep, minStack: minStack(0, 1), @@ -180,7 +180,7 @@ func opBaseFee(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([] // enable3855 applies EIP-3855 (PUSH0 opcode) func enable3855(jt *JumpTable) { // New opcode - jt[PUSH0] = &operation{ + jt[PUSH0] = &Operation{ execute: opPush0, constantGas: GasQuickStep, minStack: minStack(0, 1), diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index dd75e8ce946c..a33d752f4bf1 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -25,27 +25,27 @@ import ( type ( executionFunc func(pc *uint64, interpreter *EVMInterpreter, callContext *ScopeContext) ([]byte, error) gasFunc func(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) - // memorySizeFunc returns the required size, and whether the operation overflowed a uint64 + // memorySizeFunc returns the required size, and whether the Operation overflowed a uint64 memorySizeFunc func(*Stack) (size uint64, overflow bool) ) -type operation struct { - // execute is the operation function +type Operation struct { + // execute is the Operation function execute executionFunc constantGas uint64 dynamicGas gasFunc // minStack tells how many stack items are required minStack int - // maxStack specifies the max length the stack can have for this operation + // maxStack specifies the max length the stack can have for this Operation // to not overflow the stack. maxStack int - // memorySize returns the memory size required for the operation + // memorySize returns the memory size required for the Operation memorySize memorySizeFunc } -// UpdateConstantGas updates the constant gas for the operation. -func (op *operation) UpdateConstantGas(gas uint64) { +// UpdateConstantGas updates the constant gas for the Operation. +func (op *Operation) UpdateConstantGas(gas uint64) { op.constantGas = gas } @@ -63,7 +63,7 @@ var ( ) // JumpTable contains the EVM opcodes supported at a given fork. -type JumpTable [256]*operation +type JumpTable [256]*Operation // DefaultJumpTable defines the default jump table used by the EVM interpreter. func DefaultJumpTable(rules params.Rules) (jumpTable *JumpTable) { @@ -93,7 +93,7 @@ func DefaultJumpTable(rules params.Rules) (jumpTable *JumpTable) { return jumpTable } -// Validate checks if all the operations are set and if they are valid according to the +// Validate checks if all the Operations are set and if they are valid according to the // interpreter assumptions. func (jt JumpTable) Validate() error { for i, op := range jt { @@ -115,7 +115,7 @@ func (jt JumpTable) Validate() error { return nil } -// MustValidate panics if the operations are not valid. +// MustValidate panics if the Operations are not valid. func (jt JumpTable) MustValidate() { if err := jt.Validate(); err != nil { panic(err) @@ -124,7 +124,7 @@ func (jt JumpTable) MustValidate() { func newMergeInstructionSet() JumpTable { instructionSet := newLondonInstructionSet() - instructionSet[RANDOM] = &operation{ + instructionSet[RANDOM] = &Operation{ execute: opRandom, constantGas: GasQuickStep, minStack: minStack(0, 1), @@ -170,31 +170,31 @@ func newIstanbulInstructionSet() JumpTable { // byzantium and contantinople instructions. func newConstantinopleInstructionSet() JumpTable { instructionSet := newByzantiumInstructionSet() - instructionSet[SHL] = &operation{ + instructionSet[SHL] = &Operation{ execute: opSHL, constantGas: GasFastestStep, minStack: minStack(2, 1), maxStack: maxStack(2, 1), } - instructionSet[SHR] = &operation{ + instructionSet[SHR] = &Operation{ execute: opSHR, constantGas: GasFastestStep, minStack: minStack(2, 1), maxStack: maxStack(2, 1), } - instructionSet[SAR] = &operation{ + instructionSet[SAR] = &Operation{ execute: opSAR, constantGas: GasFastestStep, minStack: minStack(2, 1), maxStack: maxStack(2, 1), } - instructionSet[EXTCODEHASH] = &operation{ + instructionSet[EXTCODEHASH] = &Operation{ execute: opExtCodeHash, constantGas: params.ExtcodeHashGasConstantinople, minStack: minStack(1, 1), maxStack: maxStack(1, 1), } - instructionSet[CREATE2] = &operation{ + instructionSet[CREATE2] = &Operation{ execute: opCreate2, constantGas: params.Create2Gas, dynamicGas: gasCreate2, @@ -210,7 +210,7 @@ func newConstantinopleInstructionSet() JumpTable { // byzantium instructions. func newByzantiumInstructionSet() JumpTable { instructionSet := newSpuriousDragonInstructionSet() - instructionSet[STATICCALL] = &operation{ + instructionSet[STATICCALL] = &Operation{ execute: opStaticCall, constantGas: params.CallGasEIP150, dynamicGas: gasStaticCall, @@ -218,13 +218,13 @@ func newByzantiumInstructionSet() JumpTable { maxStack: maxStack(6, 1), memorySize: memoryStaticCall, } - instructionSet[RETURNDATASIZE] = &operation{ + instructionSet[RETURNDATASIZE] = &Operation{ execute: opReturnDataSize, constantGas: GasQuickStep, minStack: minStack(0, 1), maxStack: maxStack(0, 1), } - instructionSet[RETURNDATACOPY] = &operation{ + instructionSet[RETURNDATACOPY] = &Operation{ execute: opReturnDataCopy, constantGas: GasFastestStep, dynamicGas: gasReturnDataCopy, @@ -232,7 +232,7 @@ func newByzantiumInstructionSet() JumpTable { maxStack: maxStack(3, 0), memorySize: memoryReturnDataCopy, } - instructionSet[REVERT] = &operation{ + instructionSet[REVERT] = &Operation{ execute: opRevert, dynamicGas: gasRevert, minStack: minStack(2, 0), @@ -269,7 +269,7 @@ func newTangerineWhistleInstructionSet() JumpTable { // instructions that can be executed during the homestead phase. func newHomesteadInstructionSet() JumpTable { instructionSet := newFrontierInstructionSet() - instructionSet[DELEGATECALL] = &operation{ + instructionSet[DELEGATECALL] = &Operation{ execute: opDelegateCall, dynamicGas: gasDelegateCall, constantGas: params.CallGasFrontier, @@ -1090,7 +1090,7 @@ func newFrontierInstructionSet() JumpTable { // Fill all unassigned slots with opUndefined. for i, entry := range tbl { if entry == nil { - tbl[i] = &operation{execute: opUndefined, maxStack: maxStack(0, 0)} + tbl[i] = &Operation{execute: opUndefined, maxStack: maxStack(0, 0)} } } @@ -1098,7 +1098,7 @@ func newFrontierInstructionSet() JumpTable { return tbl } -// CopyJumpTable creates copy of the operations from the provided source JumpTable. +// CopyJumpTable creates copy of the Operations from the provided source JumpTable. func CopyJumpTable(source *JumpTable) *JumpTable { dest := *source for i, op := range source {