mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
finishing touches
This commit is contained in:
parent
08bd16adff
commit
e4aa362e75
4 changed files with 17 additions and 11 deletions
|
|
@ -54,7 +54,6 @@ func evmmaxMemoryGasCost(pc uint64, scope *ScopeContext, newMemSize uint64, newE
|
||||||
curEVMMAXMemSizePadded := toWordSize(curEVMMAXMemSize) * 32
|
curEVMMAXMemSizePadded := toWordSize(curEVMMAXMemSize) * 32
|
||||||
newEVMMAXMemSizePadded := toWordSize(newEVMMAXMemSize) * 32
|
newEVMMAXMemSizePadded := toWordSize(newEVMMAXMemSize) * 32
|
||||||
|
|
||||||
// if newEVMMAXMemSize + newEVMMemSize > curEVMMAXMemSize + curEVMMemSize
|
|
||||||
if newMemSizePadded > uint64(scope.Memory.Len()) || newEVMMAXMemSizePadded > curEVMMAXMemSizePadded {
|
if newMemSizePadded > uint64(scope.Memory.Len()) || newEVMMAXMemSizePadded > curEVMMAXMemSizePadded {
|
||||||
// if this is called by the invocation of SETUPX, the new evm memory is
|
// if this is called by the invocation of SETUPX, the new evm memory is
|
||||||
// 0, but we still need it to compute the fee
|
// 0, but we still need it to compute the fee
|
||||||
|
|
@ -548,7 +547,7 @@ func isPowerOfTwo(val *big.Int) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func gasSetupx(pc uint64, evm *EVM, scope *ScopeContext, memorySize uint64) (uint64, error) {
|
func gasSetmodx(pc uint64, evm *EVM, scope *ScopeContext, memorySize uint64) (uint64, error) {
|
||||||
if !scope.Stack.Back(0).IsUint64() || !scope.Stack.Back(2).IsUint64() || !scope.Stack.Back(3).IsUint64() {
|
if !scope.Stack.Back(0).IsUint64() || !scope.Stack.Back(2).IsUint64() || !scope.Stack.Back(3).IsUint64() {
|
||||||
return 0, errors.New("one or more parameters overflows 64 bits")
|
return 0, errors.New("one or more parameters overflows 64 bits")
|
||||||
}
|
}
|
||||||
|
|
@ -619,9 +618,11 @@ func gasStorex(pc uint64, evm *EVM, scope *ScopeContext, memorySize uint64) (uin
|
||||||
}
|
}
|
||||||
|
|
||||||
if scope.modExtState.active.IsModulusBinary() {
|
if scope.modExtState.active.IsModulusBinary() {
|
||||||
|
// TODO: seems pretty impossible that this can overflow, just adding a note
|
||||||
|
// here to remind myself to double-check this once again.
|
||||||
return toWordSize(storeSize) * params.CopyGas, nil
|
return toWordSize(storeSize) * params.CopyGas, nil
|
||||||
} else {
|
} else {
|
||||||
return count.Uint64() * uint64(params.MulmodxCost[int(scope.modExtState.active.ElemSize()/8)-1]), nil
|
return count.Uint64() * params.MulmodxCost[int(scope.modExtState.active.ElemSize()/8)-1], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -646,16 +647,21 @@ func gasLoadx(pc uint64, evm *EVM, scope *ScopeContext, memorySize uint64) (uint
|
||||||
return 0, errors.New("out of bounds destination")
|
return 0, errors.New("out of bounds destination")
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSize := count.Uint64() * uint64(scope.modExtState.active.ElemSize())
|
loadSize, overflow := math.SafeMul(count.Uint64(), uint64(scope.modExtState.active.ElemSize()))
|
||||||
|
if overflow {
|
||||||
|
return 0, fmt.Errorf("overflow")
|
||||||
|
}
|
||||||
last, overflow := math.SafeAdd(dst.Uint64(), loadSize)
|
last, overflow := math.SafeAdd(dst.Uint64(), loadSize)
|
||||||
if overflow || last > uint64(scope.Memory.Len()) {
|
if overflow || last > uint64(scope.Memory.Len()) {
|
||||||
return 0, errors.New("out of bounds destination")
|
return 0, errors.New("out of bounds destination")
|
||||||
}
|
}
|
||||||
|
|
||||||
if scope.modExtState.active.IsModulusBinary() {
|
if scope.modExtState.active.IsModulusBinary() {
|
||||||
|
// TODO: seems pretty impossible that this can overflow, just adding a note
|
||||||
|
// here to remind myself to double-check this once again.
|
||||||
return toWordSize(loadSize) * params.CopyGas, nil
|
return toWordSize(loadSize) * params.CopyGas, nil
|
||||||
} else {
|
} else {
|
||||||
return count.Uint64() * uint64(params.MulmodxCost[int(scope.modExtState.active.ElemSize()/8)-1]), nil
|
return count.Uint64() * params.MulmodxCost[int(scope.modExtState.active.ElemSize()/8)-1], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -954,7 +954,7 @@ func makeLog(size int) executionFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func opSetupx(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opSetmodx(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
id, modOffset, modSize, allocSize := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.pop(), scope.Stack.pop()
|
id, modOffset, modSize, allocSize := scope.Stack.pop(), scope.Stack.pop(), scope.Stack.pop(), scope.Stack.pop()
|
||||||
modulus := scope.Memory.GetCopy(modOffset.Uint64(), modSize.Uint64())
|
modulus := scope.Memory.GetCopy(modOffset.Uint64(), modSize.Uint64())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,9 +104,9 @@ func newPragueEOFInstructionSet() JumpTable {
|
||||||
|
|
||||||
func newEVMMAXInstructionSet() JumpTable {
|
func newEVMMAXInstructionSet() JumpTable {
|
||||||
instructionSet := newCancunInstructionSet()
|
instructionSet := newCancunInstructionSet()
|
||||||
instructionSet[SETUPX] = &operation{
|
instructionSet[SETMODX] = &operation{
|
||||||
execute: opSetupx,
|
execute: opSetmodx,
|
||||||
dynamicGas: gasSetupx,
|
dynamicGas: gasSetmodx,
|
||||||
minStack: minStack(4, 0),
|
minStack: minStack(4, 0),
|
||||||
maxStack: maxStack(4, 0),
|
maxStack: maxStack(4, 0),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ const (
|
||||||
|
|
||||||
// 0xc0 range - extended-width modular arithmetic ops.
|
// 0xc0 range - extended-width modular arithmetic ops.
|
||||||
const (
|
const (
|
||||||
SETUPX OpCode = 0xc0 + iota
|
SETMODX OpCode = 0xc0 + iota
|
||||||
LOADX
|
LOADX
|
||||||
STOREX
|
STOREX
|
||||||
ADDMODX
|
ADDMODX
|
||||||
|
|
@ -418,7 +418,7 @@ var opCodeToString = [256]string{
|
||||||
SWAP16: "SWAP16",
|
SWAP16: "SWAP16",
|
||||||
|
|
||||||
// 0xc0 range - extended-range modular arithmetic ops
|
// 0xc0 range - extended-range modular arithmetic ops
|
||||||
SETUPX: "SETUPX",
|
SETMODX: "SETMODX",
|
||||||
LOADX: "LOADX",
|
LOADX: "LOADX",
|
||||||
STOREX: "STOREX",
|
STOREX: "STOREX",
|
||||||
ADDMODX: "ADDMODX",
|
ADDMODX: "ADDMODX",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue