|
|
|
// Copyright 2015 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package vm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/common/math"
|
|
|
|
"github.com/woop-chain/woop/core/types"
|
|
|
|
"github.com/woop-chain/woop/internal/params"
|
|
|
|
"github.com/woop-chain/woop/shard"
|
|
|
|
"golang.org/x/crypto/sha3"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
bigZero = new(big.Int)
|
|
|
|
tt255 = math.BigPow(2, 255)
|
|
|
|
errWriteProtection = errors.New("evm: write protection")
|
|
|
|
errReturnDataOutOfBounds = errors.New("evm: return data out of bounds")
|
|
|
|
ErrExecutionReverted = errors.New("evm: execution reverted")
|
|
|
|
errMaxCodeSizeExceeded = errors.New("evm: max code size exceeded")
|
|
|
|
errInvalidJump = errors.New("evm: invalid jump destination")
|
|
|
|
)
|
|
|
|
|
|
|
|
func opAdd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
math.U256(y.Add(x, y))
|
|
|
|
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSub(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
math.U256(y.Sub(x, y))
|
|
|
|
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMul(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.pop()
|
|
|
|
stack.push(math.U256(x.Mul(x, y)))
|
|
|
|
|
|
|
|
interpreter.intPool.put(y)
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opDiv(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
if y.Sign() != 0 {
|
|
|
|
math.U256(y.Div(x, y))
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSdiv(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := math.S256(stack.pop()), math.S256(stack.pop())
|
|
|
|
res := interpreter.intPool.getZero()
|
|
|
|
|
|
|
|
if y.Sign() == 0 || x.Sign() == 0 {
|
|
|
|
stack.push(res)
|
|
|
|
} else {
|
|
|
|
if x.Sign() != y.Sign() {
|
|
|
|
res.Div(x.Abs(x), y.Abs(y))
|
|
|
|
res.Neg(res)
|
|
|
|
} else {
|
|
|
|
res.Div(x.Abs(x), y.Abs(y))
|
|
|
|
}
|
|
|
|
stack.push(math.U256(res))
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x, y)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMod(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.pop()
|
|
|
|
if y.Sign() == 0 {
|
|
|
|
stack.push(x.SetUint64(0))
|
|
|
|
} else {
|
|
|
|
stack.push(math.U256(x.Mod(x, y)))
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(y)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSmod(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := math.S256(stack.pop()), math.S256(stack.pop())
|
|
|
|
res := interpreter.intPool.getZero()
|
|
|
|
|
|
|
|
if y.Sign() == 0 {
|
|
|
|
stack.push(res)
|
|
|
|
} else {
|
|
|
|
if x.Sign() < 0 {
|
|
|
|
res.Mod(x.Abs(x), y.Abs(y))
|
|
|
|
res.Neg(res)
|
|
|
|
} else {
|
|
|
|
res.Mod(x.Abs(x), y.Abs(y))
|
|
|
|
}
|
|
|
|
stack.push(math.U256(res))
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x, y)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opExp(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
base, exponent := stack.pop(), stack.pop()
|
|
|
|
// some shortcuts
|
|
|
|
cmpToOne := exponent.Cmp(big1)
|
|
|
|
if cmpToOne < 0 { // Exponent is zero
|
|
|
|
// x ^ 0 == 1
|
|
|
|
stack.push(base.SetUint64(1))
|
|
|
|
} else if base.Sign() == 0 {
|
|
|
|
// 0 ^ y, if y != 0, == 0
|
|
|
|
stack.push(base.SetUint64(0))
|
|
|
|
} else if cmpToOne == 0 { // Exponent is one
|
|
|
|
// x ^ 1 == x
|
|
|
|
stack.push(base)
|
|
|
|
} else {
|
|
|
|
stack.push(math.Exp(base, exponent))
|
|
|
|
interpreter.intPool.put(base)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(exponent)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSignExtend(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
back := stack.pop()
|
|
|
|
if back.Cmp(big.NewInt(31)) < 0 {
|
|
|
|
bit := uint(back.Uint64()*8 + 7)
|
|
|
|
num := stack.pop()
|
|
|
|
mask := back.Lsh(common.Big1, bit)
|
|
|
|
mask.Sub(mask, common.Big1)
|
|
|
|
if num.Bit(int(bit)) > 0 {
|
|
|
|
num.Or(num, mask.Not(mask))
|
|
|
|
} else {
|
|
|
|
num.And(num, mask)
|
|
|
|
}
|
|
|
|
|
|
|
|
stack.push(math.U256(num))
|
|
|
|
}
|
|
|
|
|
|
|
|
interpreter.intPool.put(back)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opNot(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x := stack.peek()
|
|
|
|
math.U256(x.Not(x))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opLt(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
if x.Cmp(y) < 0 {
|
|
|
|
y.SetUint64(1)
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opGt(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
if x.Cmp(y) > 0 {
|
|
|
|
y.SetUint64(1)
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSlt(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
|
|
|
|
xSign := x.Cmp(tt255)
|
|
|
|
ySign := y.Cmp(tt255)
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case xSign >= 0 && ySign < 0:
|
|
|
|
y.SetUint64(1)
|
|
|
|
|
|
|
|
case xSign < 0 && ySign >= 0:
|
|
|
|
y.SetUint64(0)
|
|
|
|
|
|
|
|
default:
|
|
|
|
if x.Cmp(y) < 0 {
|
|
|
|
y.SetUint64(1)
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSgt(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
|
|
|
|
xSign := x.Cmp(tt255)
|
|
|
|
ySign := y.Cmp(tt255)
|
|
|
|
|
|
|
|
switch {
|
|
|
|
case xSign >= 0 && ySign < 0:
|
|
|
|
y.SetUint64(0)
|
|
|
|
|
|
|
|
case xSign < 0 && ySign >= 0:
|
|
|
|
y.SetUint64(1)
|
|
|
|
|
|
|
|
default:
|
|
|
|
if x.Cmp(y) > 0 {
|
|
|
|
y.SetUint64(1)
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opEq(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
if x.Cmp(y) == 0 {
|
|
|
|
y.SetUint64(1)
|
|
|
|
} else {
|
|
|
|
y.SetUint64(0)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opIszero(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x := stack.peek()
|
|
|
|
if x.Sign() > 0 {
|
|
|
|
x.SetUint64(0)
|
|
|
|
} else {
|
|
|
|
x.SetUint64(1)
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opAnd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.pop()
|
|
|
|
stack.push(x.And(x, y))
|
|
|
|
|
|
|
|
interpreter.intPool.put(y)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opOr(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
y.Or(x, y)
|
|
|
|
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opXor(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y := stack.pop(), stack.peek()
|
|
|
|
y.Xor(x, y)
|
|
|
|
|
|
|
|
interpreter.intPool.put(x)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opByte(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
th, val := stack.pop(), stack.peek()
|
|
|
|
if th.Cmp(common.Big32) < 0 {
|
|
|
|
b := math.Byte(val, 32, int(th.Int64()))
|
|
|
|
val.SetUint64(uint64(b))
|
|
|
|
} else {
|
|
|
|
val.SetUint64(0)
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(th)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opAddmod(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y, z := stack.pop(), stack.pop(), stack.pop()
|
|
|
|
if z.Cmp(bigZero) > 0 {
|
|
|
|
x.Add(x, y)
|
|
|
|
x.Mod(x, z)
|
|
|
|
stack.push(math.U256(x))
|
|
|
|
} else {
|
|
|
|
stack.push(x.SetUint64(0))
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(y, z)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMulmod(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
x, y, z := stack.pop(), stack.pop(), stack.pop()
|
|
|
|
if z.Cmp(bigZero) > 0 {
|
|
|
|
x.Mul(x, y)
|
|
|
|
x.Mod(x, z)
|
|
|
|
stack.push(math.U256(x))
|
|
|
|
} else {
|
|
|
|
stack.push(x.SetUint64(0))
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(y, z)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// opSHL implements Shift Left
|
|
|
|
// The SHL instruction (shift left) pops 2 values from the stack, first arg1 and then arg2,
|
|
|
|
// and pushes on the stack arg2 shifted to the left by arg1 number of bits.
|
|
|
|
func opSHL(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
|
|
|
shift, value := math.U256(stack.pop()), math.U256(stack.peek())
|
|
|
|
defer interpreter.intPool.put(shift) // First operand back into the pool
|
|
|
|
|
|
|
|
if shift.Cmp(common.Big256) >= 0 {
|
|
|
|
value.SetUint64(0)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
n := uint(shift.Uint64())
|
|
|
|
math.U256(value.Lsh(value, n))
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// opSHR implements Logical Shift Right
|
|
|
|
// The SHR instruction (logical shift right) pops 2 values from the stack, first arg1 and then arg2,
|
|
|
|
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with zero fill.
|
|
|
|
func opSHR(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Note, second operand is left in the stack; accumulate result into it, and no need to push it afterwards
|
|
|
|
shift, value := math.U256(stack.pop()), math.U256(stack.peek())
|
|
|
|
defer interpreter.intPool.put(shift) // First operand back into the pool
|
|
|
|
|
|
|
|
if shift.Cmp(common.Big256) >= 0 {
|
|
|
|
value.SetUint64(0)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
n := uint(shift.Uint64())
|
|
|
|
math.U256(value.Rsh(value, n))
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// opSAR implements Arithmetic Shift Right
|
|
|
|
// The SAR instruction (arithmetic shift right) pops 2 values from the stack, first arg1 and then arg2,
|
|
|
|
// and pushes on the stack arg2 shifted to the right by arg1 number of bits with sign extension.
|
|
|
|
func opSAR(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Note, S256 returns (potentially) a new bigint, so we're popping, not peeking this one
|
|
|
|
shift, value := math.U256(stack.pop()), math.S256(stack.pop())
|
|
|
|
defer interpreter.intPool.put(shift) // First operand back into the pool
|
|
|
|
|
|
|
|
if shift.Cmp(common.Big256) >= 0 {
|
|
|
|
if value.Sign() >= 0 {
|
|
|
|
value.SetUint64(0)
|
|
|
|
} else {
|
|
|
|
value.SetInt64(-1)
|
|
|
|
}
|
|
|
|
stack.push(math.U256(value))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
n := uint(shift.Uint64())
|
|
|
|
value.Rsh(value, n)
|
|
|
|
stack.push(math.U256(value))
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSha3(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
offset, size := stack.pop(), stack.pop()
|
|
|
|
data := memory.GetPtr(offset.Int64(), size.Int64())
|
|
|
|
|
|
|
|
if interpreter.hasher == nil {
|
|
|
|
interpreter.hasher = sha3.NewLegacyKeccak256().(keccakState)
|
|
|
|
} else {
|
|
|
|
interpreter.hasher.Reset()
|
|
|
|
}
|
|
|
|
interpreter.hasher.Write(data)
|
|
|
|
interpreter.hasher.Read(interpreter.hasherBuf[:])
|
|
|
|
|
|
|
|
evm := interpreter.evm
|
|
|
|
if evm.vmConfig.EnablePreimageRecording {
|
|
|
|
evm.StateDB.AddPreimage(interpreter.hasherBuf, data)
|
|
|
|
}
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(interpreter.hasherBuf[:]))
|
|
|
|
|
|
|
|
interpreter.intPool.put(offset, size)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opAddress(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(contract.Address().Bytes()))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opBalance(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
slot := stack.peek()
|
|
|
|
slot.Set(interpreter.evm.StateDB.GetBalance(common.BigToAddress(slot)))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opOrigin(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(interpreter.evm.Origin.Bytes()))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCaller(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(contract.Caller().Bytes()))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCallValue(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().Set(contract.value))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCallDataLoad(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(getDataBig(contract.Input, stack.pop(), big32)))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCallDataSize(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetInt64(int64(len(contract.Input))))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCallDataCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
memOffset = stack.pop()
|
|
|
|
dataOffset = stack.pop()
|
|
|
|
length = stack.pop()
|
|
|
|
)
|
|
|
|
memory.Set(memOffset.Uint64(), length.Uint64(), getDataBig(contract.Input, dataOffset, length))
|
|
|
|
|
|
|
|
interpreter.intPool.put(memOffset, dataOffset, length)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opReturnDataSize(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(uint64(len(interpreter.returnData))))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opReturnDataCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
memOffset = stack.pop()
|
|
|
|
dataOffset = stack.pop()
|
|
|
|
length = stack.pop()
|
|
|
|
|
|
|
|
end = interpreter.intPool.get().Add(dataOffset, length)
|
|
|
|
)
|
|
|
|
defer interpreter.intPool.put(memOffset, dataOffset, length, end)
|
|
|
|
|
|
|
|
if !end.IsUint64() || uint64(len(interpreter.returnData)) < end.Uint64() {
|
|
|
|
return nil, errReturnDataOutOfBounds
|
|
|
|
}
|
|
|
|
memory.Set(memOffset.Uint64(), length.Uint64(), interpreter.returnData[dataOffset.Uint64():end.Uint64()])
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opExtCodeSize(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
slot := stack.peek()
|
Mainnet Release Candidate 2023.1.2 (#4376)
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0)
---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0
Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0.
- [Release notes](https://github.com/ipld/go-ipld-prime/releases)
- [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0)
---
updated-dependencies:
- dependency-name: github.com/ipld/go-ipld-prime
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump golang.org/x/net from 0.3.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0)
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Small fixes.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* activate epoch
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review "--port flag".
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* Commented golangci.
* staged stream sync v1.0
* fix protocol tests
* fix spell
* remove unused struct
* fix rosetta test
* add comments and refactor verify sig
* add comments, remove extra function
* add comment
* refactor errors, rename metrics
* refactor p2p host creation
* fix initsync and host creation
* fix short range hash chain
* fix beacon node detection for p2p protocol
* refactor stream peer cooldown and fix protocol beacon node field
* refactor p2p host and routing
* fix p2p discovery test issue
* add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue
* terminal print the peer id and proto id
* fix boot complete message when node is shut down
* add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue
* fix self query issue
* fix test NewDNSSyncingPeerProvider
* [testnet] disable leader rotation
* fix discovery issue for legacy sync
* add watermark low/high options for p2p connection manager
* add test for new conn manager flags
* fix dedent
* add comment to inform about p2p connection manager options
* fix max height issue
* add a separate log for get max height error
* fix log
* feat: triesInMemory flag
* fix: panic if TriesInMemory is 1 to 2
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed timers locks.
* Removed fbft locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional logs.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* Fix formatting.
* Rebased onto dev.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Fix review comment.
* Go mod tidy.
* Set to EpochTBD.
* Fix tests.
* [core] fix state handling of self destruct
If a contract self destructs to self and then receives funds within the
same transaction, it is possible for its stale state to be saved. This
change removes that possibility by checking for deleted state objects
before returning them.
* Fixed race error.
* rpc: add configurable http and `eth_call` timeout
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fixed code review.
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* staged stream sync v1.0
* refactor errors, rename metrics
* fix p2p discovery test issue
* add watermark low/high options for p2p connection manager
* fix dedent
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Go mod tidy.
* remove default timeouts
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Fixes.
* Update singleton.go
* evm: don't return extcode for validators
Due to technical debt, validator information is stored in the code field
of the address. The code field can be accessed in Solidity for an
arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy`
or helper commands (such as `address.code.Length`). The presence of this
field is used by contract developers to (erroneously) deny smart
contract access to other smart contracts (and therefore, validators).
This PR fixes that oversight by returning the same values as other EOAs
for known validator addresses. Obviously, it needs a hard fork that will
be scheduled separately.
* Fix context passing.
* Clean up code.
* Removed engine dependency.
* Fix possible panic.
* Clean up code.
* Network type.
* Fix tests.
* Revert "Removed engine dependency." (#4392)
* Revert "Fix tests."
This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a.
* Revert "Network type."
This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76.
* Revert "Clean up code."
This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2.
* Revert "Fix possible panic."
This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085.
* Revert "Removed engine dependency."
This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859.
* gitignore the cache folder (#4389)
* stable localnet with external validator (#4388)
* stable localnet with external validator
* ignore deploy config file comments
* reduce node launched in localnet
* update makefile
* localnet configuration - add more fn
* fix validator information command typo
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Co-authored-by: frozen <355847+Frozen@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”>
Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com>
Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local>
Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
|
|
|
address := common.BigToAddress(slot)
|
|
|
|
fixValidatorCode := interpreter.evm.chainRules.IsValidatorCodeFix &&
|
|
|
|
interpreter.evm.ShardID == shard.BeaconChainShardID &&
|
|
|
|
interpreter.evm.StateDB.IsValidator(address)
|
|
|
|
if fixValidatorCode {
|
|
|
|
// https://github.com/ethereum/solidity/blob/develop/Changelog.md#081-2021-01-27
|
|
|
|
// per this link, <address>.code.length calls extcodesize on the address so this fix will work
|
|
|
|
slot.SetUint64(0)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
slot.SetUint64(uint64(interpreter.evm.StateDB.GetCodeSize(common.BigToAddress(slot))))
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCodeSize(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
l := interpreter.intPool.get().SetInt64(int64(len(contract.Code)))
|
|
|
|
stack.push(l)
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
memOffset = stack.pop()
|
|
|
|
codeOffset = stack.pop()
|
|
|
|
length = stack.pop()
|
|
|
|
)
|
|
|
|
codeCopy := getDataBig(contract.Code, codeOffset, length)
|
|
|
|
memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
|
|
|
|
|
|
|
|
interpreter.intPool.put(memOffset, codeOffset, length)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
addr = common.BigToAddress(stack.pop())
|
|
|
|
memOffset = stack.pop()
|
|
|
|
codeOffset = stack.pop()
|
|
|
|
length = stack.pop()
|
|
|
|
)
|
Mainnet Release Candidate 2023.1.2 (#4376)
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0)
---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0
Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0.
- [Release notes](https://github.com/ipld/go-ipld-prime/releases)
- [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0)
---
updated-dependencies:
- dependency-name: github.com/ipld/go-ipld-prime
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump golang.org/x/net from 0.3.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0)
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Small fixes.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* activate epoch
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review "--port flag".
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* Commented golangci.
* staged stream sync v1.0
* fix protocol tests
* fix spell
* remove unused struct
* fix rosetta test
* add comments and refactor verify sig
* add comments, remove extra function
* add comment
* refactor errors, rename metrics
* refactor p2p host creation
* fix initsync and host creation
* fix short range hash chain
* fix beacon node detection for p2p protocol
* refactor stream peer cooldown and fix protocol beacon node field
* refactor p2p host and routing
* fix p2p discovery test issue
* add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue
* terminal print the peer id and proto id
* fix boot complete message when node is shut down
* add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue
* fix self query issue
* fix test NewDNSSyncingPeerProvider
* [testnet] disable leader rotation
* fix discovery issue for legacy sync
* add watermark low/high options for p2p connection manager
* add test for new conn manager flags
* fix dedent
* add comment to inform about p2p connection manager options
* fix max height issue
* add a separate log for get max height error
* fix log
* feat: triesInMemory flag
* fix: panic if TriesInMemory is 1 to 2
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed timers locks.
* Removed fbft locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional logs.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* Fix formatting.
* Rebased onto dev.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Fix review comment.
* Go mod tidy.
* Set to EpochTBD.
* Fix tests.
* [core] fix state handling of self destruct
If a contract self destructs to self and then receives funds within the
same transaction, it is possible for its stale state to be saved. This
change removes that possibility by checking for deleted state objects
before returning them.
* Fixed race error.
* rpc: add configurable http and `eth_call` timeout
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fixed code review.
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* staged stream sync v1.0
* refactor errors, rename metrics
* fix p2p discovery test issue
* add watermark low/high options for p2p connection manager
* fix dedent
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Go mod tidy.
* remove default timeouts
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Fixes.
* Update singleton.go
* evm: don't return extcode for validators
Due to technical debt, validator information is stored in the code field
of the address. The code field can be accessed in Solidity for an
arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy`
or helper commands (such as `address.code.Length`). The presence of this
field is used by contract developers to (erroneously) deny smart
contract access to other smart contracts (and therefore, validators).
This PR fixes that oversight by returning the same values as other EOAs
for known validator addresses. Obviously, it needs a hard fork that will
be scheduled separately.
* Fix context passing.
* Clean up code.
* Removed engine dependency.
* Fix possible panic.
* Clean up code.
* Network type.
* Fix tests.
* Revert "Removed engine dependency." (#4392)
* Revert "Fix tests."
This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a.
* Revert "Network type."
This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76.
* Revert "Clean up code."
This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2.
* Revert "Fix possible panic."
This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085.
* Revert "Removed engine dependency."
This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859.
* gitignore the cache folder (#4389)
* stable localnet with external validator (#4388)
* stable localnet with external validator
* ignore deploy config file comments
* reduce node launched in localnet
* update makefile
* localnet configuration - add more fn
* fix validator information command typo
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Co-authored-by: frozen <355847+Frozen@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”>
Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com>
Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local>
Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
|
|
|
var code []byte
|
|
|
|
fixValidatorCode := interpreter.evm.chainRules.IsValidatorCodeFix &&
|
|
|
|
interpreter.evm.ShardID == shard.BeaconChainShardID &&
|
|
|
|
interpreter.evm.StateDB.IsValidator(addr)
|
|
|
|
if fixValidatorCode {
|
|
|
|
// for EOAs that are not validators, statedb returns nil
|
|
|
|
code = nil
|
|
|
|
} else {
|
|
|
|
code = interpreter.evm.StateDB.GetCode(addr)
|
Mainnet Release Candidate 2023.1.2 (#4376)
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0)
---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0
Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0.
- [Release notes](https://github.com/ipld/go-ipld-prime/releases)
- [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0)
---
updated-dependencies:
- dependency-name: github.com/ipld/go-ipld-prime
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump golang.org/x/net from 0.3.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0)
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Small fixes.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* activate epoch
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review "--port flag".
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* Commented golangci.
* staged stream sync v1.0
* fix protocol tests
* fix spell
* remove unused struct
* fix rosetta test
* add comments and refactor verify sig
* add comments, remove extra function
* add comment
* refactor errors, rename metrics
* refactor p2p host creation
* fix initsync and host creation
* fix short range hash chain
* fix beacon node detection for p2p protocol
* refactor stream peer cooldown and fix protocol beacon node field
* refactor p2p host and routing
* fix p2p discovery test issue
* add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue
* terminal print the peer id and proto id
* fix boot complete message when node is shut down
* add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue
* fix self query issue
* fix test NewDNSSyncingPeerProvider
* [testnet] disable leader rotation
* fix discovery issue for legacy sync
* add watermark low/high options for p2p connection manager
* add test for new conn manager flags
* fix dedent
* add comment to inform about p2p connection manager options
* fix max height issue
* add a separate log for get max height error
* fix log
* feat: triesInMemory flag
* fix: panic if TriesInMemory is 1 to 2
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed timers locks.
* Removed fbft locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional logs.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* Fix formatting.
* Rebased onto dev.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Fix review comment.
* Go mod tidy.
* Set to EpochTBD.
* Fix tests.
* [core] fix state handling of self destruct
If a contract self destructs to self and then receives funds within the
same transaction, it is possible for its stale state to be saved. This
change removes that possibility by checking for deleted state objects
before returning them.
* Fixed race error.
* rpc: add configurable http and `eth_call` timeout
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fixed code review.
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* staged stream sync v1.0
* refactor errors, rename metrics
* fix p2p discovery test issue
* add watermark low/high options for p2p connection manager
* fix dedent
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Go mod tidy.
* remove default timeouts
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Fixes.
* Update singleton.go
* evm: don't return extcode for validators
Due to technical debt, validator information is stored in the code field
of the address. The code field can be accessed in Solidity for an
arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy`
or helper commands (such as `address.code.Length`). The presence of this
field is used by contract developers to (erroneously) deny smart
contract access to other smart contracts (and therefore, validators).
This PR fixes that oversight by returning the same values as other EOAs
for known validator addresses. Obviously, it needs a hard fork that will
be scheduled separately.
* Fix context passing.
* Clean up code.
* Removed engine dependency.
* Fix possible panic.
* Clean up code.
* Network type.
* Fix tests.
* Revert "Removed engine dependency." (#4392)
* Revert "Fix tests."
This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a.
* Revert "Network type."
This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76.
* Revert "Clean up code."
This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2.
* Revert "Fix possible panic."
This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085.
* Revert "Removed engine dependency."
This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859.
* gitignore the cache folder (#4389)
* stable localnet with external validator (#4388)
* stable localnet with external validator
* ignore deploy config file comments
* reduce node launched in localnet
* update makefile
* localnet configuration - add more fn
* fix validator information command typo
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Co-authored-by: frozen <355847+Frozen@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”>
Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com>
Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local>
Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
|
|
|
}
|
|
|
|
codeCopy := getDataBig(code, codeOffset, length)
|
|
|
|
memory.Set(memOffset.Uint64(), length.Uint64(), codeCopy)
|
|
|
|
|
|
|
|
interpreter.intPool.put(memOffset, codeOffset, length)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// opExtCodeHash returns the code hash of a specified account.
|
|
|
|
// There are several cases when the function is called, while we can relay everything
|
|
|
|
// to `state.GetCodeHash` function to ensure the correctness.
|
|
|
|
//
|
|
|
|
// (1) Caller tries to get the code hash of a normal contract account, state
|
|
|
|
//
|
|
|
|
// should return the relative code hash and set it as the result.
|
|
|
|
//
|
|
|
|
// (2) Caller tries to get the code hash of a non-existent account, state should
|
|
|
|
//
|
|
|
|
// return common.Hash{} and zero will be set as the result.
|
|
|
|
//
|
|
|
|
// (3) Caller tries to get the code hash for an account without contract code,
|
|
|
|
//
|
|
|
|
// state should return emptyCodeHash(0xc5d246...) as the result.
|
|
|
|
//
|
|
|
|
// (4) Caller tries to get the code hash of a precompiled account, the result
|
|
|
|
//
|
|
|
|
// should be zero or emptyCodeHash.
|
|
|
|
//
|
|
|
|
// It is worth noting that in order to avoid unnecessary create and clean,
|
|
|
|
// all precompile accounts on mainnet have been transferred 1 wei, so the return
|
|
|
|
// here should be emptyCodeHash.
|
|
|
|
// If the precompile account is not transferred any amount on a private or
|
|
|
|
// customized chain, the return value will be zero.
|
|
|
|
//
|
|
|
|
// (5) Caller tries to get the code hash for an account which is marked as suicided
|
|
|
|
//
|
|
|
|
// in the current transaction, the code hash of this account should be returned.
|
|
|
|
//
|
|
|
|
// (6) Caller tries to get the code hash for an account which is marked as deleted,
|
|
|
|
//
|
|
|
|
// this account should be regarded as a non-existent account and zero should be returned.
|
|
|
|
func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
slot := stack.peek()
|
|
|
|
address := common.BigToAddress(slot)
|
|
|
|
if interpreter.evm.StateDB.Empty(address) {
|
|
|
|
slot.SetUint64(0)
|
|
|
|
} else {
|
Mainnet Release Candidate 2023.1.2 (#4376)
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0)
---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0
Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0.
- [Release notes](https://github.com/ipld/go-ipld-prime/releases)
- [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0)
---
updated-dependencies:
- dependency-name: github.com/ipld/go-ipld-prime
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Bump golang.org/x/net from 0.3.0 to 0.7.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0)
---
updated-dependencies:
- dependency-name: golang.org/x/net
dependency-type: indirect
...
Signed-off-by: dependabot[bot] <support@github.com>
* Small fixes.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* activate epoch
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review "--port flag".
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* Commented golangci.
* staged stream sync v1.0
* fix protocol tests
* fix spell
* remove unused struct
* fix rosetta test
* add comments and refactor verify sig
* add comments, remove extra function
* add comment
* refactor errors, rename metrics
* refactor p2p host creation
* fix initsync and host creation
* fix short range hash chain
* fix beacon node detection for p2p protocol
* refactor stream peer cooldown and fix protocol beacon node field
* refactor p2p host and routing
* fix p2p discovery test issue
* add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue
* terminal print the peer id and proto id
* fix boot complete message when node is shut down
* add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue
* fix self query issue
* fix test NewDNSSyncingPeerProvider
* [testnet] disable leader rotation
* fix discovery issue for legacy sync
* add watermark low/high options for p2p connection manager
* add test for new conn manager flags
* fix dedent
* add comment to inform about p2p connection manager options
* fix max height issue
* add a separate log for get max height error
* fix log
* feat: triesInMemory flag
* fix: panic if TriesInMemory is 1 to 2
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed timers locks.
* Removed fbft locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional logs.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* Fix formatting.
* Rebased onto dev.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* comment activation
* 295 epoch
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Fix review comment.
* Go mod tidy.
* Set to EpochTBD.
* Fix tests.
* [core] fix state handling of self destruct
If a contract self destructs to self and then receives funds within the
same transaction, it is possible for its stale state to be saved. This
change removes that possibility by checking for deleted state objects
before returning them.
* Fixed race error.
* rpc: add configurable http and `eth_call` timeout
* remove default timeouts
* store the evm call timeout in rosetta object
* [cmd] actually apply ToRPCServerConfig
* Removed unused method.
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* in progress.
* in progress.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fixed code review.
* Fix review comments.
* Returned locks in rotateLeader.
* Rebased onto dev.
* staged stream sync v1.0
* refactor errors, rename metrics
* fix p2p discovery test issue
* add watermark low/high options for p2p connection manager
* fix dedent
* in progress.
* consensus check is forked
* fix
* Cleanup and fix update pub keys.
* fix
fix
fix
fix
fix
* activate epoch
* EpochTBD for leader rotation epoch.
* 295 epoch
* Decider no longer requires public keys as a dependency. (#4289)
* Consensus doesn't require anymore `Node` as a circular dependency.
* Proper blockchain initialization.
* Rwlock consensus.
* Removed channels.
* Removed view change locks.
* Removed multiSigMutex locks.
* Removed leader locks.
* Removed additional locks and isViewChange.
* Added locks detected by race.
* Added locks detected by race.
* Locks for start.
* Removed additional locks.
* Removed additional locks.
* Make func private.
* Make VerifyBlock private.
* Make IsLeader private.
* Make ParseFBFTMessage private.
* Fix remove locks.
* Added additional locks.
* Added additional locks.
* Added readSignatureBitmapPayload locks.
* Added HandleMessageUpdate locks.
* Added LastMile locks.
* Locks for IsValidatorInCommittee.
* Fixed locks.
* Fixed tests.
* Fixed lock.
* Rebased over leader rotation.
* in progress.
* consensus check is forked
* update master
* fix leader
* check leader for N blocks
* fix
* fix
* Cleanup and fix update pub keys.
* Rotate leader.
* fix
fix
fix
fix
fix
* Cleaned.
* Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`.
* Fix failed tests.
* Fixed code review.
* Fix review comments.
* Merged leader rotation.
* Rebased on dev.
* Rebased on dev.
* Fix usage of private methods.
* Fix usage of private methods.
* Fix usage of private methods.
* Removed deadcode, LockedFBFTPhase.
* Fix review comment.
* Go mod tidy.
* remove default timeouts
* Rotate external leaders on non-beacon chains.
* Fix nil panic.
* Fixes.
* Update singleton.go
* evm: don't return extcode for validators
Due to technical debt, validator information is stored in the code field
of the address. The code field can be accessed in Solidity for an
arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy`
or helper commands (such as `address.code.Length`). The presence of this
field is used by contract developers to (erroneously) deny smart
contract access to other smart contracts (and therefore, validators).
This PR fixes that oversight by returning the same values as other EOAs
for known validator addresses. Obviously, it needs a hard fork that will
be scheduled separately.
* Fix context passing.
* Clean up code.
* Removed engine dependency.
* Fix possible panic.
* Clean up code.
* Network type.
* Fix tests.
* Revert "Removed engine dependency." (#4392)
* Revert "Fix tests."
This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a.
* Revert "Network type."
This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76.
* Revert "Clean up code."
This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2.
* Revert "Fix possible panic."
This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085.
* Revert "Removed engine dependency."
This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859.
* gitignore the cache folder (#4389)
* stable localnet with external validator (#4388)
* stable localnet with external validator
* ignore deploy config file comments
* reduce node launched in localnet
* update makefile
* localnet configuration - add more fn
* fix validator information command typo
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com>
Co-authored-by: frozen <355847+Frozen@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”>
Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com>
Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local>
Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
|
|
|
fixValidatorCode := interpreter.evm.chainRules.IsValidatorCodeFix &&
|
|
|
|
interpreter.evm.ShardID == shard.BeaconChainShardID &&
|
|
|
|
interpreter.evm.StateDB.IsValidator(address)
|
|
|
|
if fixValidatorCode {
|
|
|
|
slot.SetBytes(emptyCodeHash.Bytes())
|
|
|
|
} else {
|
|
|
|
slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opGasprice(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().Set(interpreter.evm.GasPrice))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opBlockhash(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
num := stack.pop()
|
|
|
|
|
|
|
|
n := interpreter.intPool.get().Sub(interpreter.evm.BlockNumber, common.Big257)
|
|
|
|
if num.Cmp(n) > 0 && num.Cmp(interpreter.evm.BlockNumber) < 0 {
|
|
|
|
stack.push(interpreter.evm.GetHash(num.Uint64()).Big())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
}
|
|
|
|
interpreter.intPool.put(num, n)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCoinbase(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(interpreter.evm.Coinbase.Bytes()))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opTimestamp(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(math.U256(interpreter.intPool.get().Set(interpreter.evm.Time)))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opNumber(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(math.U256(interpreter.intPool.get().Set(interpreter.evm.BlockNumber)))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opDifficulty(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(math.U256(interpreter.intPool.get().Set(big.NewInt(0))))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opGasLimit(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(math.U256(interpreter.intPool.get().SetUint64(interpreter.evm.GasLimit)))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opPop(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
interpreter.intPool.put(stack.pop())
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMload(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
v := stack.peek()
|
|
|
|
offset := v.Int64()
|
|
|
|
v.SetBytes(memory.GetPtr(offset, 32))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// pop value of the stack
|
|
|
|
mStart, val := stack.pop(), stack.pop()
|
|
|
|
memory.Set32(mStart.Uint64(), val)
|
|
|
|
|
|
|
|
interpreter.intPool.put(mStart, val)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMstore8(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
off, val := stack.pop().Int64(), stack.pop().Int64()
|
|
|
|
memory.store[off] = byte(val & 0xff)
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSload(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
loc := stack.peek()
|
|
|
|
val := interpreter.evm.StateDB.GetState(contract.Address(), common.BigToHash(loc))
|
|
|
|
loc.SetBytes(val.Bytes())
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
loc := common.BigToHash(stack.pop())
|
|
|
|
val := stack.pop()
|
|
|
|
interpreter.evm.StateDB.SetState(contract.Address(), loc, common.BigToHash(val))
|
|
|
|
|
|
|
|
interpreter.intPool.put(val)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opJump(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
pos := stack.pop()
|
|
|
|
if !contract.validJumpdest(pos) {
|
|
|
|
return nil, errInvalidJump
|
|
|
|
}
|
|
|
|
*pc = pos.Uint64()
|
|
|
|
|
|
|
|
interpreter.intPool.put(pos)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opJumpi(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
pos, cond := stack.pop(), stack.pop()
|
|
|
|
if cond.Sign() != 0 {
|
|
|
|
if !contract.validJumpdest(pos) {
|
|
|
|
return nil, errInvalidJump
|
|
|
|
}
|
|
|
|
*pc = pos.Uint64()
|
|
|
|
} else {
|
|
|
|
*pc++
|
|
|
|
}
|
|
|
|
|
|
|
|
interpreter.intPool.put(pos, cond)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opJumpdest(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opPc(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(*pc))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opMsize(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetInt64(int64(memory.Len())))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opGas(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(contract.Gas))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCreate(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
value = stack.pop()
|
|
|
|
offset, size = stack.pop(), stack.pop()
|
|
|
|
input = memory.GetCopy(offset.Int64(), size.Int64())
|
|
|
|
gas = contract.Gas
|
|
|
|
)
|
|
|
|
if interpreter.evm.ChainConfig().IsS3(interpreter.evm.EpochNumber) {
|
|
|
|
gas -= gas / 64
|
|
|
|
}
|
|
|
|
|
|
|
|
contract.UseGas(gas)
|
|
|
|
res, addr, returnGas, suberr := interpreter.evm.Create(contract, input, gas, value)
|
|
|
|
// Push item on the stack based on the returned error. If the ruleset is
|
|
|
|
// homestead we must check for CodeStoreOutOfGasError (homestead only
|
|
|
|
// rule) and treat as an error, if the ruleset is frontier we must
|
|
|
|
// ignore this error and pretend the operation was successful.
|
|
|
|
if interpreter.evm.ChainConfig().IsS3(interpreter.evm.EpochNumber) && suberr == ErrCodeStoreOutOfGas {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else if suberr != nil && suberr != ErrCodeStoreOutOfGas {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(addr.Bytes()))
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
interpreter.intPool.put(value, offset, size)
|
|
|
|
|
|
|
|
if suberr == ErrExecutionReverted {
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCreate2(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
endowment = stack.pop()
|
|
|
|
offset, size = stack.pop(), stack.pop()
|
|
|
|
salt = stack.pop()
|
|
|
|
input = memory.GetCopy(offset.Int64(), size.Int64())
|
|
|
|
gas = contract.Gas
|
|
|
|
)
|
|
|
|
|
|
|
|
// Apply EIP150
|
|
|
|
gas -= gas / 64
|
|
|
|
contract.UseGas(gas)
|
|
|
|
res, addr, returnGas, suberr := interpreter.evm.Create2(contract, input, gas, endowment, salt)
|
|
|
|
// Push item on the stack based on the returned error.
|
|
|
|
if suberr != nil {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetBytes(addr.Bytes()))
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
interpreter.intPool.put(endowment, offset, size, salt)
|
|
|
|
|
|
|
|
if suberr == ErrExecutionReverted {
|
|
|
|
return res, nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Pop gas. The actual gas in interpreter.evm.callGasTemp.
|
|
|
|
interpreter.intPool.put(stack.pop())
|
|
|
|
gas := interpreter.evm.callGasTemp
|
|
|
|
// Pop other call parameters.
|
|
|
|
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
|
|
|
toAddr := common.BigToAddress(addr)
|
|
|
|
value = math.U256(value)
|
|
|
|
// Get the arguments from the memory.
|
|
|
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
|
|
|
|
|
|
|
if value.Sign() != 0 {
|
|
|
|
gas += params.CallStipend
|
|
|
|
}
|
|
|
|
ret, returnGas, err := interpreter.evm.Call(contract, toAddr, args, gas, value)
|
|
|
|
if err != nil {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
|
|
|
}
|
|
|
|
if err == nil || err == ErrExecutionReverted {
|
|
|
|
if contract.WithDataCopyFix {
|
|
|
|
ret = common.CopyBytes(ret)
|
|
|
|
}
|
|
|
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
|
|
|
|
interpreter.intPool.put(addr, value, inOffset, inSize, retOffset, retSize)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opCallCode(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
|
|
|
interpreter.intPool.put(stack.pop())
|
|
|
|
gas := interpreter.evm.callGasTemp
|
|
|
|
// Pop other call parameters.
|
|
|
|
addr, value, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
|
|
|
toAddr := common.BigToAddress(addr)
|
|
|
|
value = math.U256(value)
|
|
|
|
// Get arguments from the memory.
|
|
|
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
|
|
|
|
|
|
|
if value.Sign() != 0 {
|
|
|
|
gas += params.CallStipend
|
|
|
|
}
|
|
|
|
ret, returnGas, err := interpreter.evm.CallCode(contract, toAddr, args, gas, value)
|
|
|
|
if err != nil {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
|
|
|
}
|
|
|
|
if err == nil || err == ErrExecutionReverted {
|
|
|
|
if contract.WithDataCopyFix {
|
|
|
|
ret = common.CopyBytes(ret)
|
|
|
|
}
|
|
|
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
|
|
|
|
interpreter.intPool.put(addr, value, inOffset, inSize, retOffset, retSize)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
|
|
|
interpreter.intPool.put(stack.pop())
|
|
|
|
gas := interpreter.evm.callGasTemp
|
|
|
|
// Pop other call parameters.
|
|
|
|
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
|
|
|
toAddr := common.BigToAddress(addr)
|
|
|
|
// Get arguments from the memory.
|
|
|
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
|
|
|
|
|
|
|
ret, returnGas, err := interpreter.evm.DelegateCall(contract, toAddr, args, gas)
|
|
|
|
if err != nil {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
|
|
|
}
|
|
|
|
if err == nil || err == ErrExecutionReverted {
|
|
|
|
if contract.WithDataCopyFix {
|
|
|
|
ret = common.CopyBytes(ret)
|
|
|
|
}
|
|
|
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
|
|
|
|
interpreter.intPool.put(addr, inOffset, inSize, retOffset, retSize)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opStaticCall(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
// Pop gas. The actual gas is in interpreter.evm.callGasTemp.
|
|
|
|
interpreter.intPool.put(stack.pop())
|
|
|
|
gas := interpreter.evm.callGasTemp
|
|
|
|
// Pop other call parameters.
|
|
|
|
addr, inOffset, inSize, retOffset, retSize := stack.pop(), stack.pop(), stack.pop(), stack.pop(), stack.pop()
|
|
|
|
toAddr := common.BigToAddress(addr)
|
|
|
|
// Get arguments from the memory.
|
|
|
|
args := memory.GetPtr(inOffset.Int64(), inSize.Int64())
|
|
|
|
|
|
|
|
ret, returnGas, err := interpreter.evm.StaticCall(contract, toAddr, args, gas)
|
|
|
|
if err != nil {
|
|
|
|
stack.push(interpreter.intPool.getZero())
|
|
|
|
} else {
|
|
|
|
stack.push(interpreter.intPool.get().SetUint64(1))
|
|
|
|
}
|
|
|
|
if err == nil || err == ErrExecutionReverted {
|
|
|
|
if contract.WithDataCopyFix {
|
|
|
|
ret = common.CopyBytes(ret)
|
|
|
|
}
|
|
|
|
memory.Set(retOffset.Uint64(), retSize.Uint64(), ret)
|
|
|
|
}
|
|
|
|
contract.Gas += returnGas
|
|
|
|
|
|
|
|
interpreter.intPool.put(addr, inOffset, inSize, retOffset, retSize)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opReturn(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
offset, size := stack.pop(), stack.pop()
|
|
|
|
ret := memory.GetPtr(offset.Int64(), size.Int64())
|
|
|
|
|
|
|
|
interpreter.intPool.put(offset, size)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opRevert(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
offset, size := stack.pop(), stack.pop()
|
|
|
|
ret := memory.GetPtr(offset.Int64(), size.Int64())
|
|
|
|
|
|
|
|
interpreter.intPool.put(offset, size)
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opStop(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func opSuicide(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
balance := interpreter.evm.StateDB.GetBalance(contract.Address())
|
|
|
|
interpreter.evm.StateDB.AddBalance(common.BigToAddress(stack.pop()), balance)
|
|
|
|
|
|
|
|
interpreter.evm.StateDB.Suicide(contract.Address())
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// following functions are used by the instruction jump table
|
|
|
|
|
|
|
|
// make log instruction function
|
|
|
|
func makeLog(size int) executionFunc {
|
|
|
|
return func(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
topics := make([]common.Hash, size)
|
|
|
|
mStart, mSize := stack.pop(), stack.pop()
|
|
|
|
for i := 0; i < size; i++ {
|
|
|
|
topics[i] = common.BigToHash(stack.pop())
|
|
|
|
}
|
|
|
|
|
|
|
|
d := memory.GetCopy(mStart.Int64(), mSize.Int64())
|
|
|
|
interpreter.evm.StateDB.AddLog(&types.Log{
|
|
|
|
Address: contract.Address(),
|
|
|
|
Topics: topics,
|
|
|
|
Data: d,
|
|
|
|
// This is a non-consensus field, but assigned here because
|
|
|
|
// core/state doesn't know the current block number.
|
|
|
|
BlockNumber: interpreter.evm.BlockNumber.Uint64(),
|
|
|
|
})
|
|
|
|
|
|
|
|
interpreter.intPool.put(mStart, mSize)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// opPush1 is a specialized version of pushN
|
|
|
|
func opPush1(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
var (
|
|
|
|
codeLen = uint64(len(contract.Code))
|
|
|
|
integer = interpreter.intPool.get()
|
|
|
|
)
|
|
|
|
*pc++
|
|
|
|
if *pc < codeLen {
|
|
|
|
stack.push(integer.SetUint64(uint64(contract.Code[*pc])))
|
|
|
|
} else {
|
|
|
|
stack.push(integer.SetUint64(0))
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// make push instruction function
|
|
|
|
func makePush(size uint64, pushByteSize int) executionFunc {
|
|
|
|
return func(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
codeLen := len(contract.Code)
|
|
|
|
|
|
|
|
startMin := codeLen
|
|
|
|
if int(*pc+1) < startMin {
|
|
|
|
startMin = int(*pc + 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
endMin := codeLen
|
|
|
|
if startMin+pushByteSize < endMin {
|
|
|
|
endMin = startMin + pushByteSize
|
|
|
|
}
|
|
|
|
|
|
|
|
integer := interpreter.intPool.get()
|
|
|
|
stack.push(integer.SetBytes(common.RightPadBytes(contract.Code[startMin:endMin], pushByteSize)))
|
|
|
|
|
|
|
|
*pc += size
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// make dup instruction function
|
|
|
|
func makeDup(size int64) executionFunc {
|
|
|
|
return func(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.dup(interpreter.intPool, int(size))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// make swap instruction function
|
|
|
|
func makeSwap(size int64) executionFunc {
|
|
|
|
// switch n + 1 otherwise n would be swapped with n
|
|
|
|
size++
|
|
|
|
return func(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
|
|
|
|
stack.swap(int(size))
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|