Skip to content

Commit f71771a

Browse files
Merge pull request #570 from OffchainLabs/historical-state-pathdb
arbitrum: use historical state reader with pathdb when handling rpc
2 parents e845151 + 6d1f3c4 commit f71771a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

arbitrum/apibackend.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,21 @@ func StateAndHeaderFromHeader(ctx context.Context, chainDb ethdb.Database, bc *c
545545
if archiveClientsManager != nil && header.Number.Uint64() <= archiveClientsManager.lastAvailableBlock() {
546546
return nil, header, &types.ErrUseArchiveFallback{BlockNum: header.Number.Uint64()}
547547
}
548+
549+
// use upstream path for PathScheme, as:
550+
// - intermediate state recreation and trie node referencing doesn't apply to pathdb
551+
// - HistoricState is supported only by pathdb
552+
if bc.TrieDB().Scheme() == rawdb.PathScheme {
553+
statedb, err := bc.StateAt(header.Root)
554+
if err != nil {
555+
statedb, err = bc.HistoricState(header.Root)
556+
if err != nil {
557+
return nil, nil, err
558+
}
559+
}
560+
return statedb, header, nil
561+
}
562+
548563
stateFor := func(db state.Database, snapshots *snapshot.Tree) func(header *types.Header) (*state.StateDB, StateReleaseFunc, error) {
549564
return func(header *types.Header) (*state.StateDB, StateReleaseFunc, error) {
550565
if header.Root != (common.Hash{}) {

0 commit comments

Comments
 (0)