upstream: fixed consensus/*, core/*, and eth/*

This commit is contained in:
Pratik Patil 2025-05-02 10:02:02 +05:30
parent ba9634e5d6
commit f47516d51f
No known key found for this signature in database
GPG key ID: AFDCA496554874B3
18 changed files with 99 additions and 128 deletions

View file

@ -2,7 +2,6 @@ package api
import ( import (
"context" "context"
"math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
@ -16,5 +15,5 @@ import (
type Caller interface { type Caller interface {
Call(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *override.StateOverride, blockOverrides *override.BlockOverrides) (hexutil.Bytes, error) 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) 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)
} }

View file

@ -6,7 +6,6 @@ package api
import ( import (
context "context" context "context"
"math/big"
reflect "reflect" reflect "reflect"
common "github.com/ethereum/go-ethereum/common" common "github.com/ethereum/go-ethereum/common"
@ -72,10 +71,10 @@ func (mr *MockCallerMockRecorder) CallWithState(ctx, args, blockNrOrHash, state,
} }
// GetBalance mocks base method. // 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() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetBalance", ctx, address, blockNrOrHash) ret := m.ctrl.Call(m, "GetBalance", ctx, address, blockNrOrHash)
ret0, _ := ret[0].(*big.Int) ret0, _ := ret[0].(*hexutil.Big)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }

View file

@ -579,19 +579,7 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis
return nil, err return nil, err
} }
// Open trie database with provided config bc.parallelProcessor = NewParallelStateProcessor(bc.chainConfig, bc, engine)
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.parallelSpeculativeProcesses = numprocs bc.parallelSpeculativeProcesses = numprocs
bc.enforceParallelProcessor = enforce bc.enforceParallelProcessor = enforce

View file

@ -240,9 +240,12 @@ func TestTxIndexerRepair(t *testing.T) {
expTail: tailPointer(65), expTail: tailPointer(65),
}, },
} }
borReceipts := make([]types.Receipts, len(receipts))
for _, c := range cases { for _, c := range cases {
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false) db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...), big.NewInt(0)) 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 // Index the initial blocks from ancient store
indexer := &txIndexer{ indexer := &txIndexer{
@ -431,9 +434,12 @@ func TestTxIndexerReport(t *testing.T) {
expRemaining: 0, expRemaining: 0,
}, },
} }
borReceipts := make([]types.Receipts, len(receipts))
for _, c := range cases { for _, c := range cases {
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false) db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
rawdb.WriteAncientBlocks(db, append([]*types.Block{gspec.ToBlock()}, blocks...), append([]types.Receipts{{}}, receipts...)) 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 // Index the initial blocks from ancient store
indexer := &txIndexer{ indexer := &txIndexer{
@ -453,6 +459,6 @@ func TestTxIndexerReport(t *testing.T) {
t.Fatalf("Unexpected remaining: %d, expected: %d", p.Remaining, c.expRemaining) t.Fatalf("Unexpected remaining: %d, expected: %d", p.Remaining, c.expRemaining)
} }
db.Close() db.Close()
os.RemoveAll(frdir) os.RemoveAll("")
} }
} }

View file

@ -141,31 +141,3 @@ func BenchmarkJumpdestOpEOFAnalysis(bench *testing.B) {
op = EOFCREATE op = EOFCREATE
bench.Run(op.String(), bencher) 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)
}

View file

@ -184,16 +184,16 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// Override the chain config with provided settings. // Override the chain config with provided settings.
var overrides core.ChainOverrides var overrides core.ChainOverrides
if config.OverrideCancun != nil { if config.OverridePrague != nil {
overrides.OverrideCancun = config.OverrideCancun overrides.OverridePrague = config.OverridePrague
} }
if config.OverrideVerkle != nil { if config.OverrideVerkle != nil {
overrides.OverrideVerkle = config.OverrideVerkle overrides.OverrideVerkle = config.OverrideVerkle
} }
chainConfig, _, genesisErr := core.SetupGenesisBlockWithOverride(chainDb, triedb.NewDatabase(chainDb, triedb.HashDefaults), config.Genesis, &overrides) chainConfig, _, compatErr, err := core.SetupGenesisBlockWithOverride(chainDb, triedb.NewDatabase(chainDb, triedb.HashDefaults), config.Genesis, &overrides)
if _, isCompat := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !isCompat { if err != nil {
return nil, genesisErr return nil, err
} }
blockChainAPI := ethapi.NewBlockChainAPI(eth.APIBackend) blockChainAPI := ethapi.NewBlockChainAPI(eth.APIBackend)
@ -202,6 +202,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if compatErr != nil {
return nil, compatErr
}
// END: Bor changes // END: Bor changes
bcVersion := rawdb.ReadDatabaseVersion(chainDb) bcVersion := rawdb.ReadDatabaseVersion(chainDb)
@ -544,7 +548,7 @@ func (s *Ethereum) StartMining() error {
return fmt.Errorf("signer missing: %v", err) return fmt.Errorf("signer missing: %v", err)
} }
cli.Authorize(eb, wallet.SignData) cli.Authorize(eb)
} }
if bor, ok := s.engine.(*bor.Bor); ok { if bor, ok := s.engine.(*bor.Bor); ok {

View file

@ -20,12 +20,16 @@ func (c Config) MarshalTOML() (interface{}, error) {
Genesis *core.Genesis `toml:",omitempty"` Genesis *core.Genesis `toml:",omitempty"`
NetworkId uint64 NetworkId uint64
SyncMode SyncMode SyncMode SyncMode
HistoryMode HistoryMode
EthDiscoveryURLs []string EthDiscoveryURLs []string
SnapDiscoveryURLs []string SnapDiscoveryURLs []string
NoPruning bool NoPruning bool
NoPrefetch bool NoPrefetch bool
TxLookupLimit uint64 `toml:",omitempty"` TxLookupLimit uint64 `toml:",omitempty"`
TransactionHistory uint64 `toml:",omitempty"` TransactionHistory uint64 `toml:",omitempty"`
LogHistory uint64 `toml:",omitempty"`
LogNoHistory bool `toml:",omitempty"`
LogExportCheckpoints string
StateHistory uint64 `toml:",omitempty"` StateHistory uint64 `toml:",omitempty"`
StateScheme string `toml:",omitempty"` StateScheme string `toml:",omitempty"`
RequiredBlocks map[uint64]common.Hash `toml:"-"` RequiredBlocks map[uint64]common.Hash `toml:"-"`
@ -49,15 +53,13 @@ func (c Config) MarshalTOML() (interface{}, error) {
BlobPool blobpool.Config BlobPool blobpool.Config
GPO gasprice.Config GPO gasprice.Config
EnablePreimageRecording bool EnablePreimageRecording bool
EnableWitnessCollection bool `toml:"-"`
VMTrace string VMTrace string
VMTraceJsonConfig string VMTraceJsonConfig string
DocRoot string `toml:"-"`
RPCGasCap uint64 RPCGasCap uint64
RPCReturnDataLimit uint64 RPCReturnDataLimit uint64
RPCEVMTimeout time.Duration RPCEVMTimeout time.Duration
RPCTxFeeCap float64 RPCTxFeeCap float64
OverrideCancun *big.Int `toml:",omitempty"` OverridePrague *big.Int `toml:",omitempty"`
HeimdallURL string HeimdallURL string
HeimdallTimeout time.Duration HeimdallTimeout time.Duration
WithoutHeimdall bool WithoutHeimdall bool
@ -68,7 +70,6 @@ func (c Config) MarshalTOML() (interface{}, error) {
BorLogs bool BorLogs bool
ParallelEVM core.ParallelEVMConfig `toml:",omitempty"` ParallelEVM core.ParallelEVMConfig `toml:",omitempty"`
DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"` DevFakeAuthor bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
OverridePrague *big.Int `toml:",omitempty"`
OverrideVerkle *big.Int `toml:",omitempty"` OverrideVerkle *big.Int `toml:",omitempty"`
EnableBlockTracking bool EnableBlockTracking bool
} }
@ -83,6 +84,9 @@ func (c Config) MarshalTOML() (interface{}, error) {
enc.NoPrefetch = c.NoPrefetch enc.NoPrefetch = c.NoPrefetch
enc.TxLookupLimit = c.TxLookupLimit enc.TxLookupLimit = c.TxLookupLimit
enc.TransactionHistory = c.TransactionHistory enc.TransactionHistory = c.TransactionHistory
enc.LogHistory = c.LogHistory
enc.LogNoHistory = c.LogNoHistory
enc.LogExportCheckpoints = c.LogExportCheckpoints
enc.StateHistory = c.StateHistory enc.StateHistory = c.StateHistory
enc.StateScheme = c.StateScheme enc.StateScheme = c.StateScheme
enc.RequiredBlocks = c.RequiredBlocks enc.RequiredBlocks = c.RequiredBlocks
@ -134,12 +138,16 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
Genesis *core.Genesis `toml:",omitempty"` Genesis *core.Genesis `toml:",omitempty"`
NetworkId *uint64 NetworkId *uint64
SyncMode *SyncMode SyncMode *SyncMode
HistoryMode *HistoryMode
EthDiscoveryURLs []string EthDiscoveryURLs []string
SnapDiscoveryURLs []string SnapDiscoveryURLs []string
NoPruning *bool NoPruning *bool
NoPrefetch *bool NoPrefetch *bool
TxLookupLimit *uint64 `toml:",omitempty"` TxLookupLimit *uint64 `toml:",omitempty"`
TransactionHistory *uint64 `toml:",omitempty"` TransactionHistory *uint64 `toml:",omitempty"`
LogHistory *uint64 `toml:",omitempty"`
LogNoHistory *bool `toml:",omitempty"`
LogExportCheckpoints *string
StateHistory *uint64 `toml:",omitempty"` StateHistory *uint64 `toml:",omitempty"`
StateScheme *string `toml:",omitempty"` StateScheme *string `toml:",omitempty"`
RequiredBlocks map[uint64]common.Hash `toml:"-"` RequiredBlocks map[uint64]common.Hash `toml:"-"`
@ -163,15 +171,13 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
BlobPool *blobpool.Config BlobPool *blobpool.Config
GPO *gasprice.Config GPO *gasprice.Config
EnablePreimageRecording *bool EnablePreimageRecording *bool
EnableWitnessCollection *bool `toml:"-"`
VMTrace *string VMTrace *string
VMTraceJsonConfig *string VMTraceJsonConfig *string
DocRoot *string `toml:"-"`
RPCGasCap *uint64 RPCGasCap *uint64
RPCReturnDataLimit *uint64 RPCReturnDataLimit *uint64
RPCEVMTimeout *time.Duration RPCEVMTimeout *time.Duration
RPCTxFeeCap *float64 RPCTxFeeCap *float64
OverrideCancun *big.Int `toml:",omitempty"` OverridePrague *big.Int `toml:",omitempty"`
HeimdallURL *string HeimdallURL *string
HeimdallTimeout *time.Duration HeimdallTimeout *time.Duration
WithoutHeimdall *bool WithoutHeimdall *bool
@ -182,7 +188,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
BorLogs *bool BorLogs *bool
ParallelEVM *core.ParallelEVMConfig `toml:",omitempty"` ParallelEVM *core.ParallelEVMConfig `toml:",omitempty"`
DevFakeAuthor *bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"` DevFakeAuthor *bool `hcl:"devfakeauthor,optional" toml:"devfakeauthor,optional"`
OverridePrague *big.Int `toml:",omitempty"`
OverrideVerkle *big.Int `toml:",omitempty"` OverrideVerkle *big.Int `toml:",omitempty"`
EnableBlockTracking *bool EnableBlockTracking *bool
} }
@ -220,6 +225,15 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
if dec.TransactionHistory != nil { if dec.TransactionHistory != nil {
c.TransactionHistory = *dec.TransactionHistory 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 { if dec.StateHistory != nil {
c.StateHistory = *dec.StateHistory c.StateHistory = *dec.StateHistory
} }

View file

@ -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 return receipt
} }

View file

@ -250,7 +250,7 @@ func TestBlockSubscription(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
backend, sys = newTestFilterSystem(db, Config{}) backend, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
genesis = &core.Genesis{ genesis = &core.Genesis{
Config: params.TestChainConfig, Config: params.TestChainConfig,
BaseFee: big.NewInt(params.InitialBaseFee), BaseFee: big.NewInt(params.InitialBaseFee),
@ -308,7 +308,7 @@ func TestPendingTxFilter(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
backend, sys = newTestFilterSystem(db, Config{}) backend, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
transactions = []*types.Transaction{ transactions = []*types.Transaction{
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil), types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
@ -367,7 +367,7 @@ func TestPendingTxFilterFullTx(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
backend, sys = newTestFilterSystem(db, Config{}) backend, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
transactions = []*types.Transaction{ transactions = []*types.Transaction{
types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil), types.NewTransaction(0, common.HexToAddress("0xb794f5ea0ba39494ce83a213fffba74279579268"), new(big.Int), 0, new(big.Int), nil),
@ -426,7 +426,7 @@ func TestLogFilterCreation(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
_, sys = newTestFilterSystem(db, Config{}) _, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
testCases = []struct { testCases = []struct {
crit FilterCriteria crit FilterCriteria
@ -475,7 +475,7 @@ func TestInvalidLogFilterCreation(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
_, sys = newTestFilterSystem(db, Config{}) _, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
) )
// different situations where log filter creation should fail. // different situations where log filter creation should fail.
@ -501,7 +501,7 @@ func TestInvalidGetLogsRequest(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
_, sys = newTestFilterSystem(db, Config{}) _, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111") blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111")
) )
@ -529,7 +529,7 @@ func TestInvalidGetRangeLogsRequest(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
_, sys = newTestFilterSystem(db, Config{}) _, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
) )
api.SetChainConfig(params.BorTestChainConfig) api.SetChainConfig(params.BorTestChainConfig)
@ -546,7 +546,7 @@ func TestLogFilter(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
backend, sys = newTestFilterSystem(db, Config{}) backend, sys = newTestFilterSystem(db, Config{})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111") firstAddr = common.HexToAddress("0x1111111111111111111111111111111111111111")
secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222") secondAddr = common.HexToAddress("0x2222222222222222222222222222222222222222")
@ -660,7 +660,7 @@ func TestPendingTxFilterDeadlock(t *testing.T) {
var ( var (
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
backend, sys = newTestFilterSystem(db, Config{Timeout: timeout}) backend, sys = newTestFilterSystem(db, Config{Timeout: timeout})
api = NewFilterAPI(sys) api = NewFilterAPI(sys, true)
done = make(chan struct{}) done = make(chan struct{})
) )

View file

@ -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) {}) chain, _ := core.GenerateChain(gspec.Config, gspec.ToBlock(), ethash.NewFaker(), db, 1000, func(i int, gen *core.BlockGen) {})
var l uint64 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View file

@ -2,12 +2,9 @@ package filters
import ( import (
context "context" context "context"
"crypto/rand"
"math/big"
common "github.com/ethereum/go-ethereum/common" common "github.com/ethereum/go-ethereum/common"
core "github.com/ethereum/go-ethereum/core" 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/rawdb"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
types "github.com/ethereum/go-ethereum/core/types" types "github.com/ethereum/go-ethereum/core/types"
@ -29,9 +26,12 @@ type TestBackend struct {
stateSyncFeed event.Feed stateSyncFeed event.Feed
} }
// bloombits logic was removed - https://github.com/ethereum/go-ethereum/pull/31081
/*
func (b *TestBackend) BloomStatus() (uint64, uint64) { func (b *TestBackend) BloomStatus() (uint64, uint64) {
return params.BloomBitsBlocks, b.sections return params.BloomBitsBlocks, b.sections
} }
*/
func (b *TestBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) { func (b *TestBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
number := rawdb.ReadHeaderNumber(b.DB, hash) 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) 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) { func (b *TestBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
requests := make(chan chan *bloombits.Retrieval) 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 { func (b *TestBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
return b.stateSyncFeed.Subscribe(ch) return b.stateSyncFeed.Subscribe(ch)

View file

@ -33,7 +33,6 @@ import (
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/holiman/uint256"
) )
const testHead = 32 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)) 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 // put more blobs in each new block
for j := 0; j < i && j < 6; j++ { for j := 0; j < i && j < 6; j++ {
blobTx := &types.BlobTx{ blobTx := &types.BlobTx{
ChainID: uint256.MustFromBig(gspec.Config.ChainID), ChainID: uint256.MustFromBig(gspec.Config.ChainID),
Nonce: b.TxNonce(addr), Nonce: b.TxNonce(addr),
To: common.Address{}, To: common.Address{},
Gas: 30000, Gas: 30000,
GasFeeCap: uint256.NewInt(100 * params.GWei), GasFeeCap: uint256.NewInt(100 * params.GWei),
GasTipCap: uint256.NewInt(uint64(i+1) * params.GWei), GasTipCap: uint256.NewInt(uint64(i+1) * params.GWei),
Data: []byte{}, Data: []byte{},
BlobFeeCap: uint256.NewInt(1), BlobFeeCap: uint256.NewInt(1),
BlobHashes: []common.Hash{emptyBlobVHash}, BlobHashes: []common.Hash{emptyBlobVHash},
Value: uint256.NewInt(100), Value: uint256.NewInt(100),
Sidecar: nil, Sidecar: nil,
}
b.AddTx(types.MustSignNewTx(key, signer, blobTx))
} }
b.AddTx(types.MustSignNewTx(key, signer, blobTx))
} }
} */
}) })
// Construct testing chain // Construct testing chain

View file

@ -513,7 +513,7 @@ func testSendTransactionAnnouncementsOnly(t *testing.T, protocol uint) {
tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey) tx, _ = types.SignTx(tx, types.HomesteadSigner{}, testKey)
txs[nonce] = tx txs[nonce] = tx
} }
source.txpool.Add(txs, false, false) source.txpool.Add(txs, false)
// Make sure we get all the transactions as announcements // Make sure we get all the transactions as announcements
seen := make(map[common.Hash]struct{}) seen := make(map[common.Hash]struct{})

View file

@ -1055,8 +1055,6 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
txHash = config.TxHash txHash = config.TxHash
} }
logConfig.Debug = true
// Execute transaction, either tracing all or just the requested one // Execute transaction, either tracing all or just the requested one
var ( var (
dumps []string 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 // For BorTransaction, there will be no trace available
tx, _, _, _ := rawdb.ReadBorTransaction(api.backend.ChainDb(), hash) tx, _, _, _ := rawdb.ReadBorTransaction(api.backend.ChainDb(), hash)
if tx != nil { if tx != nil {
return &ethapi.ExecutionResult{ return &logger.ExecutionResult{
StructLogs: make([]ethapi.StructLogRes, 0), StructLogs: make([]json.RawMessage, 0),
}, nil }, nil
} else { } else {
return nil, errTxNotFound return nil, errTxNotFound
@ -1410,7 +1408,7 @@ func (api *API) traceTx(ctx context.Context, tx *types.Transaction, message *cor
config.BorTx = newBoolPtr(false) 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 { if err != nil {
return nil, fmt.Errorf("tracing failed: %w", err) 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 { } else {
// Call Prepare to clear out the statedb access list // Call Prepare to clear out the statedb access list
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex) 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 { if err != nil {
return nil, fmt.Errorf("tracing failed: %w", err) return nil, fmt.Errorf("tracing failed: %w", err)
} }

View file

@ -106,16 +106,11 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
} }
} }
returnVal := fmt.Sprintf("%x", execRes.Return()) result := &logger.ExecutionResult{
if len(execRes.Revert()) > 0 {
returnVal = fmt.Sprintf("%x", execRes.Revert())
}
result := &ethapi.ExecutionResult{
Gas: execRes.UsedGas, Gas: execRes.UsedGas,
Failed: execRes.Failed(), Failed: execRes.Failed(),
ReturnValue: returnVal, ReturnValue: execRes.Return(),
StructLogs: ethapi.FormatLogs(tracer.StructLogs()), StructLogs: tracer.StructLogs(),
} }
res := &TxTraceResult{ res := &TxTraceResult{
Result: result, Result: result,

View file

@ -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. // Error returns the VM error captured by the trace.
func (l *StructLogger) Error() error { return l.err } func (l *StructLogger) Error() error { return l.err }

View file

@ -99,7 +99,6 @@ func BenchmarkTransactionTraceV2(b *testing.B) {
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
tracer.OnTxEnd(&types.Receipt{GasUsed: res.UsedGas}, nil)
state.StateDB.RevertToSnapshot(snap) state.StateDB.RevertToSnapshot(snap)
} }
} }

View file

@ -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()) 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 // StructLogRes stores a structured log emitted by the EVM while replaying a
// transaction in debug mode // transaction in debug mode
type StructLogRes struct { type StructLogRes struct {