@@ -17,7 +17,8 @@ import (
17
17
"github.com/ethereum/go-ethereum/consensus"
18
18
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
19
19
"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"
21
22
"github.com/ethereum/go-ethereum/core/rawdb"
22
23
"github.com/ethereum/go-ethereum/core/state"
23
24
"github.com/ethereum/go-ethereum/core/state/snapshot"
@@ -198,10 +199,14 @@ func (a *APIBackend) GetArbitrumNode() interface{} {
198
199
}
199
200
200
201
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" )
203
208
}
204
- return nil , errors . New ( "block body not found" )
209
+ return body , nil
205
210
}
206
211
207
212
// General Ethereum API
@@ -214,7 +219,7 @@ func (a *APIBackend) SyncProgressMap(ctx context.Context) map[string]interface{}
214
219
return a .sync .SyncProgressMap (ctx )
215
220
}
216
221
217
- func (a * APIBackend ) SyncProgress () ethereum.SyncProgress {
222
+ func (a * APIBackend ) SyncProgress (ctx context. Context ) ethereum.SyncProgress {
218
223
progress := a .SyncProgressMap (context .Background ())
219
224
220
225
if len (progress ) == 0 {
@@ -376,6 +381,14 @@ func (a *APIBackend) RPCTxFeeCap() float64 {
376
381
return a .b .config .RPCTxFeeCap
377
382
}
378
383
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
+
379
392
func (a * APIBackend ) RPCEVMTimeout () time.Duration {
380
393
return a .b .config .RPCEVMTimeout
381
394
}
@@ -423,6 +436,9 @@ func (a *APIBackend) blockNumberToUint(ctx context.Context, number rpc.BlockNumb
423
436
}
424
437
return currentFinalizedBlock .Number .Uint64 (), nil
425
438
}
439
+ if number == rpc .EarliestBlockNumber {
440
+ return a .HistoryPruningCutoff (), nil
441
+ }
426
442
if number < 0 {
427
443
return 0 , errors .New ("block number not supported" )
428
444
}
@@ -477,11 +493,23 @@ func (a *APIBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber)
477
493
if err != nil {
478
494
return nil , err
479
495
}
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
481
501
}
482
502
483
503
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
485
513
}
486
514
487
515
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)
500
528
return a .sync .BlockMetadataByNumber (ctx , blockNum )
501
529
}
502
530
531
+ func (a * APIBackend ) NewMatcherBackend () filtermaps.MatcherBackend {
532
+ return a .b .filterMaps .NewMatcherBackend ()
533
+ }
534
+
503
535
func StateAndHeaderFromHeader (ctx context.Context , chainDb ethdb.Database , bc * core.BlockChain , maxRecreateStateDepth int64 , header * types.Header , err error ) (* state.StateDB , * types.Header , error ) {
504
536
if err != nil {
505
537
return nil , header , err
@@ -613,6 +645,11 @@ func (a *APIBackend) StateAtTransaction(ctx context.Context, block *types.Block,
613
645
return eth .NewArbEthereum (a .b .arb .BlockChain (), a .ChainDb ()).StateAtTransaction (ctx , block , txIndex , reexec )
614
646
}
615
647
648
+ func (a * APIBackend ) HistoryPruningCutoff () uint64 {
649
+ bn , _ := a .BlockChain ().HistoryPruningCutoff ()
650
+ return bn
651
+ }
652
+
616
653
func (a * APIBackend ) GetReceipts (ctx context.Context , hash common.Hash ) (types.Receipts , error ) {
617
654
return a .BlockChain ().GetReceiptsByHash (hash ), nil
618
655
}
@@ -647,9 +684,13 @@ func (a *APIBackend) SendConditionalTx(ctx context.Context, signedTx *types.Tran
647
684
return a .b .EnqueueL2Message (ctx , signedTx , options )
648
685
}
649
686
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 ) {
651
688
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 ()
653
694
}
654
695
655
696
func (a * APIBackend ) GetPoolTransactions () (types.Transactions , error ) {
@@ -687,21 +728,11 @@ func (a *APIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subs
687
728
}
688
729
689
730
// Filter API
690
- func (a * APIBackend ) BloomStatus () (uint64 , uint64 ) {
691
- sections , _ , _ := a .b .bloomIndexer .Sections ()
692
- return a .b .config .BloomBitsBlocks , sections
693
- }
694
731
695
732
func (a * APIBackend ) GetLogs (ctx context.Context , hash common.Hash , number uint64 ) ([][]* types.Log , error ) {
696
733
return rawdb .ReadLogs (a .ChainDb (), hash , number ), nil
697
734
}
698
735
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
-
705
736
func (a * APIBackend ) SubscribeLogsEvent (ch chan <- []* types.Log ) event.Subscription {
706
737
return a .BlockChain ().SubscribeLogsEvent (ch )
707
738
}
0 commit comments