diff --git a/core/rawdb/accessors_state.go b/core/rawdb/accessors_state.go index 2359fb18f1..fd234e5b5b 100644 --- a/core/rawdb/accessors_state.go +++ b/core/rawdb/accessors_state.go @@ -241,6 +241,44 @@ func ReadStateHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []by return meta, accountIndex, storageIndex, accountData, storageData, nil } +// ReadAccountHistory retrieves account-related data from state history. +func ReadAccountHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []byte, error) { + meta, err := db.Ancient(stateHistoryMeta, id-1) + if err != nil { + return nil, nil, nil, err + } + accountIndex, err := db.Ancient(stateHistoryAccountIndex, id-1) + if err != nil { + return nil, nil, nil, err + } + accountData, err := db.Ancient(stateHistoryAccountData, id-1) + if err != nil { + return nil, nil, nil, err + } + return meta, accountIndex, accountData, nil +} + +// ReadStorageHistory retrieves storage-related data from state history. +func ReadStorageHistory(db ethdb.AncientReaderOp, id uint64) ([]byte, []byte, []byte, []byte, error) { + meta, err := db.Ancient(stateHistoryMeta, id-1) + if err != nil { + return nil, nil, nil, nil, err + } + accountIndex, err := db.Ancient(stateHistoryAccountIndex, id-1) + if err != nil { + return nil, nil, nil, nil, err + } + storageIndex, err := db.Ancient(stateHistoryStorageIndex, id-1) + if err != nil { + return nil, nil, nil, nil, err + } + storageData, err := db.Ancient(stateHistoryStorageData, id-1) + if err != nil { + return nil, nil, nil, nil, err + } + return meta, accountIndex, storageIndex, storageData, nil +} + // ReadStateHistoryList retrieves a list of state histories from database with // specific range. Compute the position of state history in freezer by minus one // since the id of first state history starts from one(zero for initial state). diff --git a/triedb/pathdb/history_state.go b/triedb/pathdb/history_state.go index 6dfae3f31f..458791b716 100644 --- a/triedb/pathdb/history_state.go +++ b/triedb/pathdb/history_state.go @@ -732,7 +732,7 @@ func readStateHistory(reader ethdb.AncientReader, id uint64) (*stateHistory, err // readAccountHistory reads account state history func readAccountHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address) (*stateHistory, error) { - mData, accountIndexes, _, accountData, _, err := rawdb.ReadStateHistory(reader, id) + mData, accountIndexes, accountData, err := rawdb.ReadAccountHistory(reader, id) if err != nil { return nil, err } @@ -749,7 +749,7 @@ func readAccountHistory(reader ethdb.AncientReader, id uint64, targetAddr common // readSlotHistory reads slot state history func readSlotHistory(reader ethdb.AncientReader, id uint64, targetAddr common.Address, targetSlot common.Hash) (*stateHistory, error) { - mData, accountIndexes, storageIndexes, _, storageData, err := rawdb.ReadStateHistory(reader, id) + mData, accountIndexes, storageIndexes, storageData, err := rawdb.ReadStorageHistory(reader, id) if err != nil { return nil, err }