This commit is contained in:
allen 2025-09-18 13:14:20 -04:00
parent a281cbf8b1
commit a78978c430
2 changed files with 0 additions and 43 deletions

View file

@ -60,41 +60,6 @@ func sanitizeRange(start, end uint64, freezer ethdb.AncientReader) (uint64, uint
return first, last, nil return first, last, nil
} }
func inspectHistory(freezer ethdb.AncientReader, start, end uint64, onHistory func(*stateHistory, *HistoryStats)) (*HistoryStats, error) {
var (
stats = &HistoryStats{}
init = time.Now()
logged = time.Now()
)
start, end, err := sanitizeRange(start, end, freezer)
if err != nil {
return nil, err
}
for id := start; id <= end; id += 1 {
// The entire history object is decoded, although it's unnecessary for
// account inspection. TODO(rjl493456442) optimization is worthwhile.
h, err := readStateHistory(freezer, id)
if err != nil {
return nil, err
}
if id == start {
stats.Start = h.meta.block
}
if id == end {
stats.End = h.meta.block
}
onHistory(h, stats)
if time.Since(logged) > time.Second*8 {
logged = time.Now()
eta := float64(time.Since(init)) / float64(id-start+1) * float64(end-id)
log.Info("Inspecting state history", "checked", id-start+1, "left", end-id, "elapsed", common.PrettyDuration(time.Since(init)), "eta", common.PrettyDuration(eta))
}
}
log.Info("Inspected state history", "total", end-start+1, "elapsed", common.PrettyDuration(time.Since(init)))
return stats, nil
}
// accountHistory inspects the account history within the range. // accountHistory inspects the account history within the range.
func accountHistory(freezer ethdb.AncientReader, address common.Address, start, end uint64) (*HistoryStats, error) { func accountHistory(freezer ethdb.AncientReader, address common.Address, start, end uint64) (*HistoryStats, error) {
return inspectAccountHistory(freezer, address, start, end) return inspectAccountHistory(freezer, address, start, end)

View file

@ -683,14 +683,6 @@ func (h *stateHistory) getSlotIndex(storageIndexes []byte, position uint32) *slo
return &index return &index
} }
// isTargetSlot checks if the slot index matches the target slot (handles v0/v1 compatibility)
func (h *stateHistory) isTargetSlot(slotIdx *slotIndex, targetSlot common.Hash) bool {
if h.meta.version == stateHistoryV0 {
return slotIdx.id == crypto.Keccak256Hash(targetSlot.Bytes())
}
return slotIdx.id == targetSlot
}
// setStorageData safely extracts and sets the storage data // setStorageData safely extracts and sets the storage data
func (h *stateHistory) setStorageData(storageData []byte, slotIdx *slotIndex, targetAddr common.Address) error { func (h *stateHistory) setStorageData(storageData []byte, slotIdx *slotIndex, targetAddr common.Address) error {
end := slotIdx.offset + uint32(slotIdx.length) end := slotIdx.offset + uint32(slotIdx.length)