From a58ba40cf6daa13ea5192ff8547fd45074fa032e Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 26 Sep 2024 13:52:26 +0200 Subject: [PATCH] core/vm: added JUMPF opcodes --- core/vm/eof_instructions.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/vm/eof_instructions.go b/core/vm/eof_instructions.go index c045c971c0..d187342551 100644 --- a/core/vm/eof_instructions.go +++ b/core/vm/eof_instructions.go @@ -105,7 +105,17 @@ func opRetf(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt // opJumpf implements the JUMPF opcode func opJumpf(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) { - panic("not implemented") + var ( + code = scope.Contract.CodeAt(scope.CodeSection) + idx = binary.BigEndian.Uint16(code[*pc+1:]) + typ = scope.Contract.Container.types[idx] + ) + if scope.Stack.len()+int(typ.maxStackHeight)-int(typ.inputs) > 1024 { + return nil, fmt.Errorf("stack overflow") + } + scope.CodeSection = uint64(idx) + *pc = uint64(math.MaxUint64) + return nil, nil } // opEOFCreate implements the EOFCREATE opcode