mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
resolve conflicts
This commit is contained in:
parent
9ecc4274eb
commit
7654bc2cb9
19 changed files with 40 additions and 384 deletions
|
|
@ -292,8 +292,15 @@ func writeAuthors(files []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write sorted list of authors back to the file.
|
// Write sorted list of authors back to the file.
|
||||||
slices.SortFunc(list, func(a, b string) bool {
|
slices.SortFunc(list, func(a, b string) int {
|
||||||
return strings.ToLower(a) < strings.ToLower(b)
|
al := strings.ToLower(a)
|
||||||
|
bl := strings.ToLower(b)
|
||||||
|
if al < bl {
|
||||||
|
return -1
|
||||||
|
} else if al == bl {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return 1
|
||||||
})
|
})
|
||||||
content := new(bytes.Buffer)
|
content := new(bytes.Buffer)
|
||||||
content.WriteString(authorsFileHeader)
|
content.WriteString(authorsFileHeader)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
|
estate "github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||||
"github.com/ethereum/go-ethereum/tests"
|
"github.com/ethereum/go-ethereum/tests"
|
||||||
|
|
@ -89,7 +90,7 @@ func blockTestCmd(ctx *cli.Context) error {
|
||||||
if err := test.Run(false, rawdb.HashScheme, tracer, func(res error, chain *core.BlockChain) {
|
if err := test.Run(false, rawdb.HashScheme, tracer, func(res error, chain *core.BlockChain) {
|
||||||
if ctx.Bool(DumpFlag.Name) {
|
if ctx.Bool(DumpFlag.Name) {
|
||||||
if state, _ := chain.State(); state != nil {
|
if state, _ := chain.State(); state != nil {
|
||||||
fmt.Println(string(state.Dump(nil)))
|
fmt.Println(string(state.(*estate.StateDB).Dump(nil)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error {
|
||||||
for _, st := range test.Subtests() {
|
for _, st := range test.Subtests() {
|
||||||
// Run the test and aggregate the result
|
// Run the test and aggregate the result
|
||||||
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
|
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
|
||||||
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, statedb *state.StateDB) {
|
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, statedb vm.StateDB) {
|
||||||
var root common.Hash
|
var root common.Hash
|
||||||
if statedb != nil {
|
if statedb != nil {
|
||||||
root = statedb.IntermediateRoot(false)
|
root = statedb.IntermediateRoot(false)
|
||||||
|
|
@ -109,7 +109,7 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error {
|
||||||
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
|
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
|
||||||
}
|
}
|
||||||
if dump { // Dump any state to aid debugging
|
if dump { // Dump any state to aid debugging
|
||||||
cpy, _ := state.New(root, statedb.Database(), nil)
|
cpy, _ := state.New(root, statedb.(*state.StateDB).Database(), nil)
|
||||||
dump := cpy.RawDump(nil)
|
dump := cpy.RawDump(nil)
|
||||||
result.State = &dump
|
result.State = &dump
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,8 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/ethdb/remotedb"
|
"github.com/ethereum/go-ethereum/ethdb/remotedb"
|
||||||
"github.com/ethereum/go-ethereum/ethstats"
|
"github.com/ethereum/go-ethereum/ethstats"
|
||||||
"github.com/ethereum/go-ethereum/graphql"
|
"github.com/ethereum/go-ethereum/graphql"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
"github.com/ethereum/go-ethereum/lib/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/internal/flags"
|
"github.com/ethereum/go-ethereum/lib/flags"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/metrics/exp"
|
"github.com/ethereum/go-ethereum/metrics/exp"
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ func (test *snapshotTest) run() bool {
|
||||||
for i, action := range test.actions {
|
for i, action := range test.actions {
|
||||||
if len(test.snapshots) > sindex && i == test.snapshots[sindex] {
|
if len(test.snapshots) > sindex && i == test.snapshots[sindex] {
|
||||||
snapshotRevs[sindex] = state.Snapshot()
|
snapshotRevs[sindex] = state.Snapshot()
|
||||||
checkstates[sindex] = state.Copy()
|
checkstates[sindex] = state.Copy().(*StateDB)
|
||||||
sindex++
|
sindex++
|
||||||
}
|
}
|
||||||
action.fn(action, state)
|
action.fn(action, state)
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,13 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// 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/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
package vm
|
package vm_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FuzzPrecompiledContracts(f *testing.F) {
|
func FuzzPrecompiledContracts(f *testing.F) {
|
||||||
|
|
@ -36,7 +37,7 @@ func FuzzPrecompiledContracts(f *testing.F) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
inWant := string(input)
|
inWant := string(input)
|
||||||
RunPrecompiledContract(p, input, gas)
|
vm.RunPrecompiledContract(p, nil, common.Address{}, input, gas)
|
||||||
if inHave := string(input); inWant != inHave {
|
if inHave := string(input); inWant != inHave {
|
||||||
t.Errorf("Precompiled %v modified input data", a)
|
t.Errorf("Precompiled %v modified input data", a)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,10 @@ func (evm *EVM) GetInterpreter() *EVMInterpreter {
|
||||||
return evm.interpreter
|
return evm.interpreter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (evm *EVM) SetInterpreter(i *EVMInterpreter) {
|
||||||
|
evm.interpreter = i
|
||||||
|
}
|
||||||
|
|
||||||
// Reset resets the EVM with a new transaction context.Reset
|
// Reset resets the EVM with a new transaction context.Reset
|
||||||
// This is not threadsafe and should only be done very cautiously.
|
// This is not threadsafe and should only be done very cautiously.
|
||||||
func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
|
func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ func (api *DebugAPI) AccountRange(blockNrOrHash rpc.BlockNumberOrHash, start hex
|
||||||
if maxResults > AccountRangeMaxResults || maxResults <= 0 {
|
if maxResults > AccountRangeMaxResults || maxResults <= 0 {
|
||||||
opts.Max = AccountRangeMaxResults
|
opts.Max = AccountRangeMaxResults
|
||||||
}
|
}
|
||||||
return stateDb.RawDump(opts), nil
|
return stateDb.(*state.StateDB).RawDump(opts), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageRangeResult is the result of a debug_storageRangeAt API call.
|
// StorageRangeResult is the result of a debug_storageRangeAt API call.
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
|
@ -41,7 +40,7 @@ type Options struct {
|
||||||
Config *params.ChainConfig // Chain configuration for hard fork selection
|
Config *params.ChainConfig // Chain configuration for hard fork selection
|
||||||
Chain core.ChainContext // Chain context to access past block hashes
|
Chain core.ChainContext // Chain context to access past block hashes
|
||||||
Header *types.Header // Header defining the block context to execute in
|
Header *types.Header // Header defining the block context to execute in
|
||||||
State *state.StateDB // Pre-state on top of which to estimate the gas
|
State vm.StateDB // Pre-state on top of which to estimate the gas
|
||||||
|
|
||||||
ErrorRatio float64 // Allowed overestimation ratio for faster estimation termination
|
ErrorRatio float64 // Allowed overestimation ratio for faster estimation termination
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -873,7 +873,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
block *types.Block
|
block *types.Block
|
||||||
statedb *state.StateDB
|
statedb vm.StateDB
|
||||||
release StateReleaseFunc
|
release StateReleaseFunc
|
||||||
)
|
)
|
||||||
if hash, ok := blockNrOrHash.Hash(); ok {
|
if hash, ok := blockNrOrHash.Hash(); ok {
|
||||||
|
|
|
||||||
|
|
@ -1,336 +0,0 @@
|
||||||
// Copyright 2016 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 les
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"math/big"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum"
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/consensus"
|
|
||||||
"github.com/ethereum/go-ethereum/core"
|
|
||||||
"github.com/ethereum/go-ethereum/core/bloombits"
|
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
|
||||||
"github.com/ethereum/go-ethereum/eth/gasprice"
|
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
|
||||||
"github.com/ethereum/go-ethereum/event"
|
|
||||||
"github.com/ethereum/go-ethereum/light"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
|
||||||
)
|
|
||||||
|
|
||||||
type LesApiBackend struct {
|
|
||||||
extRPCEnabled bool
|
|
||||||
allowUnprotectedTxs bool
|
|
||||||
eth *LightEthereum
|
|
||||||
gpo *gasprice.Oracle
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) ChainConfig() *params.ChainConfig {
|
|
||||||
return b.eth.chainConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) CurrentBlock() *types.Header {
|
|
||||||
return b.eth.BlockChain().CurrentHeader()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SetHead(number uint64) {
|
|
||||||
b.eth.blockchain.SetHead(number)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) {
|
|
||||||
// Return the latest current as the pending one since there
|
|
||||||
// is no pending notion in the light client. TODO(rjl493456442)
|
|
||||||
// unify the behavior of `HeaderByNumber` and `PendingBlockAndReceipts`.
|
|
||||||
if number == rpc.PendingBlockNumber {
|
|
||||||
return b.eth.blockchain.CurrentHeader(), nil
|
|
||||||
}
|
|
||||||
if number == rpc.LatestBlockNumber {
|
|
||||||
return b.eth.blockchain.CurrentHeader(), nil
|
|
||||||
}
|
|
||||||
return b.eth.blockchain.GetHeaderByNumberOdr(ctx, uint64(number))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) {
|
|
||||||
if blockNr, ok := blockNrOrHash.Number(); ok {
|
|
||||||
return b.HeaderByNumber(ctx, blockNr)
|
|
||||||
}
|
|
||||||
if hash, ok := blockNrOrHash.Hash(); ok {
|
|
||||||
header, err := b.HeaderByHash(ctx, hash)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if header == nil {
|
|
||||||
return nil, errors.New("header for hash not found")
|
|
||||||
}
|
|
||||||
if blockNrOrHash.RequireCanonical && b.eth.blockchain.GetCanonicalHash(header.Number.Uint64()) != hash {
|
|
||||||
return nil, errors.New("hash is not currently canonical")
|
|
||||||
}
|
|
||||||
return header, nil
|
|
||||||
}
|
|
||||||
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) {
|
|
||||||
return b.eth.blockchain.GetHeaderByHash(hash), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
|
||||||
header, err := b.HeaderByNumber(ctx, number)
|
|
||||||
if header == nil || err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return b.BlockByHash(ctx, header.Hash())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
|
|
||||||
return b.eth.blockchain.GetBlockByHash(ctx, hash)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) {
|
|
||||||
if blockNr, ok := blockNrOrHash.Number(); ok {
|
|
||||||
return b.BlockByNumber(ctx, blockNr)
|
|
||||||
}
|
|
||||||
if hash, ok := blockNrOrHash.Hash(); ok {
|
|
||||||
block, err := b.BlockByHash(ctx, hash)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if block == nil {
|
|
||||||
return nil, errors.New("header found, but block body is missing")
|
|
||||||
}
|
|
||||||
if blockNrOrHash.RequireCanonical && b.eth.blockchain.GetCanonicalHash(block.NumberU64()) != hash {
|
|
||||||
return nil, errors.New("hash is not currently canonical")
|
|
||||||
}
|
|
||||||
return block, nil
|
|
||||||
}
|
|
||||||
return nil, errors.New("invalid arguments; neither block nor hash specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
|
|
||||||
return light.GetBody(ctx, b.eth.odr, hash, uint64(number))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) PendingBlockAndReceipts() (*types.Block, types.Receipts) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (vm.StateDB, *types.Header, error) {
|
|
||||||
header, err := b.HeaderByNumber(ctx, number)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
if header == nil {
|
|
||||||
return nil, nil, errors.New("header not found")
|
|
||||||
}
|
|
||||||
return light.NewState(ctx, header, b.eth.odr), header, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (vm.StateDB, *types.Header, error) {
|
|
||||||
if blockNr, ok := blockNrOrHash.Number(); ok {
|
|
||||||
return b.StateAndHeaderByNumber(ctx, blockNr)
|
|
||||||
}
|
|
||||||
if hash, ok := blockNrOrHash.Hash(); ok {
|
|
||||||
header := b.eth.blockchain.GetHeaderByHash(hash)
|
|
||||||
if header == nil {
|
|
||||||
return nil, nil, errors.New("header for hash not found")
|
|
||||||
}
|
|
||||||
if blockNrOrHash.RequireCanonical && b.eth.blockchain.GetCanonicalHash(header.Number.Uint64()) != hash {
|
|
||||||
return nil, nil, errors.New("hash is not currently canonical")
|
|
||||||
}
|
|
||||||
return light.NewState(ctx, header, b.eth.odr), header, nil
|
|
||||||
}
|
|
||||||
return nil, nil, errors.New("invalid arguments; neither block nor hash specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
|
|
||||||
if number := rawdb.ReadHeaderNumber(b.eth.chainDb, hash); number != nil {
|
|
||||||
return light.GetBlockReceipts(ctx, b.eth.odr, hash, *number)
|
|
||||||
}
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
|
|
||||||
return light.GetBlockLogs(ctx, b.eth.odr, hash, number)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int {
|
|
||||||
if number := rawdb.ReadHeaderNumber(b.eth.chainDb, hash); number != nil {
|
|
||||||
return b.eth.blockchain.GetTdOdr(ctx, hash, *number)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetEVM(ctx context.Context, msg *core.Message, state vm.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) (*vm.EVM, func() error) {
|
|
||||||
if vmConfig == nil {
|
|
||||||
vmConfig = new(vm.Config)
|
|
||||||
}
|
|
||||||
txContext := core.NewEVMTxContext(msg)
|
|
||||||
context := core.NewEVMBlockContext(header, b.eth.blockchain, nil)
|
|
||||||
if blockCtx != nil {
|
|
||||||
context = *blockCtx
|
|
||||||
}
|
|
||||||
return vm.NewEVM(context, txContext, state, b.eth.chainConfig, *vmConfig), state.Error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
|
|
||||||
return b.eth.txPool.Add(ctx, signedTx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) RemoveTx(txHash common.Hash) {
|
|
||||||
b.eth.txPool.RemoveTx(txHash)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetPoolTransactions() (types.Transactions, error) {
|
|
||||||
return b.eth.txPool.GetTransactions()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetPoolTransaction(txHash common.Hash) *types.Transaction {
|
|
||||||
return b.eth.txPool.GetTransaction(txHash)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetTransaction(ctx context.Context, txHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) {
|
|
||||||
return light.GetTransaction(ctx, b.eth.odr, txHash)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error) {
|
|
||||||
return b.eth.txPool.GetNonce(ctx, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) Stats() (pending int, queued int) {
|
|
||||||
return b.eth.txPool.Stats(), 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) TxPoolContent() (map[common.Address][]*types.Transaction, map[common.Address][]*types.Transaction) {
|
|
||||||
return b.eth.txPool.Content()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) TxPoolContentFrom(addr common.Address) ([]*types.Transaction, []*types.Transaction) {
|
|
||||||
return b.eth.txPool.ContentFrom(addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
|
|
||||||
return b.eth.txPool.SubscribeNewTxsEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription {
|
|
||||||
return b.eth.blockchain.SubscribeChainEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription {
|
|
||||||
return b.eth.blockchain.SubscribeChainHeadEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription {
|
|
||||||
return b.eth.blockchain.SubscribeChainSideEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
|
|
||||||
return b.eth.blockchain.SubscribeLogsEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Subscription {
|
|
||||||
return event.NewSubscription(func(quit <-chan struct{}) error {
|
|
||||||
<-quit
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
|
|
||||||
return b.eth.blockchain.SubscribeRemovedLogsEvent(ch)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SyncProgress() ethereum.SyncProgress {
|
|
||||||
return ethereum.SyncProgress{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) ProtocolVersion() int {
|
|
||||||
return b.eth.LesVersion() + 10000
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
|
|
||||||
return b.gpo.SuggestTipCap(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) FeeHistory(ctx context.Context, blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (firstBlock *big.Int, reward [][]*big.Int, baseFee []*big.Int, gasUsedRatio []float64, err error) {
|
|
||||||
return b.gpo.FeeHistory(ctx, blockCount, lastBlock, rewardPercentiles)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) ChainDb() ethdb.Database {
|
|
||||||
return b.eth.chainDb
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) AccountManager() *accounts.Manager {
|
|
||||||
return b.eth.accountManager
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) ExtRPCEnabled() bool {
|
|
||||||
return b.extRPCEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) UnprotectedAllowed() bool {
|
|
||||||
return b.allowUnprotectedTxs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) RPCGasCap() uint64 {
|
|
||||||
return b.eth.config.RPCGasCap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) RPCEVMTimeout() time.Duration {
|
|
||||||
return b.eth.config.RPCEVMTimeout
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) RPCTxFeeCap() float64 {
|
|
||||||
return b.eth.config.RPCTxFeeCap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) BloomStatus() (uint64, uint64) {
|
|
||||||
if b.eth.bloomIndexer == nil {
|
|
||||||
return 0, 0
|
|
||||||
}
|
|
||||||
sections, _, _ := b.eth.bloomIndexer.Sections()
|
|
||||||
return params.BloomBitsBlocksClient, sections
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
|
|
||||||
for i := 0; i < bloomFilterThreads; i++ {
|
|
||||||
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, b.eth.bloomRequests)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) Engine() consensus.Engine {
|
|
||||||
return b.eth.engine
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) CurrentHeader() *types.Header {
|
|
||||||
return b.eth.blockchain.CurrentHeader()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) StateAtBlock(ctx context.Context, block *types.Block, reexec uint64, base vm.StateDB, readOnly bool, preferDisk bool) (vm.StateDB, tracers.StateReleaseFunc, error) {
|
|
||||||
return b.eth.stateAtBlock(ctx, block, reexec)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *LesApiBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*core.Message, vm.BlockContext, vm.StateDB, tracers.StateReleaseFunc, error) {
|
|
||||||
return b.eth.stateAtTransaction(ctx, block, txIndex, reexec)
|
|
||||||
}
|
|
||||||
|
|
@ -32,7 +32,7 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/reexec"
|
"github.com/ethereum/go-ethereum/lib/reexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewTestCmd(t *testing.T, data interface{}) *TestCmd {
|
func NewTestCmd(t *testing.T, data interface{}) *TestCmd {
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@ func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, st
|
||||||
var storageTrie state.Trie
|
var storageTrie state.Trie
|
||||||
if storageRoot != types.EmptyRootHash && storageRoot != (common.Hash{}) {
|
if storageRoot != types.EmptyRootHash && storageRoot != (common.Hash{}) {
|
||||||
id := trie.StorageTrieID(header.Root, crypto.Keccak256Hash(address.Bytes()), storageRoot)
|
id := trie.StorageTrieID(header.Root, crypto.Keccak256Hash(address.Bytes()), storageRoot)
|
||||||
st, err := trie.NewStateTrie(id, statedb.Database().TrieDB())
|
st, err := trie.NewStateTrie(id, statedb.(*state.StateDB).Database().TrieDB())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -731,7 +731,7 @@ func (s *BlockChainAPI) GetProof(ctx context.Context, address common.Address, st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create the accountProof.
|
// Create the accountProof.
|
||||||
tr, err := trie.NewStateTrie(trie.StateTrieID(header.Root), statedb.Database().TrieDB())
|
tr, err := trie.NewStateTrie(trie.StateTrieID(header.Root), statedb.(*state.StateDB).Database().TrieDB())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -1178,24 +1178,6 @@ func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrO
|
||||||
return result.Return(), result.Err
|
return result.Return(), result.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
// executeEstimate is a helper that executes the transaction under a given gas limit and returns
|
|
||||||
// true if the transaction fails for a reason that might be related to not enough gas. A non-nil
|
|
||||||
// error means execution failed due to reasons unrelated to the gas limit.
|
|
||||||
func executeEstimate(ctx context.Context, b Backend, args TransactionArgs, state vm.StateDB, header *types.Header, gasCap uint64, gasLimit uint64) (bool, *core.ExecutionResult, error) {
|
|
||||||
args.Gas = (*hexutil.Uint64)(&gasLimit)
|
|
||||||
result, err := doCall(ctx, b, args, state, header, nil, nil, 0, gasCap)
|
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, core.ErrIntrinsicGas) {
|
|
||||||
return true, nil, nil // Special case, raise gas limit
|
|
||||||
}
|
|
||||||
return true, nil, err // Bail out
|
|
||||||
}
|
|
||||||
return result.Failed(), result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> 6c86d947d (use interface instead of concrete state type)
|
|
||||||
// DoEstimateGas returns the lowest possible gas limit that allows the transaction to run
|
// DoEstimateGas returns the lowest possible gas limit that allows the transaction to run
|
||||||
// successfully at block `blockNrOrHash`. It returns error if the transaction would revert, or if
|
// successfully at block `blockNrOrHash`. It returns error if the transaction would revert, or if
|
||||||
// there are unexpected failures. The gas limit is capped by both `args.Gas` (if non-nil &
|
// there are unexpected failures. The gas limit is capped by both `args.Gas` (if non-nil &
|
||||||
|
|
|
||||||
|
|
@ -536,7 +536,6 @@ func (b testBackend) GetTd(ctx context.Context, hash common.Hash) *big.Int {
|
||||||
return big.NewInt(1)
|
return big.NewInt(1)
|
||||||
}
|
}
|
||||||
func (b testBackend) GetEVM(ctx context.Context, msg *core.Message, state vm.StateDB, header *types.Header, vmConfig *vm.Config, blockContext *vm.BlockContext) *vm.EVM {
|
func (b testBackend) GetEVM(ctx context.Context, msg *core.Message, state vm.StateDB, header *types.Header, vmConfig *vm.Config, blockContext *vm.BlockContext) *vm.EVM {
|
||||||
vmError := func() error { return nil }
|
|
||||||
if vmConfig == nil {
|
if vmConfig == nil {
|
||||||
vmConfig = b.chain.GetVMConfig()
|
vmConfig = b.chain.GetVMConfig()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ func (b *backendMock) GetLogs(ctx context.Context, blockHash common.Hash, number
|
||||||
}
|
}
|
||||||
func (b *backendMock) GetTd(ctx context.Context, hash common.Hash) *big.Int { return nil }
|
func (b *backendMock) GetTd(ctx context.Context, hash common.Hash) *big.Int { return nil }
|
||||||
func (b *backendMock) GetEVM(ctx context.Context, msg *core.Message, state vm.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) *vm.EVM {
|
func (b *backendMock) GetEVM(ctx context.Context, msg *core.Message, state vm.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) *vm.EVM {
|
||||||
return nil, nil
|
return nil
|
||||||
}
|
}
|
||||||
func (b *backendMock) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { return nil }
|
func (b *backendMock) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { return nil }
|
||||||
func (b *backendMock) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription {
|
func (b *backendMock) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/internal/reexec"
|
"github.com/ethereum/go-ethereum/lib/reexec"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/internal/reexec"
|
"github.com/ethereum/go-ethereum/lib/reexec"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
"github.com/ethereum/go-ethereum/core/state/snapshot"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/core/vm"
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
|
|
@ -89,7 +88,7 @@ func TestState(t *testing.T) {
|
||||||
t.Run(key+"/hash/trie", func(t *testing.T) {
|
t.Run(key+"/hash/trie", func(t *testing.T) {
|
||||||
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
||||||
var result error
|
var result error
|
||||||
test.Run(subtest, vmconfig, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
|
test.Run(subtest, vmconfig, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state vm.StateDB) {
|
||||||
result = st.checkFailure(t, err)
|
result = st.checkFailure(t, err)
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
@ -98,7 +97,7 @@ func TestState(t *testing.T) {
|
||||||
t.Run(key+"/hash/snap", func(t *testing.T) {
|
t.Run(key+"/hash/snap", func(t *testing.T) {
|
||||||
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
||||||
var result error
|
var result error
|
||||||
test.Run(subtest, vmconfig, true, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
|
test.Run(subtest, vmconfig, true, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state vm.StateDB) {
|
||||||
if snaps != nil && state != nil {
|
if snaps != nil && state != nil {
|
||||||
if _, err := snaps.Journal(state.IntermediateRoot(false)); err != nil {
|
if _, err := snaps.Journal(state.IntermediateRoot(false)); err != nil {
|
||||||
result = err
|
result = err
|
||||||
|
|
@ -113,7 +112,7 @@ func TestState(t *testing.T) {
|
||||||
t.Run(key+"/path/trie", func(t *testing.T) {
|
t.Run(key+"/path/trie", func(t *testing.T) {
|
||||||
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
||||||
var result error
|
var result error
|
||||||
test.Run(subtest, vmconfig, false, rawdb.PathScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
|
test.Run(subtest, vmconfig, false, rawdb.PathScheme, func(err error, snaps *snapshot.Tree, state vm.StateDB) {
|
||||||
result = st.checkFailure(t, err)
|
result = st.checkFailure(t, err)
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
|
|
@ -122,7 +121,7 @@ func TestState(t *testing.T) {
|
||||||
t.Run(key+"/path/snap", func(t *testing.T) {
|
t.Run(key+"/path/snap", func(t *testing.T) {
|
||||||
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error {
|
||||||
var result error
|
var result error
|
||||||
test.Run(subtest, vmconfig, true, rawdb.PathScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
|
test.Run(subtest, vmconfig, true, rawdb.PathScheme, func(err error, snaps *snapshot.Tree, state vm.StateDB) {
|
||||||
if snaps != nil && state != nil {
|
if snaps != nil && state != nil {
|
||||||
if _, err := snaps.Journal(state.IntermediateRoot(false)); err != nil {
|
if _, err := snaps.Journal(state.IntermediateRoot(false)); err != nil {
|
||||||
result = err
|
result = err
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ func (t *StateTest) checkError(subtest StateSubtest, err error) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run executes a specific subtest and verifies the post-state and logs
|
// Run executes a specific subtest and verifies the post-state and logs
|
||||||
func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string, postCheck func(err error, snaps *snapshot.Tree, state *state.StateDB)) (result error) {
|
func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string, postCheck func(err error, snaps *snapshot.Tree, state vm.StateDB)) (result error) {
|
||||||
triedb, snaps, statedb, root, err := t.RunNoVerify(subtest, vmconfig, snapshotter, scheme)
|
triedb, snaps, statedb, root, err := t.RunNoVerify(subtest, vmconfig, snapshotter, scheme)
|
||||||
|
|
||||||
// Invoke the callback at the end of function for further analysis.
|
// Invoke the callback at the end of function for further analysis.
|
||||||
|
|
@ -220,15 +220,15 @@ func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bo
|
||||||
if root != common.Hash(post.Root) {
|
if root != common.Hash(post.Root) {
|
||||||
return fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
|
return fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
|
||||||
}
|
}
|
||||||
if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) {
|
if logs := rlpHash(statedb.(*state.StateDB).Logs()); logs != common.Hash(post.Logs) {
|
||||||
return fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
|
return fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
|
||||||
}
|
}
|
||||||
statedb, _ = state.New(root, statedb.Database(), snaps)
|
statedb, _ = state.New(root, statedb.(*state.StateDB).Database(), snaps)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
|
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
|
||||||
func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string) (*trie.Database, *snapshot.Tree, *state.StateDB, common.Hash, error) {
|
func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string) (*trie.Database, *snapshot.Tree, vm.StateDB, common.Hash, error) {
|
||||||
config, eips, err := GetChainConfig(subtest.Fork)
|
config, eips, err := GetChainConfig(subtest.Fork)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, common.Hash{}, UnsupportedForkError{subtest.Fork}
|
return nil, nil, nil, common.Hash{}, UnsupportedForkError{subtest.Fork}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue