Make PruneExecutionDB not depend on consensusDB#4217
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4217 +/- ##
==========================================
- Coverage 34.96% 33.04% -1.92%
==========================================
Files 483 484 +1
Lines 57556 57664 +108
==========================================
- Hits 20125 19057 -1068
- Misses 33868 35290 +1422
+ Partials 3563 3317 -246 |
❌ 6 Tests Failed:
View the top 3 failed tests by shortest run time
📣 Thoughts on this report? Let Codecov know! | Powered by Codecov |
Refactor PruneExecutionDB, more specifically findImportantRoots so it does not depend on consensusDB, but only on executionDB Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
a59d76b to
4965575
Compare
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
diegoximenes
left a comment
There was a problem hiding this comment.
Almost there 🙂, just some test nitpicks
| // Create a safety buffer (+/- 2 blocks) around the expected prune point. | ||
| // Due to synchronization latency, the second node's state may vary slightly, | ||
| // making the exact availability of these boundary blocks non-deterministic. | ||
| if i >= checkUntilBlock-2 && i <= checkUntilBlock+2 { |
There was a problem hiding this comment.
I don't fully understand this, but it is only a test so it is OK to have it here.
There was a problem hiding this comment.
yeah I'm fully 100% sure what causes these fluctuations but that's my best guess where sometimes blocks in the range [balanceShouldntExistUntilBlock-1, balanceShouldntExistUntilBlock+1] might or might not have been persisted to trieDB, so to be safe I did a +/-2 window.
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
Signed-off-by: Igor Braga <5835477+bragaigor@users.noreply.github.com>
|
|
||
| validatorDB := rawdb.NewTable(consensusDB, storage.BlockValidatorPrefix) | ||
| lastValidated, err := staker.ReadLastValidatedInfo(validatorDB) | ||
| data, err := executionDB.Get(gethexec.ValidatedBlockHashKey) |
There was a problem hiding this comment.
wrap the error so the user will understand that "validator" prune mode cannot work for a node that has not been used as validator
There was a problem hiding this comment.
(old behavior wouldn've been to just not try saving another block but I think it's better as you wrote it, especially since nodes that have a database before the change don't have that key in db even if they do work as validators)
Refactor
PruneExecutionDB, more specificallyfindImportantRootsso it does not depend onconsensusDB, but only onexecutionDB. The former PruneExecutionDB used to depend on consensusDB for 2 things:Prunemode"validator"staker.ReadLastValidatedInfoPrunemode"minimal"For the replacements we use:
executionDBto store such validated block using keyLastValidatedBlockHashKeyexecutionDB.Put(validatedBlockHashKey, ...toSetFinalityDatato store latest validated blockrawdb.ReadFinalizedBlockHashandrawdb.ReadHeaderNumberto get finalized block number and hashCloses NIT-4266