go-ethereum/core/state
Mars 0e69530c6e
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
all: improve ETA calculation across all progress indicators (#32521)
### Summary
Fixes long-standing ETA calculation errors in progress indicators that
have been present since February 2021. The current implementation
produces increasingly inaccurate estimates due to integer division
precision loss.

### Problem

3aeccadd04/triedb/pathdb/history_indexer.go (L541-L553)
The ETA calculation has two critical issues:
1. **Integer division precision loss**: `speed` is calculated as
`uint64`
2. **Off-by-one**: `speed` uses `+ 1`(2 times) to avoid division by
zero, however it makes mistake in the final calculation

This results in wildly inaccurate time estimates that don't improve as
progress continues.

### Example
Current output during state history indexing:
```
lvl=info msg="Indexing state history" processed=16858580 left=41802252 elapsed=18h22m59.848s eta=11h36m42.252s
```

**Expected calculation:**
- Speed: 16858580 ÷ 66179848ms = 0.255 blocks/ms  
- ETA: 41802252 ÷ 0.255 = ~45.6 hours

**Current buggy calculation:**
- Speed: rounds to 1 block/ms
- ETA: 41802252 ÷ 1 = ~11.6 hours 

### Solution
- Created centralized `CalculateETA()` function in common package
- Replaced all 8 duplicate code copies across the codebase

### Testing
Verified accurate ETA calculations during archive node reindexing with
significantly improved time estimates.
2025-09-01 13:47:02 +08:00
..
pruner all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
snapshot all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
access_events.go core/state, core/vm: update stateless gas costs to follow the verkle-gen-7 testnet (#31014) 2025-05-15 20:43:52 +08:00
access_events_test.go core/state, core/vm: update stateless gas costs to follow the verkle-gen-7 testnet (#31014) 2025-05-15 20:43:52 +08:00
access_list.go core/state: improve PrettyPrint function (#32293) 2025-07-30 10:39:03 +08:00
database.go core, miner, trie: add metrics tracking state trie depth (#32388) 2025-08-22 22:09:14 +08:00
database_history.go core, eth, triedb: serve historical states over RPC (#31161) 2025-06-25 16:50:54 +08:00
dump.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
iterator.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
iterator_test.go core/state: state reader abstraction (#29761) 2024-09-05 13:10:47 +03:00
journal.go core/state: fix copy of storageChange (#31874) 2025-05-23 13:10:10 +02:00
metrics.go core/rawdb,state: add preimage miss metric (#31295) 2025-03-07 11:23:19 +01:00
reader.go all: fix problematic function name in comment (#32513) 2025-08-29 08:54:23 +08:00
state_object.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
state_object_test.go build: use golangci-lint (#20295) 2019-11-18 10:49:17 +02:00
state_test.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
statedb.go core, miner, trie: add metrics tracking state trie depth (#32388) 2025-08-22 22:09:14 +08:00
statedb_fuzz_test.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
statedb_hooked.go core/state: add GetStateAndCommittedState (#31585) 2025-07-03 13:19:34 +08:00
statedb_hooked_test.go core/tracing: stringer for gas and nonce change reasons (#31234) 2025-02-28 12:53:56 +01:00
statedb_test.go core, consensus/beacon: defer trie resolution (#31725) 2025-06-25 09:42:11 +08:00
stateupdate.go all: implement state history v2 (#30107) 2025-01-17 02:59:02 +01:00
sync.go core,eth,internal: fix typo (#29024) 2024-02-20 19:42:48 +08:00
sync_test.go triedb/pathdb, eth: use double-buffer mechanism in pathdb (#30464) 2025-06-22 20:40:54 +08:00
transient_storage.go core/state: improve PrettyPrint function (#32293) 2025-07-30 10:39:03 +08:00
trie_prefetcher.go trie, core/state: introduce trie Prefetch for optimizing preload (#32134) 2025-08-20 21:45:27 +08:00
trie_prefetcher_test.go all: implement state history v2 (#30107) 2025-01-17 02:59:02 +01:00