mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
upstream: fixed consensus/*, core/*, and eth/*
This commit is contained in:
parent
ba9634e5d6
commit
f47516d51f
18 changed files with 99 additions and 128 deletions
|
|
@ -2,7 +2,6 @@ package api
|
|||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
|
|
@ -16,5 +15,5 @@ import (
|
|||
type Caller interface {
|
||||
Call(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (hexutil.Bytes, error)
|
||||
CallWithState(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, state *state.StateDB, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (hexutil.Bytes, error)
|
||||
GetBalance(ctx context.Context, address common.Address, blockNrOrHash *rpc.BlockNumberOrHash) (*big.Int, error)
|
||||
GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package api
|
|||
|
||||
import (
|
||||
context "context"
|
||||
"math/big"
|
||||
reflect "reflect"
|
||||
|
||||
common "github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -72,10 +71,10 @@ func (mr *MockCallerMockRecorder) CallWithState(ctx, args, blockNrOrHash, state,
|
|||
}
|
||||
|
||||
// GetBalance mocks base method.
|
||||
func (m *MockCaller) GetBalance(ctx context.Context, address common.Address, blockNrOrHash *rpc.BlockNumberOrHash) (*big.Int, error) {
|
||||
func (m *MockCaller) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBalance", ctx, address, blockNrOrHash)
|
||||
ret0, _ := ret[0].(*big.Int)
|
||||
ret0, _ := ret[0].(*hexutil.Big)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -579,19 +579,7 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Open trie database with provided config
|
||||
triedb := bc.triedb
|
||||
|
||||
chainConfig, _, _, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
|
||||
return nil, genesisErr
|
||||
}
|
||||
|
||||
bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine)
|
||||
bc.parallelProcessor = NewParallelStateProcessor(bc.chainConfig, bc, engine)
|
||||
bc.parallelSpeculativeProcesses = numprocs
|
||||
bc.enforceParallelProcessor = enforce
|
||||
|
||||
|
|
|
|||
|
|
@ -240,9 +240,12 @@ func TestTxIndexerRepair(t *testing.T) {
|
|||
expTail: tailPointer(65),
|
||||
},
|
||||
}
|
||||
|
||||
borReceipts := make([]types.Receipts, len(receipts))
|
||||
|
||||
for _, c := range cases {
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false)
|
||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0))
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
|
||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), append([]types.Receipts{{}}, borReceipts...), big.NewInt(0))
|
||||
|
||||
// Index the initial blocks from ancient store
|
||||
indexer := &txIndexer{
|
||||
|
|
@ -431,9 +434,12 @@ func TestTxIndexerReport(t *testing.T) {
|
|||
expRemaining: 0,
|
||||
},
|
||||
}
|
||||
|
||||
borReceipts := make([]types.Receipts, len(receipts))
|
||||
|
||||
for _, c := range cases {
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false)
|
||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...))
|
||||
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
|
||||
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), append([]types.Receipts{{}}, borReceipts...), big.NewInt(0))
|
||||
|
||||
// Index the initial blocks from ancient store
|
||||
indexer := &txIndexer{
|
||||
|
|
@ -453,6 +459,6 @@ func TestTxIndexerReport(t *testing.T) {
|
|||
t.Fatalf("Unexpected remaining: %d, expected: %d", p.Remaining, c.expRemaining)
|
||||
}
|
||||
db.Close()
|
||||
os.RemoveAll(frdir)
|
||||
os.RemoveAll("")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,31 +141,3 @@ func BenchmarkJumpdestOpEOFAnalysis(bench *testing.B) {
|
|||
op = EOFCREATE
|
||||
bench.Run(op.String(), bencher)
|
||||
}
|
||||
|
||||
func BenchmarkJumpdestOpEOFAnalysis(bench *testing.B) {
|
||||
var op OpCode
|
||||
bencher := func(b *testing.B) {
|
||||
code := make([]byte, analysisCodeSize)
|
||||
b.SetBytes(analysisCodeSize)
|
||||
for i := range code {
|
||||
code[i] = byte(op)
|
||||
}
|
||||
bits := make(bitvec, len(code)/8+1+4)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
clear(bits)
|
||||
eofCodeBitmapInternal(code, bits)
|
||||
}
|
||||
}
|
||||
for op = PUSH1; op <= PUSH32; op++ {
|
||||
bench.Run(op.String(), bencher)
|
||||
}
|
||||
op = JUMPDEST
|
||||
bench.Run(op.String(), bencher)
|
||||
op = STOP
|
||||
bench.Run(op.String(), bencher)
|
||||
op = RJUMPV
|
||||
bench.Run(op.String(), bencher)
|
||||
op = EOFCREATE
|
||||
bench.Run(op.String(), bencher)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,16 +184,16 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
|
||||
// Override the chain config with provided settings.
|
||||
var overrides core.ChainOverrides
|
||||
if config.OverrideCancun != nil {
|
||||
overrides.OverrideCancun = config.OverrideCancun
|
||||
if config.OverridePrague != nil {
|
||||
overrides.OverridePrague = config.OverridePrague
|
||||
}
|
||||
if config.OverrideVerkle != nil {
|
||||
overrides.OverrideVerkle = config.OverrideVerkle
|
||||
}
|
||||
|
||||
chainConfig, _, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, triedb.NewDatabase(chainDb, triedb.HashDefaults), config.Genesis, &overrides)
|
||||
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat {
|
||||
return nil, genesisErr
|
||||
chainConfig, _, compatErr, err := core.SetupGenesisBlockWithOverride(chainDb, triedb.NewDatabase(chainDb, triedb.HashDefaults), config.Genesis, &overrides)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blockChainAPI := ethapi.NewBlockChainAPI(eth.APIBackend)
|
||||
|
|
@ -202,6 +202,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if compatErr != nil {
|
||||
return nil, compatErr
|
||||
}
|
||||
// END: Bor changes
|
||||
|
||||
bcVersion := rawdb.ReadDatabaseVersion(chainDb)
|
||||
|
|
@ -544,7 +548,7 @@ func (s *Ethereum) StartMining() error {
|
|||
return fmt.Errorf("signer missing: %v", err)
|
||||
}
|
||||
|
||||
cli.Authorize(eb, wallet.SignData)
|
||||
cli.Authorize(eb)
|
||||
}
|
||||
|
||||
if bor, ok := s.engine.(*bor.Bor); ok {
|
||||
|
|
|
|||
|
|
@ -20,12 +20,16 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
Genesis *core.Genesis `toml:",omitempty"`
|
||||
NetworkId uint64
|
||||
SyncMode SyncMode
|
||||
HistoryMode HistoryMode
|
||||
EthDiscoveryURLs []string
|
||||
SnapDiscoveryURLs []string
|
||||
NoPruning bool
|
||||
NoPrefetch bool
|
||||
TxLookupLimit uint64 `toml:",omitempty"`
|
||||
TransactionHistory uint64 `toml:",omitempty"`
|
||||
TxLookupLimit uint64 `toml:",omitempty"`
|
||||
TransactionHistory uint64 `toml:",omitempty"`
|
||||
LogHistory uint64 `toml:",omitempty"`
|
||||
LogNoHistory bool `toml:",omitempty"`
|
||||
LogExportCheckpoints string
|
||||
StateHistory uint64 `toml:",omitempty"`
|
||||
StateScheme string `toml:",omitempty"`
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
|
|
@ -49,15 +53,13 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
BlobPool blobpool.Config
|
||||
GPO gasprice.Config
|
||||
EnablePreimageRecording bool
|
||||
EnableWitnessCollection bool `toml:"-"`
|
||||
VMTrace string
|
||||
VMTraceJsonConfig string
|
||||
DocRoot string `toml:"-"`
|
||||
RPCGasCap uint64
|
||||
RPCReturnDataLimit uint64
|
||||
RPCEVMTimeout time.Duration
|
||||
RPCTxFeeCap float64
|
||||
OverrideCancun *big.Int `toml:",omitempty"`
|
||||
OverridePrague *big.Int `toml:",omitempty"`
|
||||
HeimdallURL string
|
||||
HeimdallTimeout time.Duration
|
||||
WithoutHeimdall bool
|
||||
|
|
@ -68,7 +70,6 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
BorLogs bool
|
||||
ParallelEVM core.ParallelEVMConfig `toml:",omitempty"`
|
||||
DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
|
||||
OverridePrague *big.Int `toml:",omitempty"`
|
||||
OverrideVerkle *big.Int `toml:",omitempty"`
|
||||
EnableBlockTracking bool
|
||||
}
|
||||
|
|
@ -83,6 +84,9 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
enc.NoPrefetch = c.NoPrefetch
|
||||
enc.TxLookupLimit = c.TxLookupLimit
|
||||
enc.TransactionHistory = c.TransactionHistory
|
||||
enc.LogHistory = c.LogHistory
|
||||
enc.LogNoHistory = c.LogNoHistory
|
||||
enc.LogExportCheckpoints = c.LogExportCheckpoints
|
||||
enc.StateHistory = c.StateHistory
|
||||
enc.StateScheme = c.StateScheme
|
||||
enc.RequiredBlocks = c.RequiredBlocks
|
||||
|
|
@ -134,12 +138,16 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
Genesis *core.Genesis `toml:",omitempty"`
|
||||
NetworkId *uint64
|
||||
SyncMode *SyncMode
|
||||
HistoryMode *HistoryMode
|
||||
EthDiscoveryURLs []string
|
||||
SnapDiscoveryURLs []string
|
||||
NoPruning *bool
|
||||
NoPrefetch *bool
|
||||
TxLookupLimit *uint64 `toml:",omitempty"`
|
||||
TransactionHistory *uint64 `toml:",omitempty"`
|
||||
TxLookupLimit *uint64 `toml:",omitempty"`
|
||||
TransactionHistory *uint64 `toml:",omitempty"`
|
||||
LogHistory *uint64 `toml:",omitempty"`
|
||||
LogNoHistory *bool `toml:",omitempty"`
|
||||
LogExportCheckpoints *string
|
||||
StateHistory *uint64 `toml:",omitempty"`
|
||||
StateScheme *string `toml:",omitempty"`
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
|
|
@ -163,15 +171,13 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
BlobPool *blobpool.Config
|
||||
GPO *gasprice.Config
|
||||
EnablePreimageRecording *bool
|
||||
EnableWitnessCollection *bool `toml:"-"`
|
||||
VMTrace *string
|
||||
VMTraceJsonConfig *string
|
||||
DocRoot *string `toml:"-"`
|
||||
RPCGasCap *uint64
|
||||
RPCReturnDataLimit *uint64
|
||||
RPCEVMTimeout *time.Duration
|
||||
RPCTxFeeCap *float64
|
||||
OverrideCancun *big.Int `toml:",omitempty"`
|
||||
OverridePrague *big.Int `toml:",omitempty"`
|
||||
HeimdallURL *string
|
||||
HeimdallTimeout *time.Duration
|
||||
WithoutHeimdall *bool
|
||||
|
|
@ -182,7 +188,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
BorLogs *bool
|
||||
ParallelEVM *core.ParallelEVMConfig `toml:",omitempty"`
|
||||
DevFakeAuthor *bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
|
||||
OverridePrague *big.Int `toml:",omitempty"`
|
||||
OverrideVerkle *big.Int `toml:",omitempty"`
|
||||
EnableBlockTracking *bool
|
||||
}
|
||||
|
|
@ -220,6 +225,15 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
if dec.TransactionHistory != nil {
|
||||
c.TransactionHistory = *dec.TransactionHistory
|
||||
}
|
||||
if dec.LogHistory != nil {
|
||||
c.LogHistory = *dec.LogHistory
|
||||
}
|
||||
if dec.LogNoHistory != nil {
|
||||
c.LogNoHistory = *dec.LogNoHistory
|
||||
}
|
||||
if dec.LogExportCheckpoints != nil {
|
||||
c.LogExportCheckpoints = *dec.LogExportCheckpoints
|
||||
}
|
||||
if dec.StateHistory != nil {
|
||||
c.StateHistory = *dec.StateHistory
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func newTestReceipt(contractAddr common.Address, topicAddress common.Hash) *type
|
|||
},
|
||||
}
|
||||
|
||||
receipt.Bloom = types.CreateBloom(types.Receipts{receipt})
|
||||
receipt.Bloom = types.CreateBloom(receipt)
|
||||
|
||||
return receipt
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ func TestBlockSubscription(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
backend, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
genesis = &core.Genesis{
|
||||
Config: params.TestChainConfig,
|
||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||
|
|
@ -308,7 +308,7 @@ func TestPendingTxFilter(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
backend, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
|
||||
transactions = []*types.Transaction{
|
||||
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
||||
|
|
@ -367,7 +367,7 @@ func TestPendingTxFilterFullTx(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
backend, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
|
||||
transactions = []*types.Transaction{
|
||||
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
|
||||
|
|
@ -426,7 +426,7 @@ func TestLogFilterCreation(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
_, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
|
||||
testCases = []struct {
|
||||
crit FilterCriteria
|
||||
|
|
@ -475,7 +475,7 @@ func TestInvalidLogFilterCreation(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
_, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
)
|
||||
|
||||
// different situations where log filter creation should fail.
|
||||
|
|
@ -501,7 +501,7 @@ func TestInvalidGetLogsRequest(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
_, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111")
|
||||
)
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ func TestInvalidGetRangeLogsRequest(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
_, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
)
|
||||
|
||||
api.SetChainConfig(params.BorTestChainConfig)
|
||||
|
|
@ -546,7 +546,7 @@ func TestLogFilter(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
backend, sys = newTestFilterSystem(db, Config{})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
|
||||
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111")
|
||||
secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222")
|
||||
|
|
@ -660,7 +660,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) {
|
|||
var (
|
||||
db = rawdb.NewMemoryDatabase()
|
||||
backend, sys = newTestFilterSystem(db, Config{Timeout: timeout})
|
||||
api = NewFilterAPI(sys)
|
||||
api = NewFilterAPI(sys, true)
|
||||
done = make(chan struct{})
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ func TestRangeLogs(t *testing.T) {
|
|||
}
|
||||
chain, _ := core.GenerateChain(gspec.Config, gspec.ToBlock(), ethash.NewFaker(), db, 1000, func(i int, gen *core.BlockGen) {})
|
||||
var l uint64
|
||||
bc, err := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, &l)
|
||||
bc, err := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, &l, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,9 @@ package filters
|
|||
|
||||
import (
|
||||
context "context"
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
|
||||
common "github.com/ethereum/go-ethereum/common"
|
||||
core "github.com/ethereum/go-ethereum/core"
|
||||
bloombits "github.com/ethereum/go-ethereum/core/bloombits"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
types "github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -29,9 +26,12 @@ type TestBackend struct {
|
|||
stateSyncFeed event.Feed
|
||||
}
|
||||
|
||||
// bloombits logic was removed - https://github.com/ethereum/go-ethereum/pull/31081
|
||||
/*
|
||||
func (b *TestBackend) BloomStatus() (uint64, uint64) {
|
||||
return params.BloomBitsBlocks, b.sections
|
||||
}
|
||||
*/
|
||||
|
||||
func (b *TestBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
|
||||
number := rawdb.ReadHeaderNumber(b.DB, hash)
|
||||
|
|
@ -141,6 +141,8 @@ func (b *TestBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subsc
|
|||
return b.chainFeed.Subscribe(ch)
|
||||
}
|
||||
|
||||
// bloombits logic was removed - https://github.com/ethereum/go-ethereum/pull/31081
|
||||
/*
|
||||
func (b *TestBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
|
||||
requests := make(chan chan *bloombits.Retrieval)
|
||||
|
||||
|
|
@ -173,6 +175,7 @@ func (b *TestBackend) ServiceFilter(ctx context.Context, session *bloombits.Matc
|
|||
}
|
||||
}()
|
||||
}
|
||||
*/
|
||||
|
||||
func (b *TestBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
|
||||
return b.stateSyncFeed.Subscribe(ch)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import (
|
|||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/holiman/uint256"
|
||||
)
|
||||
|
||||
const testHead = 32
|
||||
|
|
@ -196,27 +195,29 @@ func newTestBackend(t *testing.T, londonBlock *big.Int, cancunBlock *big.Int, pe
|
|||
|
||||
b.AddTx(types.MustSignNewTx(key, signer, txdata))
|
||||
|
||||
if cancunBlock != nil && b.Number().Cmp(cancunBlock) >= 0 {
|
||||
b.SetPoS()
|
||||
/*
|
||||
if cancunBlock != nil && b.Number().Cmp(cancunBlock) >= 0 {
|
||||
b.SetPoS()
|
||||
|
||||
// put more blobs in each new block
|
||||
for j := 0; j < i && j < 6; j++ {
|
||||
blobTx := &types.BlobTx{
|
||||
ChainID: uint256.MustFromBig(gspec.Config.ChainID),
|
||||
Nonce: b.TxNonce(addr),
|
||||
To: common.Address{},
|
||||
Gas: 30000,
|
||||
GasFeeCap: uint256.NewInt(100 * params.GWei),
|
||||
GasTipCap: uint256.NewInt(uint64(i+1) * params.GWei),
|
||||
Data: []byte{},
|
||||
BlobFeeCap: uint256.NewInt(1),
|
||||
BlobHashes: []common.Hash{emptyBlobVHash},
|
||||
Value: uint256.NewInt(100),
|
||||
Sidecar: nil,
|
||||
// put more blobs in each new block
|
||||
for j := 0; j < i && j < 6; j++ {
|
||||
blobTx := &types.BlobTx{
|
||||
ChainID: uint256.MustFromBig(gspec.Config.ChainID),
|
||||
Nonce: b.TxNonce(addr),
|
||||
To: common.Address{},
|
||||
Gas: 30000,
|
||||
GasFeeCap: uint256.NewInt(100 * params.GWei),
|
||||
GasTipCap: uint256.NewInt(uint64(i+1) * params.GWei),
|
||||
Data: []byte{},
|
||||
BlobFeeCap: uint256.NewInt(1),
|
||||
BlobHashes: []common.Hash{emptyBlobVHash},
|
||||
Value: uint256.NewInt(100),
|
||||
Sidecar: nil,
|
||||
}
|
||||
b.AddTx(types.MustSignNewTx(key, signer, blobTx))
|
||||
}
|
||||
b.AddTx(types.MustSignNewTx(key, signer, blobTx))
|
||||
}
|
||||
}
|
||||
*/
|
||||
})
|
||||
|
||||
// Construct testing chain
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ func testSendTransactionAnnouncementsOnly(t *testing.T, protocol uint) {
|
|||
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
|
||||
txs[nonce] = tx
|
||||
}
|
||||
source.txpool.Add(txs, false, false)
|
||||
source.txpool.Add(txs, false)
|
||||
|
||||
// Make sure we get all the transactions as announcements
|
||||
seen := make(map[common.Hash]struct{})
|
||||
|
|
|
|||
|
|
@ -1055,8 +1055,6 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
|||
txHash = config.TxHash
|
||||
}
|
||||
|
||||
logConfig.Debug = true
|
||||
|
||||
// Execute transaction, either tracing all or just the requested one
|
||||
var (
|
||||
dumps []string
|
||||
|
|
@ -1200,8 +1198,8 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
|||
// For BorTransaction, there will be no trace available
|
||||
tx, _, _, _ := rawdb.ReadBorTransaction(api.backend.ChainDb(), hash)
|
||||
if tx != nil {
|
||||
return ðapi.ExecutionResult{
|
||||
StructLogs: make([]ethapi.StructLogRes, 0),
|
||||
return &logger.ExecutionResult{
|
||||
StructLogs: make([]json.RawMessage, 0),
|
||||
}, nil
|
||||
} else {
|
||||
return nil, errTxNotFound
|
||||
|
|
@ -1410,7 +1408,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
|
|||
config.BorTx = newBoolPtr(false)
|
||||
}
|
||||
|
||||
_, err = core.ApplyTransactionWithEVM(message, new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, evm)
|
||||
_, err = core.ApplyTransactionWithEVM(message, new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, evm, context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("tracing failed: %w", err)
|
||||
}
|
||||
|
|
@ -1424,7 +1422,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
|
|||
} else {
|
||||
// Call Prepare to clear out the statedb access list
|
||||
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)
|
||||
_, err = core.ApplyTransactionWithEVM(message, api.backend.ChainConfig(), new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, evm, context.Background())
|
||||
_, err = core.ApplyTransactionWithEVM(message, new(core.GasPool).AddGas(message.GasLimit), statedb, vmctx.BlockNumber, txctx.BlockHash, tx, &usedGas, evm, context.Background())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("tracing failed: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,16 +106,11 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
}
|
||||
}
|
||||
|
||||
returnVal := fmt.Sprintf("%x", execRes.Return())
|
||||
if len(execRes.Revert()) > 0 {
|
||||
returnVal = fmt.Sprintf("%x", execRes.Revert())
|
||||
}
|
||||
|
||||
result := ðapi.ExecutionResult{
|
||||
result := &logger.ExecutionResult{
|
||||
Gas: execRes.UsedGas,
|
||||
Failed: execRes.Failed(),
|
||||
ReturnValue: returnVal,
|
||||
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
|
||||
ReturnValue: execRes.Return(),
|
||||
StructLogs: tracer.StructLogs(),
|
||||
}
|
||||
res := &TxTraceResult{
|
||||
Result: result,
|
||||
|
|
|
|||
|
|
@ -395,6 +395,9 @@ func (l *StructLogger) OnTxEnd(receipt *types.Receipt, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// StructLogs returns the captured log entries.
|
||||
func (l *StructLogger) StructLogs() []json.RawMessage { return l.logs }
|
||||
|
||||
// Error returns the VM error captured by the trace.
|
||||
func (l *StructLogger) Error() error { return l.err }
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ func BenchmarkTransactionTraceV2(b *testing.B) {
|
|||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
tracer.OnTxEnd(&types.Receipt{GasUsed: res.UsedGas}, nil)
|
||||
state.StateDB.RevertToSnapshot(snap)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1056,16 +1056,6 @@ func (api *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs,
|
|||
return DoEstimateGas(ctx, api.b, args, bNrOrHash, overrides, blockOverrides, api.b.RPCGasCap())
|
||||
}
|
||||
|
||||
// ExecutionResult groups all structured logs emitted by the EVM
|
||||
// while replaying a transaction in debug mode as well as transaction
|
||||
// execution status, the amount of gas used and the return value
|
||||
type ExecutionResult struct {
|
||||
Gas uint64 `json:"gas"`
|
||||
Failed bool `json:"failed"`
|
||||
ReturnValue string `json:"returnValue"`
|
||||
StructLogs []StructLogRes `json:"structLogs"`
|
||||
}
|
||||
|
||||
// StructLogRes stores a structured log emitted by the EVM while replaying a
|
||||
// transaction in debug mode
|
||||
type StructLogRes struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue