Skip to content

Commit 0accd7b

Browse files
committed
fix build
1 parent ca3c04b commit 0accd7b

10 files changed

+150
-30
lines changed

arbitrum/apibackend.go

+50-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717
"github.com/ethereum/go-ethereum/consensus"
1818
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
1919
"github.com/ethereum/go-ethereum/core"
20-
"github.com/ethereum/go-ethereum/core/bloombits"
20+
"github.com/ethereum/go-ethereum/core/filtermaps"
21+
"github.com/ethereum/go-ethereum/core/history"
2122
"github.com/ethereum/go-ethereum/core/rawdb"
2223
"github.com/ethereum/go-ethereum/core/state"
2324
"github.com/ethereum/go-ethereum/core/state/snapshot"
@@ -198,10 +199,14 @@ func (a *APIBackend) GetArbitrumNode() interface{} {
198199
}
199200

200201
func (a *APIBackend) GetBody(ctx context.Context, hash common.Hash, number rpc.BlockNumber) (*types.Body, error) {
201-
if body := a.BlockChain().GetBody(hash); body != nil {
202-
return body, nil
202+
body := a.BlockChain().GetBody(hash)
203+
if body == nil {
204+
if uint64(number) < a.HistoryPruningCutoff() {
205+
return nil, &history.PrunedHistoryError{}
206+
}
207+
return nil, errors.New("block body not found")
203208
}
204-
return nil, errors.New("block body not found")
209+
return body, nil
205210
}
206211

207212
// General Ethereum API
@@ -214,7 +219,7 @@ func (a *APIBackend) SyncProgressMap(ctx context.Context) map[string]interface{}
214219
return a.sync.SyncProgressMap(ctx)
215220
}
216221

217-
func (a *APIBackend) SyncProgress() ethereum.SyncProgress {
222+
func (a *APIBackend) SyncProgress(ctx context.Context) ethereum.SyncProgress {
218223
progress := a.SyncProgressMap(context.Background())
219224

220225
if len(progress) == 0 {
@@ -376,6 +381,14 @@ func (a *APIBackend) RPCTxFeeCap() float64 {
376381
return a.b.config.RPCTxFeeCap
377382
}
378383

384+
func (a *APIBackend) CurrentView() *filtermaps.ChainView {
385+
head := a.BlockChain().CurrentBlock()
386+
if head == nil {
387+
return nil
388+
}
389+
return filtermaps.NewChainView(a.BlockChain(), head.Number.Uint64(), head.Hash())
390+
}
391+
379392
func (a *APIBackend) RPCEVMTimeout() time.Duration {
380393
return a.b.config.RPCEVMTimeout
381394
}
@@ -423,6 +436,9 @@ func (a *APIBackend) blockNumberToUint(ctx context.Context, number rpc.BlockNumb
423436
}
424437
return currentFinalizedBlock.Number.Uint64(), nil
425438
}
439+
if number == rpc.EarliestBlockNumber {
440+
return a.HistoryPruningCutoff(), nil
441+
}
426442
if number < 0 {
427443
return 0, errors.New("block number not supported")
428444
}
@@ -477,11 +493,23 @@ func (a *APIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber)
477493
if err != nil {
478494
return nil, err
479495
}
480-
return a.BlockChain().GetBlockByNumber(numUint), nil
496+
block := a.BlockChain().GetBlockByNumber(numUint)
497+
if block == nil && numUint < a.HistoryPruningCutoff() {
498+
return nil, &history.PrunedHistoryError{}
499+
}
500+
return block, nil
481501
}
482502

483503
func (a *APIBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) {
484-
return a.BlockChain().GetBlockByHash(hash), nil
504+
number := a.BlockChain().GetBlockNumber(hash)
505+
if number == nil {
506+
return nil, nil
507+
}
508+
block := a.BlockChain().GetBlock(hash, *number)
509+
if block == nil && *number < a.HistoryPruningCutoff() {
510+
return nil, &history.PrunedHistoryError{}
511+
}
512+
return block, nil
485513
}
486514

487515
func (a *APIBackend) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error) {
@@ -500,6 +528,10 @@ func (a *APIBackend) BlockMetadataByNumber(ctx context.Context, blockNum uint64)
500528
return a.sync.BlockMetadataByNumber(ctx, blockNum)
501529
}
502530

531+
func (a *APIBackend) NewMatcherBackend() filtermaps.MatcherBackend {
532+
return a.b.filterMaps.NewMatcherBackend()
533+
}
534+
503535
func StateAndHeaderFromHeader(ctx context.Context, chainDb ethdb.Database, bc *core.BlockChain, maxRecreateStateDepth int64, header *types.Header, err error) (*state.StateDB, *types.Header, error) {
504536
if err != nil {
505537
return nil, header, err
@@ -613,6 +645,11 @@ func (a *APIBackend) StateAtTransaction(ctx context.Context, block *types.Block,
613645
return eth.NewArbEthereum(a.b.arb.BlockChain(), a.ChainDb()).StateAtTransaction(ctx, block, txIndex, reexec)
614646
}
615647

648+
func (a *APIBackend) HistoryPruningCutoff() uint64 {
649+
bn, _ := a.BlockChain().HistoryPruningCutoff()
650+
return bn
651+
}
652+
616653
func (a *APIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) {
617654
return a.BlockChain().GetReceiptsByHash(hash), nil
618655
}
@@ -647,9 +684,13 @@ func (a *APIBackend) SendConditionalTx(ctx context.Context, signedTx *types.Tran
647684
return a.b.EnqueueL2Message(ctx, signedTx, options)
648685
}
649686

650-
func (a *APIBackend) GetTransaction(ctx context.Context, txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64, error) {
687+
func (a *APIBackend) GetTransaction(txHash common.Hash) (bool, *types.Transaction, common.Hash, uint64, uint64) {
651688
tx, blockHash, blockNumber, index := rawdb.ReadTransaction(a.b.chainDb, txHash)
652-
return tx != nil, tx, blockHash, blockNumber, index, nil
689+
return tx != nil, tx, blockHash, blockNumber, index
690+
}
691+
692+
func (a *APIBackend) TxIndexDone() bool {
693+
return a.BlockChain().TxIndexDone()
653694
}
654695

655696
func (a *APIBackend) GetPoolTransactions() (types.Transactions, error) {
@@ -687,21 +728,11 @@ func (a *APIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subs
687728
}
688729

689730
// Filter API
690-
func (a *APIBackend) BloomStatus() (uint64, uint64) {
691-
sections, _, _ := a.b.bloomIndexer.Sections()
692-
return a.b.config.BloomBitsBlocks, sections
693-
}
694731

695732
func (a *APIBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
696733
return rawdb.ReadLogs(a.ChainDb(), hash, number), nil
697734
}
698735

699-
func (a *APIBackend) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession) {
700-
for i := 0; i < bloomFilterThreads; i++ {
701-
go session.Multiplex(bloomRetrievalBatch, bloomRetrievalWait, a.b.bloomRequests)
702-
}
703-
}
704-
705736
func (a *APIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
706737
return a.BlockChain().SubscribeLogsEvent(ch)
707738
}

core/blockchain.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,8 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er
26722672
// active. This is useful so operators know their client is ready for the fork.
26732673
func (bc *BlockChain) logForkReadiness(block *types.Block) {
26742674
c := bc.Config()
2675-
current, last := c.LatestFork(block.Time()), c.LatestFork(math.MaxUint64)
2675+
arbosVersion := types.DeserializeHeaderExtraInformation(block.Header()).ArbOSFormatVersion
2676+
current, last := c.LatestFork(block.Time(), arbosVersion), c.LatestFork(math.MaxUint64, arbosVersion)
26762677
t := c.Timestamp(last)
26772678
if t == nil {
26782679
return

core/blockchain_arbitrum.go

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ func (bc *BlockChain) WriteBlockAndSetHeadWithTime(block *types.Block, receipts
8585
}
8686

8787
func (bc *BlockChain) ReorgToOldBlock(newHead *types.Block) error {
88-
bc.wg.Add(1)
89-
defer bc.wg.Done()
9088
if _, err := bc.SetCanonical(newHead); err != nil {
9189
return fmt.Errorf("error reorging to old block: %w", err)
9290
}

core/blockchain_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4202,7 +4202,7 @@ func testChainReorgSnapSync(t *testing.T, ancientLimit uint64) {
42024202
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false)
42034203
defer db.Close()
42044204

4205-
chain, _ := NewBlockChain(db, DefaultCacheConfigWithScheme(rawdb.PathScheme), gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil)
4205+
chain, _ := NewBlockChain(db, DefaultCacheConfigWithScheme(rawdb.PathScheme), nil, gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil)
42064206
defer chain.Stop()
42074207

42084208
if n, err := chain.InsertReceiptChain(blocks, receipts, ancientLimit); err != nil {
@@ -4317,7 +4317,7 @@ func testInsertChainWithCutoff(t *testing.T, cutoff uint64, ancientLimit uint64,
43174317

43184318
db, _ := rawdb.NewDatabaseWithFreezer(rawdb.NewMemoryDatabase(), "", "", false)
43194319
defer db.Close()
4320-
chain, _ := NewBlockChain(db, DefaultCacheConfigWithScheme(rawdb.PathScheme), genesis, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil)
4320+
chain, _ := NewBlockChain(db, DefaultCacheConfigWithScheme(rawdb.PathScheme), nil, genesis, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil)
43214321
defer chain.Stop()
43224322

43234323
var (

core/txpool/locals/tx_tracker_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func newTestEnv(t *testing.T, n int, gasTip uint64, journal string) *testEnv {
6565
})
6666

6767
db := rawdb.NewMemoryDatabase()
68-
chain, _ := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil)
68+
chain, _ := core.NewBlockChain(db, nil, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil)
6969

7070
legacyPool := legacypool.New(legacypool.DefaultConfig, chain)
7171
pool, err := txpool.New(gasTip, chain, []txpool.SubPool{legacyPool})

core/types/arb_types.go

+90
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ func (tx *ArbitrumUnsignedTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int)
142142
return dst.Set(baseFee)
143143
}
144144

145+
func (tx *ArbitrumUnsignedTx) sigHash(chainID *big.Int) common.Hash {
146+
return prefixedRlpHash(
147+
ArbitrumUnsignedTxType,
148+
[]any{
149+
chainID,
150+
tx.From,
151+
tx.Nonce,
152+
tx.GasFeeCap,
153+
tx.Gas,
154+
tx.To,
155+
tx.Value,
156+
tx.Data,
157+
})
158+
}
159+
145160
type ArbitrumContractTx struct {
146161
ChainId *big.Int
147162
RequestId common.Hash
@@ -212,6 +227,21 @@ func (tx *ArbitrumContractTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int)
212227
return dst.Set(baseFee)
213228
}
214229

230+
func (tx *ArbitrumContractTx) sigHash(chainID *big.Int) common.Hash {
231+
return prefixedRlpHash(
232+
ArbitrumContractTxType,
233+
[]any{
234+
chainID,
235+
tx.RequestId,
236+
tx.From,
237+
tx.GasFeeCap,
238+
tx.Gas,
239+
tx.To,
240+
tx.Value,
241+
tx.Data,
242+
})
243+
}
244+
215245
type ArbitrumRetryTx struct {
216246
ChainId *big.Int
217247
Nonce uint64
@@ -296,6 +326,25 @@ func (tx *ArbitrumRetryTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *bi
296326
return dst.Set(baseFee)
297327
}
298328

329+
func (tx *ArbitrumRetryTx) sigHash(chainID *big.Int) common.Hash {
330+
return prefixedRlpHash(
331+
ArbitrumRetryTxType,
332+
[]any{
333+
chainID,
334+
tx.Nonce,
335+
tx.From,
336+
tx.GasFeeCap,
337+
tx.Gas,
338+
tx.To,
339+
tx.Value,
340+
tx.Data,
341+
tx.TicketId,
342+
tx.RefundTo,
343+
tx.MaxRefund,
344+
tx.SubmissionFeeRefund,
345+
})
346+
}
347+
299348
type ArbitrumSubmitRetryableTx struct {
300349
ChainId *big.Int
301350
RequestId common.Hash
@@ -415,6 +464,26 @@ func (tx *ArbitrumSubmitRetryableTx) data() []byte {
415464
return data
416465
}
417466

467+
func (tx *ArbitrumSubmitRetryableTx) sigHash(chainID *big.Int) common.Hash {
468+
return prefixedRlpHash(
469+
ArbitrumSubmitRetryableTxType,
470+
[]any{
471+
chainID,
472+
tx.RequestId,
473+
tx.From,
474+
tx.L1BaseFee,
475+
tx.DepositValue,
476+
tx.GasFeeCap,
477+
tx.Gas,
478+
tx.RetryTo,
479+
tx.RetryValue,
480+
tx.Beneficiary,
481+
tx.MaxSubmissionFee,
482+
tx.FeeRefundAddr,
483+
tx.RetryData,
484+
})
485+
}
486+
418487
type ArbitrumDepositTx struct {
419488
ChainId *big.Int
420489
L1RequestId common.Hash
@@ -473,6 +542,18 @@ func (d *ArbitrumDepositTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *b
473542
return dst.Set(bigZero)
474543
}
475544

545+
func (d *ArbitrumDepositTx) sigHash(chainID *big.Int) common.Hash {
546+
return prefixedRlpHash(
547+
ArbitrumRetryTxType,
548+
[]any{
549+
chainID,
550+
d.L1RequestId,
551+
d.From,
552+
d.To,
553+
d.Value,
554+
})
555+
}
556+
476557
type ArbitrumInternalTx struct {
477558
ChainId *big.Int
478559
Data []byte
@@ -518,6 +599,15 @@ func (t *ArbitrumInternalTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *
518599
return dst.Set(bigZero)
519600
}
520601

602+
func (t *ArbitrumInternalTx) sigHash(chainID *big.Int) common.Hash {
603+
return prefixedRlpHash(
604+
ArbitrumInternalTxType,
605+
[]any{
606+
chainID,
607+
t.Data,
608+
})
609+
}
610+
521611
type HeaderInfo struct {
522612
SendRoot common.Hash
523613
SendCount uint64

eth/api_backend_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func initBackend(withLocal bool) *EthAPIBackend {
6161
db = rawdb.NewMemoryDatabase()
6262
engine = beacon.New(ethash.NewFaker())
6363
)
64-
chain, _ := core.NewBlockChain(db, nil, gspec, nil, engine, vm.Config{}, nil)
64+
chain, _ := core.NewBlockChain(db, nil, nil, gspec, nil, engine, vm.Config{}, nil)
6565

6666
txconfig := legacypool.DefaultConfig
6767
txconfig.Journal = "" // Don't litter the disk with test journals

eth/filters/filter_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func TestRangeLogs(t *testing.T) {
435435
}
436436
chain, _ := core.GenerateChain(gspec.Config, gspec.ToBlock(), ethash.NewFaker(), db, 1000, func(i int, gen *core.BlockGen) {})
437437
var l uint64
438-
bc, err := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, &l)
438+
bc, err := core.NewBlockChain(db, nil, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, &l)
439439
if err != nil {
440440
t.Fatal(err)
441441
}

rpc/websocket_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ func TestWebsocketMethodNameLengthLimit(t *testing.T) {
397397

398398
var (
399399
srv = newTestServer()
400-
httpsrv = httptest.NewServer(srv.WebsocketHandler([]string{"*"}))
400+
httpsrv = httptest.NewServer(srv.WebsocketHandler([]string{"*"}, 0))
401401
wsURL = "ws:" + strings.TrimPrefix(httpsrv.URL, "http:")
402402
)
403403
defer srv.Stop()

tests/transaction_test_util.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ func (tt *TransactionTest) Run() error {
128128
return UnsupportedForkError{Name: testcase.name}
129129
}
130130
var (
131-
rules = config.Rules(new(big.Int), testcase.isMerge, 0)
132-
signer = types.MakeSigner(config, new(big.Int), 0)
131+
rules = config.Rules(new(big.Int), testcase.isMerge, 0, 0)
132+
signer = types.MakeSigner(config, new(big.Int), 0, 0)
133133
)
134134
sender, hash, gas, err := validateTx(tt.Txbytes, signer, &rules)
135135
if err != nil {

0 commit comments

Comments
 (0)