Skip to content

test: the evodb reconciliation, on both sides of DIP0003 - #223

Merged
minuszka merged 1 commit into
defcon-project:v22.1.xfrom
minuszka:fix/f135-evodb-reconcile-regression
Sep 9, 2026
Merged

minuszka merged 1 commit into
defcon-project:v22.1.xfrom
minuszka:fix/f135-evodb-reconcile-regression

Conversation

@minuszka

@minuszka minuszka commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.py

The strict criterion, not the easy one. With three masternodes registered and a
quorum mined, the node's evodb directory is removed entirely and the node must

  • come back at the same tip, and
  • rebuild the same state: protx list registered, masternode count,
    quorum list and a protx diff 1 H ladder, 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.py

The branch that is easy to get wrong, and was. Below DIP0003Height an empty
evodb 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 MigrationAlreadyDone is
false, so MigrateDBIfNeeded never reaches its own below-DIP3 branch — the one
that writes the best-block marker — and fails four lines earlier on its
"b_b2 is gone, so a previous migration was interrupted" test. The node then
refuses to start with Error upgrading Evo database even though the
reconciliation 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 BitcoinTestFramework rather than DashTestFramework because the latter
pins dip3params to 2:2, which puts DIP3 out of reach at height 2. Here
regtest's own DIP0003Height (432) applies, so both sides of the boundary are
reachable in one test.

Evidence

Run on the integrated tip ff7ba9e51b, binary
f7a64a9cee401abcb2c56efeb2211f19a60578b3641a549922a1b6258a88ee2b:

on the merged code reconciliation call disabled
feature_evodb_reconcile_below_dip3.py exit 0 exit 1
feature_evodb_reconcile.py exit 0 exit 1

Both 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 for
the 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 under test/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.

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.
@minuszka
minuszka merged commit 25c3966 into defcon-project:v22.1.x Sep 9, 2026
3 checks passed
@minuszka
minuszka deleted the fix/f135-evodb-reconcile-regression branch September 9, 2026 20:02
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 this pull request may close these issues.

1 participant