mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
core/vm: fill gaps in jump table with opUndefined (#6372)
Cherry-pick https://github.com/ethereum/go-ethereum/pull/24031 Co-authored-by: Paweł Bylica <chfast@gmail.com>
This commit is contained in:
parent
0b9eec66d0
commit
31d30df59f
@ -837,6 +837,10 @@ func opRevert(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func opUndefined(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
|
return nil, &ErrInvalidOpCode{opcode: OpCode(scope.Contract.Code[*pc])}
|
||||||
|
}
|
||||||
|
|
||||||
func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opStop(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -281,10 +281,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
|||||||
// enough stack items available to perform the operation.
|
// enough stack items available to perform the operation.
|
||||||
op = contract.GetOp(_pc)
|
op = contract.GetOp(_pc)
|
||||||
operation := in.jt[op]
|
operation := in.jt[op]
|
||||||
|
|
||||||
if operation == nil {
|
|
||||||
return nil, &ErrInvalidOpCode{opcode: op}
|
|
||||||
}
|
|
||||||
// Validate stack
|
// Validate stack
|
||||||
if sLen := locStack.Len(); sLen < operation.minStack {
|
if sLen := locStack.Len(); sLen < operation.minStack {
|
||||||
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.minStack}
|
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.minStack}
|
||||||
|
@ -258,7 +258,7 @@ func newHomesteadInstructionSet() JumpTable {
|
|||||||
// newFrontierInstructionSet returns the frontier instructions
|
// newFrontierInstructionSet returns the frontier instructions
|
||||||
// that can be executed during the frontier phase.
|
// that can be executed during the frontier phase.
|
||||||
func newFrontierInstructionSet() JumpTable {
|
func newFrontierInstructionSet() JumpTable {
|
||||||
return JumpTable{
|
tbl := JumpTable{
|
||||||
STOP: {
|
STOP: {
|
||||||
execute: opStop,
|
execute: opStop,
|
||||||
constantGas: 0,
|
constantGas: 0,
|
||||||
@ -1463,4 +1463,13 @@ func newFrontierInstructionSet() JumpTable {
|
|||||||
writes: true,
|
writes: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill all unassigned slots with opUndefined.
|
||||||
|
for i, entry := range tbl {
|
||||||
|
if entry == nil {
|
||||||
|
tbl[i] = &operation{execute: opUndefined, maxStack: maxStack(0, 0)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tbl
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user