From bd89dda25c821c5dedf62907371f1ca39fae049a Mon Sep 17 00:00:00 2001 From: jeffreylin0723 Date: Tue, 8 Aug 2023 01:08:02 +0800 Subject: [PATCH 1/4] add opcode opInferCall signature --- core/vm/instructions.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 2105201fce42..59027b78b111 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -845,6 +845,11 @@ func opSelfdestruct6780(pc *uint64, interpreter *EVMInterpreter, scope *ScopeCon return nil, errStopToken } +func opInferCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { + ret := 5 + return []byte{byte(ret)}, nil +} + // following functions are used by the instruction jump table // make log instruction function From e5e5e04a6cbc890cf100f0c57ac0e39064eeb84b Mon Sep 17 00:00:00 2001 From: jeffreylin0723 Date: Tue, 8 Aug 2023 01:31:59 +0800 Subject: [PATCH 2/4] add opcode to be 0xb0 --- core/vm/opcodes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index 2929b8ce920c..cb4cad51da92 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -208,6 +208,11 @@ const ( LOG4 ) +// 0xb0 range - infercall ops +const ( + INFERCALL OpCode = 0xb0 +) + // 0xf0 range - closures. const ( CREATE OpCode = 0xf0 From af5bec11e2c8d324b3955c6cf341365ff40ec53b Mon Sep 17 00:00:00 2001 From: jeffreylin0723 Date: Tue, 8 Aug 2023 01:32:47 +0800 Subject: [PATCH 3/4] add jump table with dynamic gas and min&max stack same with CALL --- core/vm/jump_table.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index 702b18661545..495912d13351 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -216,6 +216,7 @@ func newByzantiumInstructionSet() JumpTable { func newSpuriousDragonInstructionSet() JumpTable { instructionSet := newTangerineWhistleInstructionSet() instructionSet[EXP].dynamicGas = gasExpEIP158 + return validate(instructionSet) } @@ -1051,6 +1052,13 @@ func newFrontierInstructionSet() JumpTable { minStack: minStack(1, 0), maxStack: maxStack(1, 0), }, + // make infercall min max stack equal to call for now. + INFERCALL: { + execute: opInferCall, + dynamicGas: gasInferCall, + minStack: minStack(7, 1), + maxStack: maxStack(7, 1), + }, } // Fill all unassigned slots with opUndefined. From d95ea841329173ac3ca087c4e5daff50a9545149 Mon Sep 17 00:00:00 2001 From: jeffreylin0723 Date: Tue, 8 Aug 2023 01:33:10 +0800 Subject: [PATCH 4/4] add dynamic gas function --- core/vm/gas_table.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/vm/gas_table.go b/core/vm/gas_table.go index 5153c8b7a3de..d171cbaa7ecc 100644 --- a/core/vm/gas_table.go +++ b/core/vm/gas_table.go @@ -477,3 +477,10 @@ func gasSelfdestruct(evm *EVM, contract *Contract, stack *Stack, mem *Memory, me } return gas, nil } + +// add gas function for inferCall +func gasInferCall(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { + //return constant gas + var gas uint64 = 20 + return gas, nil +}