Repository navigation
Conversation
Two functional tests for the startup reconciliation added in defcon-project#222. Neither existed when that change went in, and the proof lived only in the audit evidence package, so a later change could have silently undone it. feature_evodb_reconcile.py takes the strict criterion: with masternodes registered and a quorum mined, the node's evodb is removed entirely and the node must come back at the same tip AND rebuild the same state -- the masternode list, the quorum list and a diff ladder, compared value for value. The masternodes are what make that comparison mean anything, so the test asserts up front that the reference actually carries them; an empty list equals an empty list, and a reconciliation that built nothing would pass a comparison taken on a bare chain. It also requires that a second clean restart does not replay again, which is what proves the marker was written. feature_evodb_reconcile_below_dip3.py covers the branch that is easy to get wrong. Below DIP0003 an empty evodb is not lagging, it is current, and returning early is not enough: on an empty database MigrationAlreadyDone is false, so the migration gate never reaches its own below-DIP3 branch and fails four lines earlier on its interrupted-migration test. The reconciliation therefore writes the marker itself, and this test fails if that is ever removed. It uses the plain framework because DashTestFramework pins dip3params to 2:2, which puts DIP3 out of reach at height 2. Both were shown to be able to fail: with the reconciliation call disabled and nothing else changed, each fails at node startup with "Error upgrading Evo database" -- the fingerprint of the defect they are about. Not covered here, and stated rather than left to be found: a database of an older marker generation, which must migrate rather than replay. The node writes only the current marker, so a functional test cannot manufacture that state; it was measured on a v22.1.4-generation mainnet datadir in the audit evidence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
Two functional tests for the startup reconciliation added in #222. That change
went in without a regression test — the PR description said so — and the proof
lived only in the audit evidence package. This closes that gap, so a later
change to the load path cannot silently undo it.
feature_evodb_reconcile.pyThe strict criterion, not the easy one. With three masternodes registered and a
quorum mined, the node's
evodbdirectory is removed entirely and the node mustprotx list registered,masternode count,quorum listand aprotx diff 1 Hladder, compared value for value.The masternodes are what make that comparison mean anything. An empty list
equals an empty list, so a reconciliation that built nothing at all would pass
a comparison taken on a bare chain — which is exactly how an earlier hand-run of
this scenario passed on a fix that rebuilt nothing. The test therefore asserts up
front that the reference actually carries masternodes, quorums, and at least one
ladder height with a non-empty list, and fails there rather than at the end if it
does not.
It also requires that a second clean restart does not replay again. That is
what proves the marker was written, rather than the node merely surviving once.
feature_evodb_reconcile_below_dip3.pyThe branch that is easy to get wrong, and was. Below
DIP0003Heightan emptyevodb is not lagging — it is current, because there is no deterministic
masternode list yet and empty is the correct content.
Returning early is not enough. On an empty database
MigrationAlreadyDoneisfalse, so
MigrateDBIfNeedednever reaches its own below-DIP3 branch — the onethat writes the best-block marker — and fails four lines earlier on its
"
b_b2is gone, so a previous migration was interrupted" test. The node thenrefuses to start with
Error upgrading Evo databaseeven though thereconciliation correctly decided there was nothing to do. So the reconciliation
writes the marker itself, and this test fails if that is ever removed: the first
arm would still pass and the second would not.
It uses
BitcoinTestFrameworkrather thanDashTestFrameworkbecause the latterpins
dip3paramsto2:2, which puts DIP3 out of reach at height 2. Hereregtest's own
DIP0003Height(432) applies, so both sides of the boundary arereachable in one test.
Evidence
Run on the integrated tip
ff7ba9e51b, binaryf7a64a9cee401abcb2c56efeb2211f19a60578b3641a549922a1b6258a88ee2b:feature_evodb_reconcile_below_dip3.pyfeature_evodb_reconcile.pyBoth failures are at node startup, with
dashd exited with status 1 during initialization. : Error upgrading Evo database.— the fingerprint of the defect the tests are about, so they fail forthe right reason and not incidentally. Nothing but the reconciliation call was
changed for that control, and the binary came back bit-identical afterwards.
Scope
src/is untouched: three files, +241, all undertest/functional/.One case is deliberately not covered here, stated rather than left to be
discovered: a database of an older marker generation, which must migrate
rather than replay. The node writes only the current marker as a compile-time
constant, so a functional test cannot manufacture that state. It was measured
instead on a v22.1.4-generation mainnet datadir — the state every mainnet
masternode is in — where the fixed node migrates in about six seconds, does not
replay, and produces no
bad-qc-not-allowed.