Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pruning proceeds ahead of last sync blocks #115

Closed
AlexeyAkhunov opened this issue Oct 16, 2019 · 0 comments · Fixed by #139
Closed

Pruning proceeds ahead of last sync blocks #115

AlexeyAkhunov opened this issue Oct 16, 2019 · 0 comments · Fixed by #139
Assignees

Comments

@AlexeyAkhunov
Copy link
Contributor

When syncing to Ropsten, where it takes a long time for sync to start, I observed that pruning has started ahead of sync:

INFO [10-16|10:46:00.988] Initialising Ethereum protocol           versions="[63 62]" network=3
INFO [10-16|10:46:01.010] Loaded most recent local header          number=0 hash=419410…ca4a2d td=1048576 age=50y6mo5d
INFO [10-16|10:46:01.011] Loaded most recent local full block      number=0 hash=419410…ca4a2d td=1048576 age=50y6mo5d
INFO [10-16|10:46:01.011] Loaded most recent local fast block      number=0 hash=419410…ca4a2d td=1048576 age=50y6mo5d
INFO [10-16|10:46:01.011] Pruner started 
INFO [10-16|10:46:01.011] Loaded local transaction journal         transactions=0 dropped=0
INFO [10-16|10:46:01.012] Regenerated local transaction journal    transactions=0 accounts=0
INFO [10-16|10:46:01.012] Initialising Firehose protocol           versions=[1]
INFO [10-16|10:46:01.088] New local node record                    seq=23 id=a3c8dc9a49dedf3b ip=127.0.0.1 udp=30303 tcp=30303
INFO [10-16|10:46:01.088] Started P2P networking                   self=enode://d3228a32673a4c6ec8556a6796bf3a4ea94d288aed9db43a98d7ba742abd296624b2c7f02bd3ad88250ce4b74a777dfdb30fef0a4cad7f484b8c748221f6c626@127.0.0.1:30303
INFO [10-16|10:46:01.091] IPC endpoint opened                      url=/Users/alexeyakhunov/Library/Ethereum/testnet/geth.ipc
INFO [10-16|10:51:01.036] Save last pruned block num               num=3000
INFO [10-16|10:56:01.028] Save last pruned block num               num=6000
INFO [10-16|11:01:01.016] Save last pruned block num               num=9000
INFO [10-16|11:06:01.007] Save last pruned block num               num=12000

The reason is underflow when computing diff in this code:

func calculateNumOfPrunedBlocks(curentBlock, lastPrunedBlock uint64, blocksBeforePruning uint64, blocksBatch uint64) (uint64, uint64, bool) {
	diff := curentBlock - lastPrunedBlock - blocksBeforePruning
	switch {
	case diff >= blocksBatch:
		return lastPrunedBlock, lastPrunedBlock + blocksBatch, true
	case diff > 0 && diff < blocksBatch:
		return lastPrunedBlock, lastPrunedBlock + diff, true
	default:
		return lastPrunedBlock, lastPrunedBlock, false
	}
}

Also there is a typo in the word curentBlock :)

BlinkyStitt pushed a commit to llamanodes/erigon that referenced this issue Jun 8, 2023
cffls pushed a commit to cffls/erigon that referenced this issue Feb 14, 2024
taratorio pushed a commit that referenced this issue Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants