go-ethereum/common
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
..
bitutil
compiler
fdlimit
hexutil common, common/hexutil: use reflect.TypeFor (#32321) 2025-08-07 14:30:03 +02:00
lru core/rawdb: integrate eradb backend for RPC (#31604) 2025-06-03 10:47:38 +02:00
math all: use fmt.Appendf instead of fmt.Sprintf where possible (#31301) 2025-03-25 14:53:02 +01:00
mclock
prque common/prque: fix godoc comments (#29460) 2024-04-06 11:09:30 +02:00
big.go
bytes.go
bytes_test.go
debug.go
eta.go all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
eta_test.go all: improve ETA calculation across all progress indicators (#32521) 2025-09-01 13:47:02 +08:00
format.go
path.go build: get rid of ci.go -> common direct dependency (#30637) 2024-10-20 14:54:06 +03:00
range.go eth/filters: implement log filter using new log index (#31080) 2025-03-17 18:59:04 +01:00
range_test.go eth/filters: implement log filter using new log index (#31080) 2025-03-17 18:59:04 +01:00
size.go
size_test.go
test_utils.go
types.go common, common/hexutil: use reflect.TypeFor (#32321) 2025-08-07 14:30:03 +02:00
types_test.go common: using ParseUint instead of ParseInt (#30020) 2024-06-19 11:06:52 +02:00