mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
commit
2233a6cc7b
24 changed files with 146 additions and 131 deletions
|
|
@ -162,7 +162,6 @@ func runCmd(ctx *cli.Context) error {
|
||||||
Value: flags.GlobalBig(ctx, ValueFlag.Name),
|
Value: flags.GlobalBig(ctx, ValueFlag.Name),
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Tracer: tracer,
|
Tracer: tracer,
|
||||||
Debug: ctx.Bool(DebugFlag.Name) || ctx.Bool(MachineFlag.Name),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ func stateTestCmd(ctx *cli.Context) error {
|
||||||
// Iterate over all the tests, run them and aggregate the results
|
// Iterate over all the tests, run them and aggregate the results
|
||||||
cfg := vm.Config{
|
cfg := vm.Config{
|
||||||
Tracer: tracer,
|
Tracer: tracer,
|
||||||
Debug: ctx.Bool(DebugFlag.Name) || ctx.Bool(MachineFlag.Name),
|
|
||||||
}
|
}
|
||||||
results := make([]StatetestResult, 0, len(tests))
|
results := make([]StatetestResult, 0, len(tests))
|
||||||
for key, test := range tests {
|
for key, test := range tests {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus"
|
"github.com/XinFinOrg/XDPoSChain/consensus"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
|
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/clique"
|
"github.com/XinFinOrg/XDPoSChain/consensus/clique"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
|
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/state"
|
"github.com/XinFinOrg/XDPoSChain/core/state"
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||||
|
|
@ -206,10 +205,6 @@ func (x *XDPoS_v1) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
||||||
if header.UncleHash != utils.UncleHash {
|
if header.UncleHash != utils.UncleHash {
|
||||||
return utils.ErrInvalidUncleHash
|
return utils.ErrInvalidUncleHash
|
||||||
}
|
}
|
||||||
// If all checks passed, validate any special fields for hard forks
|
|
||||||
if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// All basic checks passed, verify cascading fields
|
// All basic checks passed, verify cascading fields
|
||||||
return x.verifyCascadingFields(chain, header, parents, fullVerify)
|
return x.verifyCascadingFields(chain, header, parents, fullVerify)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
"github.com/XinFinOrg/XDPoSChain/common/hexutil"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus"
|
"github.com/XinFinOrg/XDPoSChain/consensus"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
|
"github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils"
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/misc"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
|
"github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559"
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||||
"github.com/XinFinOrg/XDPoSChain/log"
|
"github.com/XinFinOrg/XDPoSChain/log"
|
||||||
|
|
@ -162,11 +161,6 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade
|
||||||
masterNodes = x.GetMasternodes(chain, header)
|
masterNodes = x.GetMasternodes(chain, header)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all checks passed, validate any special fields for hard forks
|
|
||||||
if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
verified, validatorAddress, err := x.verifyMsgSignature(sigHash(header), header.Validator, masterNodes)
|
verified, validatorAddress, err := x.verifyMsgSignature(sigHash(header), header.Validator, masterNodes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for index, mn := range masterNodes {
|
for index, mn := range masterNodes {
|
||||||
|
|
|
||||||
|
|
@ -328,10 +328,6 @@ func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header,
|
||||||
if header.GasUsed > header.GasLimit {
|
if header.GasUsed > header.GasLimit {
|
||||||
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
|
return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit)
|
||||||
}
|
}
|
||||||
// If all checks passed, validate any special fields for hard forks
|
|
||||||
if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// All basic checks passed, verify cascading fields
|
// All basic checks passed, verify cascading fields
|
||||||
return c.verifyCascadingFields(chain, header, parents)
|
return c.verifyCascadingFields(chain, header, parents)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -283,9 +283,6 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
|
||||||
if err := misc.VerifyDAOHeaderExtraData(chain.Config(), header); err != nil {
|
if err := misc.VerifyDAOHeaderExtraData(chain.Config(), header); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := misc.VerifyForkHashes(chain.Config(), header, uncle); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
// Copyright 2017 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 misc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/params"
|
|
||||||
)
|
|
||||||
|
|
||||||
// VerifyForkHashes verifies that blocks conforming to network hard-forks do have
|
|
||||||
// the correct hashes, to avoid clients going off on different chains. This is an
|
|
||||||
// optional feature.
|
|
||||||
func VerifyForkHashes(config *params.ChainConfig, header *types.Header, uncle bool) error {
|
|
||||||
// We don't care about uncles
|
|
||||||
if uncle {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// If the homestead reprice hash is set, validate it
|
|
||||||
if config.EIP150Block != nil && config.EIP150Block.Cmp(header.Number) == 0 {
|
|
||||||
if config.EIP150Hash != (common.Hash{}) && config.EIP150Hash != header.Hash() {
|
|
||||||
return fmt.Errorf("homestead gas reprice fork: have %#x, want %#x", header.Hash(), config.EIP150Hash)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// All ok, return
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -63,7 +63,7 @@ func (bits *bitvec) codeSegment(pos uint64) bool {
|
||||||
// codeBitmap collects data locations in code.
|
// codeBitmap collects data locations in code.
|
||||||
func codeBitmap(code []byte) bitvec {
|
func codeBitmap(code []byte) bitvec {
|
||||||
// The bitmap is 4 bytes longer than necessary, in case the code
|
// The bitmap is 4 bytes longer than necessary, in case the code
|
||||||
// ends with a PUSH32, the algorithm will push zeroes onto the
|
// ends with a PUSH32, the algorithm will set bits on the
|
||||||
// bitvector outside the bounds of the actual code.
|
// bitvector outside the bounds of the actual code.
|
||||||
bits := make(bitvec, len(code)/8+1+4)
|
bits := make(bitvec, len(code)/8+1+4)
|
||||||
return codeBitmapInternal(code, bits)
|
return codeBitmapInternal(code, bits)
|
||||||
|
|
|
||||||
|
|
@ -121,8 +121,7 @@ type EVM struct {
|
||||||
// used throughout the execution of the tx.
|
// used throughout the execution of the tx.
|
||||||
interpreter *EVMInterpreter
|
interpreter *EVMInterpreter
|
||||||
// abort is used to abort the EVM calling operations
|
// abort is used to abort the EVM calling operations
|
||||||
// NOTE: must be set atomically
|
abort atomic.Bool
|
||||||
abort int32
|
|
||||||
// callGasTemp holds the gas available for the current call. This is needed because the
|
// callGasTemp holds the gas available for the current call. This is needed because the
|
||||||
// available gas is calculated in gasCall* according to the 63/64 rule and later
|
// available gas is calculated in gasCall* according to the 63/64 rule and later
|
||||||
// applied in opCall*.
|
// applied in opCall*.
|
||||||
|
|
@ -156,12 +155,12 @@ func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
|
||||||
// Cancel cancels any running EVM operation. This may be called concurrently and
|
// Cancel cancels any running EVM operation. This may be called concurrently and
|
||||||
// it's safe to be called multiple times.
|
// it's safe to be called multiple times.
|
||||||
func (evm *EVM) Cancel() {
|
func (evm *EVM) Cancel() {
|
||||||
atomic.StoreInt32(&evm.abort, 1)
|
evm.abort.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancelled returns true if Cancel has been called
|
// Cancelled returns true if Cancel has been called
|
||||||
func (evm *EVM) Cancelled() bool {
|
func (evm *EVM) Cancelled() bool {
|
||||||
return atomic.LoadInt32(&evm.abort) == 1
|
return evm.abort.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpreter returns the current interpreter
|
// Interpreter returns the current interpreter
|
||||||
|
|
@ -190,11 +189,12 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
}
|
}
|
||||||
snapshot := evm.StateDB.Snapshot()
|
snapshot := evm.StateDB.Snapshot()
|
||||||
p, isPrecompile := evm.precompile(addr)
|
p, isPrecompile := evm.precompile(addr)
|
||||||
|
debug := evm.Config.Tracer != nil
|
||||||
|
|
||||||
if !evm.StateDB.Exist(addr) {
|
if !evm.StateDB.Exist(addr) {
|
||||||
if !isPrecompile && evm.chainRules.IsEIP158 && value.Sign() == 0 {
|
if !isPrecompile && evm.chainRules.IsEIP158 && value.Sign() == 0 {
|
||||||
// Calling a non existing account, don't do anything, but ping the tracer
|
// Calling a non existing account, don't do anything, but ping the tracer
|
||||||
if evm.Config.Debug {
|
if debug {
|
||||||
if evm.depth == 0 {
|
if evm.depth == 0 {
|
||||||
evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
|
evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
|
||||||
evm.Config.Tracer.CaptureEnd(ret, 0, 0, nil)
|
evm.Config.Tracer.CaptureEnd(ret, 0, 0, nil)
|
||||||
|
|
@ -210,7 +210,7 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
|
||||||
evm.Context.Transfer(evm.StateDB, caller.Address(), addr, value)
|
evm.Context.Transfer(evm.StateDB, caller.Address(), addr, value)
|
||||||
|
|
||||||
// Capture the tracer start/end events in debug mode
|
// Capture the tracer start/end events in debug mode
|
||||||
if evm.Config.Debug {
|
if debug {
|
||||||
if evm.depth == 0 {
|
if evm.depth == 0 {
|
||||||
evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
|
evm.Config.Tracer.CaptureStart(evm, caller.Address(), addr, false, input, gas, value)
|
||||||
|
|
||||||
|
|
@ -281,7 +281,7 @@ func (evm *EVM) CallCode(caller ContractRef, addr common.Address, input []byte,
|
||||||
var snapshot = evm.StateDB.Snapshot()
|
var snapshot = evm.StateDB.Snapshot()
|
||||||
|
|
||||||
// Invoke tracer hooks that signal entering/exiting a call frame
|
// Invoke tracer hooks that signal entering/exiting a call frame
|
||||||
if evm.Config.Debug {
|
if evm.Config.Tracer != nil {
|
||||||
evm.Config.Tracer.CaptureEnter(CALLCODE, caller.Address(), addr, input, gas, value)
|
evm.Config.Tracer.CaptureEnter(CALLCODE, caller.Address(), addr, input, gas, value)
|
||||||
defer func(startGas uint64) {
|
defer func(startGas uint64) {
|
||||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||||
|
|
@ -322,7 +322,7 @@ func (evm *EVM) DelegateCall(caller ContractRef, addr common.Address, input []by
|
||||||
var snapshot = evm.StateDB.Snapshot()
|
var snapshot = evm.StateDB.Snapshot()
|
||||||
|
|
||||||
// Invoke tracer hooks that signal entering/exiting a call frame
|
// Invoke tracer hooks that signal entering/exiting a call frame
|
||||||
if evm.Config.Debug {
|
if evm.Config.Tracer != nil {
|
||||||
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, nil)
|
evm.Config.Tracer.CaptureEnter(DELEGATECALL, caller.Address(), addr, input, gas, nil)
|
||||||
defer func(startGas uint64) {
|
defer func(startGas uint64) {
|
||||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||||
|
|
@ -372,7 +372,7 @@ func (evm *EVM) StaticCall(caller ContractRef, addr common.Address, input []byte
|
||||||
evm.StateDB.AddBalance(addr, big0)
|
evm.StateDB.AddBalance(addr, big0)
|
||||||
|
|
||||||
// Invoke tracer hooks that signal entering/exiting a call frame
|
// Invoke tracer hooks that signal entering/exiting a call frame
|
||||||
if evm.Config.Debug {
|
if evm.Config.Tracer != nil {
|
||||||
evm.Config.Tracer.CaptureEnter(STATICCALL, caller.Address(), addr, input, gas, nil)
|
evm.Config.Tracer.CaptureEnter(STATICCALL, caller.Address(), addr, input, gas, nil)
|
||||||
defer func(startGas uint64) {
|
defer func(startGas uint64) {
|
||||||
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
evm.Config.Tracer.CaptureExit(ret, startGas-gas, err)
|
||||||
|
|
@ -456,7 +456,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
contract := NewContract(caller, AccountRef(address), value, gas)
|
contract := NewContract(caller, AccountRef(address), value, gas)
|
||||||
contract.SetCodeOptionalHash(&address, codeAndHash)
|
contract.SetCodeOptionalHash(&address, codeAndHash)
|
||||||
|
|
||||||
if evm.Config.Debug {
|
if evm.Config.Tracer != nil {
|
||||||
if evm.depth == 0 {
|
if evm.depth == 0 {
|
||||||
evm.Config.Tracer.CaptureStart(evm, caller.Address(), address, true, codeAndHash.code, gas, value)
|
evm.Config.Tracer.CaptureStart(evm, caller.Address(), address, true, codeAndHash.code, gas, value)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -500,7 +500,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if evm.Config.Debug {
|
if evm.Config.Tracer != nil {
|
||||||
if evm.depth == 0 {
|
if evm.depth == 0 {
|
||||||
evm.Config.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err)
|
evm.Config.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
package vm
|
package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
"github.com/XinFinOrg/XDPoSChain/core/types"
|
"github.com/XinFinOrg/XDPoSChain/core/types"
|
||||||
"github.com/XinFinOrg/XDPoSChain/crypto"
|
"github.com/XinFinOrg/XDPoSChain/crypto"
|
||||||
|
|
@ -544,7 +542,7 @@ func opSstore(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b
|
||||||
}
|
}
|
||||||
|
|
||||||
func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
if atomic.LoadInt32(&interpreter.evm.abort) != 0 {
|
if interpreter.evm.abort.Load() {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
pos := scope.Stack.pop()
|
pos := scope.Stack.pop()
|
||||||
|
|
@ -556,7 +554,7 @@ func opJump(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt
|
||||||
}
|
}
|
||||||
|
|
||||||
func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
func opJumpi(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
|
||||||
if atomic.LoadInt32(&interpreter.evm.abort) != 0 {
|
if interpreter.evm.abort.Load() {
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
pos, cond := scope.Stack.pop(), scope.Stack.pop()
|
pos, cond := scope.Stack.pop(), scope.Stack.pop()
|
||||||
|
|
@ -838,9 +836,9 @@ func opSelfdestruct(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext
|
||||||
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
|
balance := interpreter.evm.StateDB.GetBalance(scope.Contract.Address())
|
||||||
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance)
|
interpreter.evm.StateDB.AddBalance(beneficiary.Bytes20(), balance)
|
||||||
interpreter.evm.StateDB.SelfDestruct(scope.Contract.Address())
|
interpreter.evm.StateDB.SelfDestruct(scope.Contract.Address())
|
||||||
if interpreter.evm.Config.Debug {
|
if tracer := interpreter.evm.Config.Tracer; tracer != nil {
|
||||||
interpreter.evm.Config.Tracer.CaptureEnter(SELFDESTRUCT, scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
tracer.CaptureEnter(SELFDESTRUCT, scope.Contract.Address(), beneficiary.Bytes20(), []byte{}, 0, balance)
|
||||||
interpreter.evm.Config.Tracer.CaptureExit([]byte{}, 0, nil)
|
tracer.CaptureExit([]byte{}, 0, nil)
|
||||||
}
|
}
|
||||||
return nil, errStopToken
|
return nil, errStopToken
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import (
|
||||||
|
|
||||||
// Config are the configuration options for the Interpreter
|
// Config are the configuration options for the Interpreter
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Debug bool // Enables debugging
|
|
||||||
Tracer EVMLogger // Opcode logger
|
Tracer EVMLogger // Opcode logger
|
||||||
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
|
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
|
||||||
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
|
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
|
||||||
|
|
@ -145,6 +144,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
gasCopy uint64 // for EVMLogger to log gas remaining before execution
|
gasCopy uint64 // for EVMLogger to log gas remaining before execution
|
||||||
logged bool // deferred EVMLogger should ignore already logged steps
|
logged bool // deferred EVMLogger should ignore already logged steps
|
||||||
res []byte // result of the opcode execution function
|
res []byte // result of the opcode execution function
|
||||||
|
debug = in.evm.Config.Tracer != nil
|
||||||
)
|
)
|
||||||
// Don't move this deferred function, it's placed before the capturestate-deferred method,
|
// Don't move this deferred function, it's placed before the capturestate-deferred method,
|
||||||
// so that it get's executed _after_: the capturestate needs the stacks before
|
// so that it get's executed _after_: the capturestate needs the stacks before
|
||||||
|
|
@ -154,7 +154,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
}()
|
}()
|
||||||
contract.Input = input
|
contract.Input = input
|
||||||
|
|
||||||
if in.evm.Config.Debug {
|
if debug {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !logged {
|
if !logged {
|
||||||
|
|
@ -170,7 +170,7 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
// the execution of one of the operations or until the done flag is set by the
|
// the execution of one of the operations or until the done flag is set by the
|
||||||
// parent context.
|
// parent context.
|
||||||
for {
|
for {
|
||||||
if in.evm.Config.Debug {
|
if debug {
|
||||||
// Capture pre-execution values for tracing.
|
// Capture pre-execution values for tracing.
|
||||||
logged, pcCopy, gasCopy = false, pc, contract.Gas
|
logged, pcCopy, gasCopy = false, pc, contract.Gas
|
||||||
}
|
}
|
||||||
|
|
@ -215,15 +215,16 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
|
||||||
if err != nil || !contract.UseGas(dynamicCost) {
|
if err != nil || !contract.UseGas(dynamicCost) {
|
||||||
return nil, ErrOutOfGas
|
return nil, ErrOutOfGas
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do tracing before memory expansion
|
// Do tracing before memory expansion
|
||||||
if in.evm.Config.Debug {
|
if debug {
|
||||||
in.evm.Config.Tracer.CaptureState(in.evm, pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
|
in.evm.Config.Tracer.CaptureState(in.evm, pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
|
||||||
logged = true
|
logged = true
|
||||||
}
|
}
|
||||||
if memorySize > 0 {
|
if memorySize > 0 {
|
||||||
mem.Resize(memorySize)
|
mem.Resize(memorySize)
|
||||||
}
|
}
|
||||||
} else if in.evm.Config.Debug {
|
} else if debug {
|
||||||
in.evm.Config.Tracer.CaptureState(in.evm, pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
|
in.evm.Config.Tracer.CaptureState(in.evm, pc, op, gasCopy, cost, callContext, in.returnData, in.evm.depth, err)
|
||||||
logged = true
|
logged = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,12 @@ func validate(jt JumpTable) JumpTable {
|
||||||
return jt
|
return jt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newCancunInstructionSet() JumpTable {
|
||||||
|
instructionSet := newEip1559InstructionSet()
|
||||||
|
enable1153(&instructionSet) // EIP-1153 "Transient Storage"
|
||||||
|
return validate(instructionSet)
|
||||||
|
}
|
||||||
|
|
||||||
func newEip1559InstructionSet() JumpTable {
|
func newEip1559InstructionSet() JumpTable {
|
||||||
instructionSet := newShanghaiInstructionSet()
|
instructionSet := newShanghaiInstructionSet()
|
||||||
enable2929(&instructionSet) // Gas cost increases for state access opcodes https://eips.ethereum.org/EIPS/eip-2929
|
enable2929(&instructionSet) // Gas cost increases for state access opcodes https://eips.ethereum.org/EIPS/eip-2929
|
||||||
|
|
|
||||||
72
core/vm/jump_table_export.go
Normal file
72
core/vm/jump_table_export.go
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
// Copyright 2023 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 (
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/params"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LookupInstructionSet returns the instructionset for the fork configured by
|
||||||
|
// the rules.
|
||||||
|
func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
|
||||||
|
switch {
|
||||||
|
case rules.IsCancun:
|
||||||
|
return newCancunInstructionSet(), nil
|
||||||
|
case rules.IsEIP1559:
|
||||||
|
return newEip1559InstructionSet(), nil
|
||||||
|
case rules.IsShanghai:
|
||||||
|
return newShanghaiInstructionSet(), nil
|
||||||
|
case rules.IsMerge:
|
||||||
|
return newMergeInstructionSet(), nil
|
||||||
|
case rules.IsLondon:
|
||||||
|
return newLondonInstructionSet(), nil
|
||||||
|
case rules.IsBerlin:
|
||||||
|
return newBerlinInstructionSet(), nil
|
||||||
|
case rules.IsIstanbul:
|
||||||
|
return newIstanbulInstructionSet(), nil
|
||||||
|
case rules.IsConstantinople:
|
||||||
|
return newConstantinopleInstructionSet(), nil
|
||||||
|
case rules.IsByzantium:
|
||||||
|
return newByzantiumInstructionSet(), nil
|
||||||
|
case rules.IsEIP158:
|
||||||
|
return newSpuriousDragonInstructionSet(), nil
|
||||||
|
case rules.IsEIP150:
|
||||||
|
return newTangerineWhistleInstructionSet(), nil
|
||||||
|
case rules.IsHomestead:
|
||||||
|
return newHomesteadInstructionSet(), nil
|
||||||
|
}
|
||||||
|
return newFrontierInstructionSet(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stack returns the mininum and maximum stack requirements.
|
||||||
|
func (op *operation) Stack() (int, int) {
|
||||||
|
return op.minStack, op.maxStack
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasCost returns true if the opcode has a cost. Opcodes which do _not_ have
|
||||||
|
// a cost assigned are one of two things:
|
||||||
|
// - undefined, a.k.a invalid opcodes,
|
||||||
|
// - the STOP opcode.
|
||||||
|
// This method can thus be used to check if an opcode is "Invalid (or STOP)".
|
||||||
|
func (op *operation) HasCost() bool {
|
||||||
|
// Ideally, we'd check this:
|
||||||
|
// return op.execute == opUndefined
|
||||||
|
// However, go-lang does now allow that. So we'll just check some other
|
||||||
|
// 'indicators' that this is an invalid op. Alas, STOP is impossible to
|
||||||
|
// filter out
|
||||||
|
return op.dynamicGas != nil || op.constantGas != 0
|
||||||
|
}
|
||||||
|
|
@ -285,9 +285,7 @@ var opCodeToString = [256]string{
|
||||||
BASEFEE: "BASEFEE",
|
BASEFEE: "BASEFEE",
|
||||||
|
|
||||||
// 0x50 range - 'storage' and execution.
|
// 0x50 range - 'storage' and execution.
|
||||||
POP: "POP",
|
POP: "POP",
|
||||||
//DUP: "DUP",
|
|
||||||
//SWAP: "SWAP",
|
|
||||||
MLOAD: "MLOAD",
|
MLOAD: "MLOAD",
|
||||||
MSTORE: "MSTORE",
|
MSTORE: "MSTORE",
|
||||||
MSTORE8: "MSTORE8",
|
MSTORE8: "MSTORE8",
|
||||||
|
|
@ -303,7 +301,7 @@ var opCodeToString = [256]string{
|
||||||
TSTORE: "TSTORE",
|
TSTORE: "TSTORE",
|
||||||
PUSH0: "PUSH0",
|
PUSH0: "PUSH0",
|
||||||
|
|
||||||
// 0x60 range - push.
|
// 0x60 range - pushes.
|
||||||
PUSH1: "PUSH1",
|
PUSH1: "PUSH1",
|
||||||
PUSH2: "PUSH2",
|
PUSH2: "PUSH2",
|
||||||
PUSH3: "PUSH3",
|
PUSH3: "PUSH3",
|
||||||
|
|
@ -337,6 +335,7 @@ var opCodeToString = [256]string{
|
||||||
PUSH31: "PUSH31",
|
PUSH31: "PUSH31",
|
||||||
PUSH32: "PUSH32",
|
PUSH32: "PUSH32",
|
||||||
|
|
||||||
|
// 0x80 - dups.
|
||||||
DUP1: "DUP1",
|
DUP1: "DUP1",
|
||||||
DUP2: "DUP2",
|
DUP2: "DUP2",
|
||||||
DUP3: "DUP3",
|
DUP3: "DUP3",
|
||||||
|
|
@ -354,6 +353,7 @@ var opCodeToString = [256]string{
|
||||||
DUP15: "DUP15",
|
DUP15: "DUP15",
|
||||||
DUP16: "DUP16",
|
DUP16: "DUP16",
|
||||||
|
|
||||||
|
// 0x90 - swaps.
|
||||||
SWAP1: "SWAP1",
|
SWAP1: "SWAP1",
|
||||||
SWAP2: "SWAP2",
|
SWAP2: "SWAP2",
|
||||||
SWAP3: "SWAP3",
|
SWAP3: "SWAP3",
|
||||||
|
|
@ -370,19 +370,22 @@ var opCodeToString = [256]string{
|
||||||
SWAP14: "SWAP14",
|
SWAP14: "SWAP14",
|
||||||
SWAP15: "SWAP15",
|
SWAP15: "SWAP15",
|
||||||
SWAP16: "SWAP16",
|
SWAP16: "SWAP16",
|
||||||
LOG0: "LOG0",
|
|
||||||
LOG1: "LOG1",
|
|
||||||
LOG2: "LOG2",
|
|
||||||
LOG3: "LOG3",
|
|
||||||
LOG4: "LOG4",
|
|
||||||
|
|
||||||
// 0xf0 range.
|
// 0xa0 range - logging ops.
|
||||||
|
LOG0: "LOG0",
|
||||||
|
LOG1: "LOG1",
|
||||||
|
LOG2: "LOG2",
|
||||||
|
LOG3: "LOG3",
|
||||||
|
LOG4: "LOG4",
|
||||||
|
|
||||||
|
// 0xf0 range - closures.
|
||||||
CREATE: "CREATE",
|
CREATE: "CREATE",
|
||||||
CALL: "CALL",
|
CALL: "CALL",
|
||||||
RETURN: "RETURN",
|
RETURN: "RETURN",
|
||||||
CALLCODE: "CALLCODE",
|
CALLCODE: "CALLCODE",
|
||||||
DELEGATECALL: "DELEGATECALL",
|
DELEGATECALL: "DELEGATECALL",
|
||||||
CREATE2: "CREATE2",
|
CREATE2: "CREATE2",
|
||||||
|
|
||||||
STATICCALL: "STATICCALL",
|
STATICCALL: "STATICCALL",
|
||||||
REVERT: "REVERT",
|
REVERT: "REVERT",
|
||||||
INVALID: "INVALID",
|
INVALID: "INVALID",
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ func setDefaults(cfg *Config) {
|
||||||
DAOForkBlock: new(big.Int),
|
DAOForkBlock: new(big.Int),
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: new(big.Int),
|
EIP150Block: new(big.Int),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: new(big.Int),
|
EIP155Block: new(big.Int),
|
||||||
EIP158Block: new(big.Int),
|
EIP158Block: new(big.Int),
|
||||||
ByzantiumBlock: new(big.Int),
|
ByzantiumBlock: new(big.Int),
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,6 @@ func TestEip2929Cases(t *testing.T) {
|
||||||
code, ops)
|
code, ops)
|
||||||
Execute(code, nil, &Config{
|
Execute(code, nil, &Config{
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Debug: true,
|
|
||||||
Tracer: vm.NewMarkdownLogger(nil, os.Stdout),
|
Tracer: vm.NewMarkdownLogger(nil, os.Stdout),
|
||||||
ExtraEips: []int{2929},
|
ExtraEips: []int{2929},
|
||||||
},
|
},
|
||||||
|
|
@ -664,7 +663,6 @@ func TestColdAccountAccessCost(t *testing.T) {
|
||||||
tracer := vm.NewStructLogger(nil)
|
tracer := vm.NewStructLogger(nil)
|
||||||
Execute(tc.code, nil, &Config{
|
Execute(tc.code, nil, &Config{
|
||||||
EVMConfig: vm.Config{
|
EVMConfig: vm.Config{
|
||||||
Debug: true,
|
|
||||||
Tracer: tracer,
|
Tracer: tracer,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -749,7 +749,7 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, t
|
||||||
tracer = vm.NewStructLogger(config.LogConfig)
|
tracer = vm.NewStructLogger(config.LogConfig)
|
||||||
}
|
}
|
||||||
// Run the transaction with tracing enabled.
|
// Run the transaction with tracing enabled.
|
||||||
vmenv := vm.NewEVM(vmctx, txContext, statedb, nil, api.config, vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true})
|
vmenv := vm.NewEVM(vmctx, txContext, statedb, nil, api.config, vm.Config{Tracer: tracer, NoBaseFee: true})
|
||||||
|
|
||||||
// Call SetTxContext to clear out the statedb access list
|
// Call SetTxContext to clear out the statedb access list
|
||||||
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)
|
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create call tracer: %v", err)
|
t.Fatalf("failed to create call tracer: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Tracer: tracer})
|
||||||
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
|
|
@ -229,7 +229,7 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("failed to create call tracer: %v", err)
|
b.Fatalf("failed to create call tracer: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Tracer: tracer})
|
||||||
snap := statedb.Snapshot()
|
snap := statedb.Snapshot()
|
||||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||||
if _, err = st.TransitionDb(common.Address{}); err != nil {
|
if _, err = st.TransitionDb(common.Address{}); err != nil {
|
||||||
|
|
@ -299,7 +299,7 @@ func testContractTracer(tracerName string, dirPath string, t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create call tracer: %v", err)
|
t.Fatalf("failed to create call tracer: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, test.Genesis.Config, vm.Config{Tracer: tracer})
|
||||||
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func runTrace(tracer Tracer, blockNumber *big.Int, chaincfg *params.ChainConfig)
|
||||||
txContext = vm.TxContext{GasPrice: big.NewInt(100000)}
|
txContext = vm.TxContext{GasPrice: big.NewInt(100000)}
|
||||||
)
|
)
|
||||||
|
|
||||||
env := vm.NewEVM(ctx, txContext, &dummyStatedb{}, nil, chaincfg, vm.Config{Debug: true, Tracer: tracer})
|
env := vm.NewEVM(ctx, txContext, &dummyStatedb{}, nil, chaincfg, vm.Config{Tracer: tracer})
|
||||||
|
|
||||||
contract := vm.NewContract(account{}, account{}, value, startGas)
|
contract := vm.NewContract(account{}, account{}, value, startGas)
|
||||||
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}
|
||||||
|
|
@ -149,7 +149,7 @@ func TestHaltBetweenSteps(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{}, &dummyStatedb{}, nil, params.TestChainConfig, vm.Config{Debug: true, Tracer: tracer})
|
env := vm.NewEVM(vm.BlockContext{BlockNumber: big.NewInt(1)}, vm.TxContext{}, &dummyStatedb{}, nil, params.TestChainConfig, vm.Config{Tracer: tracer})
|
||||||
scope := &vm.ScopeContext{
|
scope := &vm.ScopeContext{
|
||||||
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
Contract: vm.NewContract(&account{}, &account{}, big.NewInt(0), 0),
|
||||||
}
|
}
|
||||||
|
|
@ -169,7 +169,7 @@ func TestNoStepExec(t *testing.T) {
|
||||||
runEmptyTrace := func(tracer Tracer) (json.RawMessage, error) {
|
runEmptyTrace := func(tracer Tracer) (json.RawMessage, error) {
|
||||||
ctx := vm.BlockContext{BlockNumber: big.NewInt(1)}
|
ctx := vm.BlockContext{BlockNumber: big.NewInt(1)}
|
||||||
txContext := vm.TxContext{GasPrice: big.NewInt(100000)}
|
txContext := vm.TxContext{GasPrice: big.NewInt(100000)}
|
||||||
env := vm.NewEVM(ctx, txContext, &dummyStatedb{}, nil, params.TestChainConfig, vm.Config{Debug: true, Tracer: tracer})
|
env := vm.NewEVM(ctx, txContext, &dummyStatedb{}, nil, params.TestChainConfig, vm.Config{Tracer: tracer})
|
||||||
startGas := uint64(10000)
|
startGas := uint64(10000)
|
||||||
contract := vm.NewContract(account{}, account{}, big.NewInt(0), startGas)
|
contract := vm.NewContract(account{}, account{}, big.NewInt(0), startGas)
|
||||||
tracer.CaptureStart(env, contract.Caller(), contract.Address(), false, []byte{}, startGas, big.NewInt(0))
|
tracer.CaptureStart(env, contract.Caller(), contract.Address(), false, []byte{}, startGas, big.NewInt(0))
|
||||||
|
|
@ -204,7 +204,23 @@ func TestNoStepExec(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsPrecompile(t *testing.T) {
|
func TestIsPrecompile(t *testing.T) {
|
||||||
chaincfg := ¶ms.ChainConfig{ChainId: big.NewInt(1), HomesteadBlock: big.NewInt(0), DAOForkBlock: nil, DAOForkSupport: false, EIP150Block: big.NewInt(0), EIP150Hash: common.Hash{}, EIP155Block: big.NewInt(0), EIP158Block: big.NewInt(0), ByzantiumBlock: big.NewInt(100), ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(200), BerlinBlock: big.NewInt(300), LondonBlock: big.NewInt(0), Ethash: new(params.EthashConfig), Clique: nil}
|
chaincfg := ¶ms.ChainConfig{
|
||||||
|
ChainId: big.NewInt(1),
|
||||||
|
HomesteadBlock: big.NewInt(0),
|
||||||
|
DAOForkBlock: nil,
|
||||||
|
DAOForkSupport: false,
|
||||||
|
EIP150Block: big.NewInt(0),
|
||||||
|
EIP155Block: big.NewInt(0),
|
||||||
|
EIP158Block: big.NewInt(0),
|
||||||
|
ByzantiumBlock: big.NewInt(100),
|
||||||
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
|
PetersburgBlock: big.NewInt(0),
|
||||||
|
IstanbulBlock: big.NewInt(200),
|
||||||
|
BerlinBlock: big.NewInt(300),
|
||||||
|
LondonBlock: big.NewInt(0),
|
||||||
|
Ethash: new(params.EthashConfig),
|
||||||
|
Clique: nil,
|
||||||
|
}
|
||||||
chaincfg.ByzantiumBlock = big.NewInt(100)
|
chaincfg.ByzantiumBlock = big.NewInt(100)
|
||||||
chaincfg.IstanbulBlock = big.NewInt(200)
|
chaincfg.IstanbulBlock = big.NewInt(200)
|
||||||
chaincfg.BerlinBlock = big.NewInt(300)
|
chaincfg.BerlinBlock = big.NewInt(300)
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ func TestZeroValueToNotExitCall(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create call tracer: %v", err)
|
t.Fatalf("failed to create call tracer: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, params.MainnetChainConfig, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, params.MainnetChainConfig, vm.Config{Tracer: tracer})
|
||||||
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
|
|
@ -237,7 +237,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create call tracer: %v", err)
|
t.Fatalf("failed to create call tracer: %v", err)
|
||||||
}
|
}
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, params.MainnetChainConfig, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, params.MainnetChainConfig, vm.Config{Tracer: tracer})
|
||||||
|
|
||||||
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -335,7 +335,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
|
||||||
//EnableMemory: false,
|
//EnableMemory: false,
|
||||||
//EnableReturnData: false,
|
//EnableReturnData: false,
|
||||||
})
|
})
|
||||||
evm := vm.NewEVM(context, txContext, statedb, nil, params.AllEthashProtocolChanges, vm.Config{Debug: true, Tracer: tracer})
|
evm := vm.NewEVM(context, txContext, statedb, nil, params.AllEthashProtocolChanges, vm.Config{Tracer: tracer})
|
||||||
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
msg, err := tx.AsMessage(signer, nil, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatalf("failed to prepare transaction for tracing: %v", err)
|
b.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -2064,7 +2064,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
|
||||||
|
|
||||||
// Apply the transaction with the access list tracer
|
// Apply the transaction with the access list tracer
|
||||||
tracer := vm.NewAccessListTracer(accessList, args.from(), to, precompiles)
|
tracer := vm.NewAccessListTracer(accessList, args.from(), to, precompiles)
|
||||||
config := vm.Config{Tracer: tracer, Debug: true, NoBaseFee: true}
|
config := vm.Config{Tracer: tracer, NoBaseFee: true}
|
||||||
vmenv, _, err := b.GetEVM(ctx, msg, statedb, XDCxState, header, &config)
|
vmenv, _, err := b.GetEVM(ctx, msg, statedb, XDCxState, header, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, nil, err
|
return nil, 0, nil, err
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,6 @@ var (
|
||||||
ChainId: big.NewInt(50),
|
ChainId: big.NewInt(50),
|
||||||
HomesteadBlock: big.NewInt(1),
|
HomesteadBlock: big.NewInt(1),
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
EIP155Block: big.NewInt(3),
|
EIP155Block: big.NewInt(3),
|
||||||
EIP158Block: big.NewInt(3),
|
EIP158Block: big.NewInt(3),
|
||||||
ByzantiumBlock: big.NewInt(4),
|
ByzantiumBlock: big.NewInt(4),
|
||||||
|
|
@ -182,7 +181,6 @@ var (
|
||||||
DAOForkBlock: big.NewInt(1920000),
|
DAOForkBlock: big.NewInt(1920000),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(2463000),
|
EIP150Block: big.NewInt(2463000),
|
||||||
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
|
|
||||||
EIP155Block: big.NewInt(2675000),
|
EIP155Block: big.NewInt(2675000),
|
||||||
EIP158Block: big.NewInt(2675000),
|
EIP158Block: big.NewInt(2675000),
|
||||||
ByzantiumBlock: big.NewInt(4370000),
|
ByzantiumBlock: big.NewInt(4370000),
|
||||||
|
|
@ -197,7 +195,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
EIP155Block: big.NewInt(3),
|
EIP155Block: big.NewInt(3),
|
||||||
EIP158Block: big.NewInt(3),
|
EIP158Block: big.NewInt(3),
|
||||||
ByzantiumBlock: big.NewInt(4),
|
ByzantiumBlock: big.NewInt(4),
|
||||||
|
|
@ -223,7 +220,6 @@ var (
|
||||||
ChainId: big.NewInt(551),
|
ChainId: big.NewInt(551),
|
||||||
HomesteadBlock: big.NewInt(1),
|
HomesteadBlock: big.NewInt(1),
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
||||||
EIP155Block: big.NewInt(3),
|
EIP155Block: big.NewInt(3),
|
||||||
EIP158Block: big.NewInt(3),
|
EIP158Block: big.NewInt(3),
|
||||||
ByzantiumBlock: big.NewInt(4),
|
ByzantiumBlock: big.NewInt(4),
|
||||||
|
|
@ -250,7 +246,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(2),
|
EIP150Block: big.NewInt(2),
|
||||||
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
|
|
||||||
EIP155Block: big.NewInt(3),
|
EIP155Block: big.NewInt(3),
|
||||||
EIP158Block: big.NewInt(3),
|
EIP158Block: big.NewInt(3),
|
||||||
ByzantiumBlock: big.NewInt(1035301),
|
ByzantiumBlock: big.NewInt(1035301),
|
||||||
|
|
@ -278,7 +273,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
|
@ -299,7 +293,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
|
@ -315,7 +308,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
|
@ -332,7 +324,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
|
@ -360,7 +351,6 @@ var (
|
||||||
DAOForkBlock: nil,
|
DAOForkBlock: nil,
|
||||||
DAOForkSupport: false,
|
DAOForkSupport: false,
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP150Hash: common.Hash{},
|
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
|
|
@ -386,9 +376,7 @@ type ChainConfig struct {
|
||||||
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
||||||
|
|
||||||
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
|
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
|
||||||
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
|
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
|
||||||
EIP150Hash common.Hash `json:"eip150Hash,omitempty"` // EIP150 HF hash (needed for header only clients as only gas pricing changed)
|
|
||||||
|
|
||||||
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
|
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
|
||||||
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
|
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,9 @@
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/params"
|
"github.com/XinFinOrg/XDPoSChain/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -32,7 +30,6 @@ var (
|
||||||
DAOForkBlock: big.NewInt(1920000),
|
DAOForkBlock: big.NewInt(1920000),
|
||||||
DAOForkSupport: true,
|
DAOForkSupport: true,
|
||||||
EIP150Block: big.NewInt(2463000),
|
EIP150Block: big.NewInt(2463000),
|
||||||
EIP150Hash: common.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
|
|
||||||
EIP155Block: big.NewInt(2675000),
|
EIP155Block: big.NewInt(2675000),
|
||||||
EIP158Block: big.NewInt(2675000),
|
EIP158Block: big.NewInt(2675000),
|
||||||
ByzantiumBlock: big.NewInt(4370000),
|
ByzantiumBlock: big.NewInt(4370000),
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ func withTrace(t *testing.T, gasLimit uint64, test func(vm.Config) error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tracer := vm.NewStructLogger(nil)
|
tracer := vm.NewStructLogger(nil)
|
||||||
config.Debug, config.Tracer = true, tracer
|
config.Tracer = tracer
|
||||||
err2 := test(config)
|
err2 := test(config)
|
||||||
if !reflect.DeepEqual(err, err2) {
|
if !reflect.DeepEqual(err, err2) {
|
||||||
t.Errorf("different error for second run: %v", err2)
|
t.Errorf("different error for second run: %v", err2)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue