upstream v1.15.11: fixed all compilation errors

This commit is contained in:
Pratik Patil 2025-05-22 14:06:07 +05:30
parent b7f304f72e
commit 1742bd3b27
No known key found for this signature in database
GPG key ID: AFDCA496554874B3
15 changed files with 85 additions and 77 deletions

View file

@ -977,6 +977,14 @@ func (fb *filterBackend) NewMatcherBackend() filtermaps.MatcherBackend {
panic("not supported") panic("not supported")
} }
func (fb *filterBackend) CurrentView() *filtermaps.ChainView {
panic("implement me")
}
func (fb *filterBackend) HistoryPruningCutoff() uint64 {
panic("implement me")
}
func nullSubscription() event.Subscription { func nullSubscription() event.Subscription {
return event.NewSubscription(func(quit <-chan struct{}) error { return event.NewSubscription(func(quit <-chan struct{}) error {
<-quit <-quit

View file

@ -331,7 +331,7 @@ func ImportHistory(chain *core.BlockChain, db ethdb.Database, dir string, networ
if err != nil { if err != nil {
return fmt.Errorf("error reading receipts %d: %w", it.Number(), err) return fmt.Errorf("error reading receipts %d: %w", it.Number(), err)
} }
if status, err := chain.HeaderChain().InsertHeaderChain([]*types.Header{block.Header()}, start); err != nil { if status, err := chain.HeaderChain().InsertHeaderChain([]*types.Header{block.Header()}, start, forker); err != nil {
return fmt.Errorf("error inserting header %d: %w", it.Number(), err) return fmt.Errorf("error inserting header %d: %w", it.Number(), err)
} else if status != core.CanonStatTy { } else if status != core.CanonStatTy {
return fmt.Errorf("error inserting header %d, not canon: %v", it.Number(), status) return fmt.Errorf("error inserting header %d, not canon: %v", it.Number(), status)

View file

@ -22,7 +22,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"math"
"math/big" "math/big"
"runtime" "runtime"
"slices" "slices"
@ -2548,8 +2547,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
trieDiffNodes, trieBufNodes, _ := bc.triedb.Size() trieDiffNodes, trieBufNodes, _ := bc.triedb.Size()
stats.report(chain, it.index, snapDiffItems, snapBufItems, trieDiffNodes, trieBufNodes, setHead) stats.report(chain, it.index, snapDiffItems, snapBufItems, trieDiffNodes, trieBufNodes, setHead)
// Print confirmation that a future fork is scheduled, but not yet active. /*
bc.logForkReadiness(block) // Print confirmation that a future fork is scheduled, but not yet active.
bc.logForkReadiness(block)
*/
if !setHead { if !setHead {
// After merge we expect few side chains. Simply count // After merge we expect few side chains. Simply count
@ -3295,6 +3296,7 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er
log.Error(summarizeBadBlock(block, receipts, bc.Config(), err)) log.Error(summarizeBadBlock(block, receipts, bc.Config(), err))
} }
/*
// logForkReadiness will write a log when a future fork is scheduled, but not // logForkReadiness will write a log when a future fork is scheduled, but not
// active. This is useful so operators know their client is ready for the fork. // active. This is useful so operators know their client is ready for the fork.
func (bc *BlockChain) logForkReadiness(block *types.Block) { func (bc *BlockChain) logForkReadiness(block *types.Block) {
@ -3311,6 +3313,7 @@ func (bc *BlockChain) logForkReadiness(block *types.Block) {
bc.lastForkReadyAlert = time.Now() bc.lastForkReadyAlert = time.Now()
} }
} }
*/
// summarizeBadBlock returns a string summarizing the bad block and other // summarizeBadBlock returns a string summarizing the bad block and other
// relevant information. // relevant information.
@ -3388,9 +3391,3 @@ func (bc *BlockChain) GetTrieFlushInterval() time.Duration {
func (bc *BlockChain) SubscribeChain2HeadEvent(ch chan<- Chain2HeadEvent) event.Subscription { func (bc *BlockChain) SubscribeChain2HeadEvent(ch chan<- Chain2HeadEvent) event.Subscription {
return bc.scope.Track(bc.chain2HeadFeed.Subscribe(ch)) return bc.scope.Track(bc.chain2HeadFeed.Subscribe(ch))
} }
// HistoryPruningCutoff returns the configured history pruning point.
// Blocks before this might not be available in the database.
func (bc *BlockChain) HistoryPruningCutoff() uint64 {
return bc.cacheConfig.HistoryPruningCutoff
}

View file

@ -2125,13 +2125,13 @@ func testInsertReceiptChainRollback(t *testing.T, scheme string) {
} }
// Set up a BlockChain that uses the ancient store. // Set up a BlockChain that uses the ancient store.
ancientDb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false) ancientDb, err := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false, false, false)
if err != nil { if err != nil {
t.Fatalf("failed to create temp freezer db: %v", err) t.Fatalf("failed to create temp freezer db: %v", err)
} }
defer ancientDb.Close() defer ancientDb.Close()
ancientChain, _ := NewBlockChain(ancientDb, DefaultCacheConfigWithScheme(scheme), gspec, nil, ethash.NewFaker(), vm.Config{}, nil) ancientChain, _ := NewBlockChain(ancientDb, DefaultCacheConfigWithScheme(scheme), gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
defer ancientChain.Stop() defer ancientChain.Stop()
// Import the canonical header chain. // Import the canonical header chain.

View file

@ -68,13 +68,13 @@ type txIndexer struct {
// newTxIndexer initializes the transaction indexer. // newTxIndexer initializes the transaction indexer.
func newTxIndexer(limit uint64, chain *BlockChain) *txIndexer { func newTxIndexer(limit uint64, chain *BlockChain) *txIndexer {
cutoff, _ := chain.HistoryPruningCutoff()
indexer := &txIndexer{ indexer := &txIndexer{
limit: limit, limit: limit,
cutoff: chain.HistoryPruningCutoff(), cutoff: cutoff,
db: chain.db, db: chain.db,
progress: make(chan chan TxIndexProgress), term: make(chan chan struct{}),
term: make(chan chan struct{}), closed: make(chan struct{}),
closed: make(chan struct{}),
} }
indexer.head.Store(indexer.resolveHead()) indexer.head.Store(indexer.resolveHead())
indexer.tail.Store(rawdb.ReadTxIndexTail(chain.db)) indexer.tail.Store(rawdb.ReadTxIndexTail(chain.db))

View file

@ -218,10 +218,6 @@ func (r *reserver) Has(address common.Address) bool {
return exists return exists
} }
func MakeAddressReserver() {
makeAddressReserver()
}
// makeTx is a utility method to construct a random blob transaction and sign it // makeTx is a utility method to construct a random blob transaction and sign it
// with a valid key, only setting the interesting fields from the perspective of // with a valid key, only setting the interesting fields from the perspective of
// the blob pool. // the blob pool.

View file

@ -61,7 +61,7 @@ func initBackend(withLocal bool) *EthAPIBackend {
db = rawdb.NewMemoryDatabase() db = rawdb.NewMemoryDatabase()
engine = beacon.New(ethash.NewFaker()) engine = beacon.New(ethash.NewFaker())
) )
chain, _ := core.NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil) chain, _ := core.NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil, nil, nil)
txconfig := legacypool.DefaultConfig txconfig := legacypool.DefaultConfig
txconfig.Journal = "" // Don't litter the disk with test journals txconfig.Journal = "" // Don't litter the disk with test journals

View file

@ -227,18 +227,17 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EnablePreimageRecording: config.EnablePreimageRecording, EnablePreimageRecording: config.EnablePreimageRecording,
} }
cacheConfig = &core.CacheConfig{ cacheConfig = &core.CacheConfig{
TrieCleanLimit: config.TrieCleanCache, TrieCleanLimit: config.TrieCleanCache,
TrieCleanNoPrefetch: config.NoPrefetch, TrieCleanNoPrefetch: config.NoPrefetch,
TrieDirtyLimit: config.TrieDirtyCache, TrieDirtyLimit: config.TrieDirtyCache,
TrieDirtyDisabled: config.NoPruning, TrieDirtyDisabled: config.NoPruning,
TrieTimeLimit: config.TrieTimeout, TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache, SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages, Preimages: config.Preimages,
StateHistory: config.StateHistory, StateHistory: config.StateHistory,
StateScheme: scheme, StateScheme: scheme,
TriesInMemory: config.TriesInMemory, TriesInMemory: config.TriesInMemory,
ChainHistoryMode: config.HistoryMode, ChainHistoryMode: config.HistoryMode,
HistoryPruningCutoff: historyPruningCutoff,
} }
) )
@ -296,7 +295,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
HashScheme: scheme == rawdb.HashScheme, HashScheme: scheme == rawdb.HashScheme,
} }
chainView := eth.newChainView(eth.blockchain.CurrentBlock()) chainView := eth.newChainView(eth.blockchain.CurrentBlock())
historyCutoff := eth.blockchain.HistoryPruningCutoff() historyCutoff, _ := eth.blockchain.HistoryPruningCutoff()
var finalBlock uint64 var finalBlock uint64
if fb := eth.blockchain.CurrentFinalBlock(); fb != nil { if fb := eth.blockchain.CurrentFinalBlock(); fb != nil {
finalBlock = fb.Number.Uint64() finalBlock = fb.Number.Uint64()
@ -867,7 +866,7 @@ func (s *Ethereum) updateFilterMapsHeads() {
if head == nil || newHead.Hash() != head.Hash() { if head == nil || newHead.Hash() != head.Hash() {
head = newHead head = newHead
chainView := s.newChainView(head) chainView := s.newChainView(head)
historyCutoff := s.blockchain.HistoryPruningCutoff() historyCutoff, _ := s.blockchain.HistoryPruningCutoff()
var finalBlock uint64 var finalBlock uint64
if fb := s.blockchain.CurrentFinalBlock(); fb != nil { if fb := s.blockchain.CurrentFinalBlock(); fb != nil {
finalBlock = fb.Number.Uint64() finalBlock = fb.Number.Uint64()

View file

@ -436,8 +436,6 @@ func (q *queue) stats() []interface{} {
} }
} }
// This was removed from geth
/*
// ReserveHeaders reserves a set of headers for the given peer, skipping any // ReserveHeaders reserves a set of headers for the given peer, skipping any
// previously failed batches. // previously failed batches.
func (q *queue) ReserveHeaders(p *peerConnection, count int) *fetchRequest { func (q *queue) ReserveHeaders(p *peerConnection, count int) *fetchRequest {
@ -480,7 +478,6 @@ func (q *queue) ReserveHeaders(p *peerConnection, count int) *fetchRequest {
return request return request
} }
*/
// ReserveBodies reserves a set of body fetches for the given peer, skipping any // ReserveBodies reserves a set of body fetches for the given peer, skipping any
// previously failed downloads. Beside the next batch of needed fetches, it also // previously failed downloads. Beside the next batch of needed fetches, it also
@ -644,8 +641,6 @@ func (q *queue) Revoke(peerID string) {
} }
} }
// This was removed from geth
/*
// ExpireHeaders cancels a request that timed out and moves the pending fetch // ExpireHeaders cancels a request that timed out and moves the pending fetch
// task back into the queue for rescheduling. // task back into the queue for rescheduling.
func (q *queue) ExpireHeaders(peer string) int { func (q *queue) ExpireHeaders(peer string) int {
@ -656,7 +651,6 @@ func (q *queue) ExpireHeaders(peer string) int {
return q.expire(peer, q.headerPendPool, q.headerTaskQueue) return q.expire(peer, q.headerPendPool, q.headerTaskQueue)
} }
*/
// ExpireBodies checks for in flight block body requests that exceeded a timeout // ExpireBodies checks for in flight block body requests that exceeded a timeout
// allowance, canceling them and returning the responsible peers for penalisation. // allowance, canceling them and returning the responsible peers for penalisation.
@ -711,8 +705,6 @@ func (q *queue) expire(peer string, pendPool map[string]*fetchRequest, taskQueue
return len(req.Headers) return len(req.Headers)
} }
// This was removed from geth
/*
// DeliverHeaders injects a header retrieval response into the header results // DeliverHeaders injects a header retrieval response into the header results
// cache. This method either accepts all headers it received, or none of them // cache. This method either accepts all headers it received, or none of them
// if they do not map correctly to the skeleton. // if they do not map correctly to the skeleton.
@ -836,7 +828,6 @@ func (q *queue) DeliverHeaders(id string, headers []*types.Header, hashes []comm
return len(headers), nil return len(headers), nil
} }
*/
// DeliverBodies injects a block body retrieval response into the results queue. // DeliverBodies injects a block body retrieval response into the results queue.
// The method returns the number of blocks bodies accepted from the delivery and // The method returns the number of blocks bodies accepted from the delivery and

View file

@ -10,10 +10,10 @@ import (
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"
filtermaps "github.com/ethereum/go-ethereum/core/filtermaps"
types "github.com/ethereum/go-ethereum/core/types" types "github.com/ethereum/go-ethereum/core/types"
ethdb "github.com/ethereum/go-ethereum/ethdb" ethdb "github.com/ethereum/go-ethereum/ethdb"
event "github.com/ethereum/go-ethereum/event" event "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/core/filtermaps"
params "github.com/ethereum/go-ethereum/params" params "github.com/ethereum/go-ethereum/params"
rpc "github.com/ethereum/go-ethereum/rpc" rpc "github.com/ethereum/go-ethereum/rpc"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"
@ -42,21 +42,6 @@ func (m *MockBackend) EXPECT() *MockBackendMockRecorder {
return m.recorder return m.recorder
} }
// BloomStatus mocks base method.
func (m *MockBackend) BloomStatus() (uint64, uint64) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BloomStatus")
ret0, _ := ret[0].(uint64)
ret1, _ := ret[1].(uint64)
return ret0, ret1
}
// BloomStatus indicates an expected call of BloomStatus.
func (mr *MockBackendMockRecorder) BloomStatus() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BloomStatus", reflect.TypeOf((*MockBackend)(nil).BloomStatus))
}
// ChainConfig mocks base method. // ChainConfig mocks base method.
func (m *MockBackend) ChainConfig() *params.ChainConfig { func (m *MockBackend) ChainConfig() *params.ChainConfig {
m.ctrl.T.Helper() m.ctrl.T.Helper()
@ -99,6 +84,20 @@ func (mr *MockBackendMockRecorder) CurrentHeader() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CurrentHeader", reflect.TypeOf((*MockBackend)(nil).CurrentHeader)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CurrentHeader", reflect.TypeOf((*MockBackend)(nil).CurrentHeader))
} }
// CurrentView mocks base method.
func (m *MockBackend) CurrentView() *filtermaps.ChainView {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CurrentView")
ret0, _ := ret[0].(*filtermaps.ChainView)
return ret0
}
// CurrentView indicates an expected call of CurrentView.
func (mr *MockBackendMockRecorder) CurrentView() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CurrentView", reflect.TypeOf((*MockBackend)(nil).CurrentView))
}
// GetBody mocks base method. // GetBody mocks base method.
func (m *MockBackend) GetBody(arg0 context.Context, arg1 common.Hash, arg2 rpc.BlockNumber) (*types.Body, error) { func (m *MockBackend) GetBody(arg0 context.Context, arg1 common.Hash, arg2 rpc.BlockNumber) (*types.Body, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
@ -204,6 +203,33 @@ func (mr *MockBackendMockRecorder) HeaderByNumber(arg0, arg1 interface{}) *gomoc
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByNumber", reflect.TypeOf((*MockBackend)(nil).HeaderByNumber), arg0, arg1) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderByNumber", reflect.TypeOf((*MockBackend)(nil).HeaderByNumber), arg0, arg1)
} }
// HistoryPruningCutoff mocks base method.
func (m *MockBackend) HistoryPruningCutoff() uint64 {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HistoryPruningCutoff")
ret0, _ := ret[0].(uint64)
return ret0
}
// HistoryPruningCutoff indicates an expected call of HistoryPruningCutoff.
func (mr *MockBackendMockRecorder) HistoryPruningCutoff() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HistoryPruningCutoff", reflect.TypeOf((*MockBackend)(nil).HistoryPruningCutoff))
}
// NewMatcherBackend mocks base method.
func (m *MockBackend) NewMatcherBackend() filtermaps.MatcherBackend {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NewMatcherBackend")
ret0, _ := ret[0].(filtermaps.MatcherBackend)
return ret0
}
// NewMatcherBackend indicates an expected call of NewMatcherBackend.
func (mr *MockBackendMockRecorder) NewMatcherBackend() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewMatcherBackend", reflect.TypeOf((*MockBackend)(nil).NewMatcherBackend))
}
// SubscribeChainEvent mocks base method. // SubscribeChainEvent mocks base method.
func (m *MockBackend) SubscribeChainEvent(arg0 chan<- core.ChainEvent) event.Subscription { func (m *MockBackend) SubscribeChainEvent(arg0 chan<- core.ChainEvent) event.Subscription {
@ -288,11 +314,3 @@ func (mr *MockBackendMockRecorder) SubscribeStateSyncEvent(arg0 interface{}) *go
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeStateSyncEvent", reflect.TypeOf((*MockBackend)(nil).SubscribeStateSyncEvent), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SubscribeStateSyncEvent", reflect.TypeOf((*MockBackend)(nil).SubscribeStateSyncEvent), arg0)
} }
func (m *MockBackend) NewMatcherBackend() filtermaps.MatcherBackend {
panic("implement me")
}
func (mr *MockBackendMockRecorder) NewMatcherBackend() filtermaps.MatcherBackend {
panic("implement me")
}

View file

@ -120,7 +120,7 @@ func (m *MockFullNodeBackend) Stats() (pending int, queued int) {
return 0, 0 return 0, 0
} }
func (m *MockFullNodeBackend) SyncProgress() ethereum.SyncProgress { func (m *MockFullNodeBackend) SyncProgress(ctx context.Context) ethereum.SyncProgress {
return ethereum.SyncProgress{} return ethereum.SyncProgress{}
} }

View file

@ -80,10 +80,7 @@ func blockToProtoBlock(h *types.Block) *protobor.Block {
} }
func (s *Server) TransactionReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) { func (s *Server) TransactionReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) {
_, _, blockHash, _, txnIndex, err := s.backend.APIBackend.GetTransaction(ctx, protoutil.ConvertH256ToHash(req.Hash)) _, _, blockHash, _, txnIndex := s.backend.APIBackend.GetTransaction(protoutil.ConvertH256ToHash(req.Hash))
if err != nil {
return nil, err
}
receipts, err := s.backend.APIBackend.GetReceipts(ctx, blockHash) receipts, err := s.backend.APIBackend.GetReceipts(ctx, blockHash)
if err != nil { if err != nil {

View file

@ -203,7 +203,7 @@ func (s *Server) Status(ctx context.Context, in *proto.StatusRequest) (*proto.St
} }
apiBackend := s.backend.APIBackend apiBackend := s.backend.APIBackend
syncProgress := apiBackend.SyncProgress() syncProgress := apiBackend.SyncProgress(ctx)
resp := &proto.StatusResponse{ resp := &proto.StatusResponse{
CurrentHeader: headerToProtoHeader(apiBackend.CurrentHeader()), CurrentHeader: headerToProtoHeader(apiBackend.CurrentHeader()),

View file

@ -716,7 +716,7 @@ func (b testBackend) SubscribePendingLogsEvent(ch chan<- []*types.Log) event.Sub
} }
func (b testBackend) HistoryPruningCutoff() uint64 { func (b testBackend) HistoryPruningCutoff() uint64 {
bn := b.chain.HistoryPruningCutoff() bn, _ := b.chain.HistoryPruningCutoff()
return bn return bn
} }

View file

@ -1384,6 +1384,7 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
} }
} }
/*
// Timestamp returns the timestamp associated with the fork or returns nil if // Timestamp returns the timestamp associated with the fork or returns nil if
// the fork isn't defined or isn't a time-based fork. // the fork isn't defined or isn't a time-based fork.
func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 { func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 {
@ -1400,6 +1401,7 @@ func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 {
return nil return nil
} }
} }
*/
// isForkBlockIncompatible returns true if a fork scheduled at block s1 cannot be // isForkBlockIncompatible returns true if a fork scheduled at block s1 cannot be
// rescheduled to block s2 because head is already past the fork. // rescheduled to block s2 because head is already past the fork.