mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
core/vm: derive maxStack from numPop & numPush (#6397)
This commit is contained in:
parent
dc248c5ea4
commit
49bb63661f
@ -45,6 +45,7 @@ func EnableEIP(eipNum int, jt *JumpTable) error {
|
||||
return fmt.Errorf("undefined eip %d", eipNum)
|
||||
}
|
||||
enablerFn(jt)
|
||||
validateAndFillMaxStack(jt)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -76,8 +77,8 @@ func enable1884(jt *JumpTable) {
|
||||
jt[SELFBALANCE] = &operation{
|
||||
execute: opSelfBalance,
|
||||
constantGas: GasFastStep,
|
||||
minStack: minStack(0, 1),
|
||||
maxStack: maxStack(0, 1),
|
||||
numPop: 0,
|
||||
numPush: 1,
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,8 +95,8 @@ func enable1344(jt *JumpTable) {
|
||||
jt[CHAINID] = &operation{
|
||||
execute: opChainID,
|
||||
constantGas: GasQuickStep,
|
||||
minStack: minStack(0, 1),
|
||||
maxStack: maxStack(0, 1),
|
||||
numPop: 0,
|
||||
numPush: 1,
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,8 +163,8 @@ func enable3198(jt *JumpTable) {
|
||||
jt[BASEFEE] = &operation{
|
||||
execute: opBaseFee,
|
||||
constantGas: GasQuickStep,
|
||||
minStack: minStack(0, 1),
|
||||
maxStack: maxStack(0, 1),
|
||||
numPop: 0,
|
||||
numPush: 1,
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,8 +181,8 @@ func enable3855(jt *JumpTable) {
|
||||
jt[PUSH0] = &operation{
|
||||
execute: opPush0,
|
||||
constantGas: GasQuickStep,
|
||||
minStack: minStack(0, 1),
|
||||
maxStack: maxStack(0, 1),
|
||||
numPop: 0,
|
||||
numPush: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,8 +240,8 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||
operation := in.jt[op]
|
||||
cost = operation.constantGas // For tracing
|
||||
// Validate stack
|
||||
if sLen := locStack.Len(); sLen < operation.minStack {
|
||||
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.minStack}
|
||||
if sLen := locStack.Len(); sLen < operation.numPop {
|
||||
return nil, &ErrStackUnderflow{stackLen: sLen, required: operation.numPop}
|
||||
} else if sLen > operation.maxStack {
|
||||
return nil, &ErrStackOverflow{stackLen: sLen, limit: operation.maxStack}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,23 +20,6 @@ import (
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
)
|
||||
|
||||
func minSwapStack(n int) int {
|
||||
return minStack(n, n)
|
||||
}
|
||||
func maxSwapStack(n int) int {
|
||||
return maxStack(n, n)
|
||||
}
|
||||
|
||||
func minDupStack(n int) int {
|
||||
return minStack(n, n+1)
|
||||
}
|
||||
func maxDupStack(n int) int {
|
||||
return maxStack(n, n+1)
|
||||
}
|
||||
|
||||
func maxStack(pop, push int) int {
|
||||
return int(params.StackLimit) + pop - push
|
||||
}
|
||||
func minStack(pops, push int) int {
|
||||
return pops
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user