mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
core/vm: fill gaps in jump table with opUndefined (#24031)
This commit is contained in:
parent
ae267d3da7
commit
7d3c783bb9
3 changed files with 14 additions and 4 deletions
|
|
@ -779,6 +779,10 @@ func opRevert(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]
|
||||||
return ret, ErrExecutionReverted
|
return ret, ErrExecutionReverted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func opUndefined(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
|
||||||
|
return nil, &ErrInvalidOpCode{opcode: OpCode(callContext.contract.Code[*pc])}
|
||||||
|
}
|
||||||
|
|
||||||
func opStop(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
|
func opStop(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,9 +207,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.cfg.JumpTable[op]
|
operation := in.cfg.JumpTable[op]
|
||||||
if operation == nil {
|
|
||||||
return nil, &ErrInvalidOpCode{opcode: op}
|
|
||||||
}
|
|
||||||
// Validate stack
|
// Validate stack
|
||||||
if sLen := stack.len(); sLen < operation.minStack {
|
if sLen := stack.len(); sLen < operation.minStack {
|
||||||
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.minStack}
|
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.minStack}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,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,
|
||||||
|
|
@ -983,4 +983,13 @@ func newFrontierInstructionSet() JumpTable {
|
||||||
maxStack: maxStack(1, 0),
|
maxStack: maxStack(1, 0),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 a new issue