Test deterministic consensus replay and upgrade

Consensus changes need repeatable evidence across replay, export/restart, divergence detection, and the 18-to-19 upgrade path. This change adds a deterministic app test suite (app/consensus_determinism_test.go), a bounded runner script, a standalone CI job, and documentation.

  • Simulation scope: TestConsensusDeterminismSimulationScope records which modules the SDK simulation manager covers (auth, bank, denom, params, scheduler, wasm). It shows that THORChain's AppModule registers no weighted operations, so TestAppStateDeterminism never exercises THORChain state.
  • Replay: TestConsensusDeterminismReplay imports a sanitized, fixed-time THORChain genesis fixture into independent app instances, eight times per seed. The fixture has four funded pools (BTC/ETH/DOGE/LTC), observed inbounds, a swap queue item, a scheduled outbound, network fees and a nonzero Reserve. Each run finalizes and commits a block and compares the app hash and the exported THORChain state. Every second run reverses pool order so that writes depending on map order show up as mismatches.
  • Divergence detection: TestConsensusDeterminismDetectsDivergence checks that changing a pool by one unit produces a different committed app hash.
  • Export/restart: TestConsensusDeterminismRestartAndExport exports state, reopens the committed DB and imports the export into a fresh app. It checks the THORChain records, the Reserve balance and the BTC pool at import. It then commits another block on two independent imports and compares their hashes and exported state.
  • 18→19 migration: TestConsensusDeterminismMigration18To19 seeds two legacy owner-keyed affiliate collector records (one owner with a THORName, one without) and funds the collector module to match. It runs the 3.20.0 upgrade handler starting from module version 18 and checks that the version reaches the current ConsensusVersion(). After the commit it checks:
    • the active validator version is 3.20.0;
    • Reserve and BTC pool balances are unchanged;
    • the named collector holds the first balance and the second owner received its RUNE;
    • the legacy keys are gone;
    • two independent runs produce the same hash and state.
  • Runner and CI: scripts/test-consensus-determinism.sh pins Go 1.26.9, uses the caller's GOCACHE (falling back to a /tmp cache when unset), takes the shared build lock and runs go test -p 2 -timeout 15m ./app -run '^TestConsensusDeterminism'. The new consensus-determinism job in the long-test stage runs this script on the small runner with a 25m timeout and saves the log as an artifact.
  • Docs: docs/test-consensus-determinism.md (linked from SUMMARY.md) describes the method and its limits. The fixture does not submit signed user transactions, so it does not prove swap execution or outbound signing.

Validation: The integrated consensus-determinism CI job passed; the local runner tests also passed (five tests, no skips). This topic is also included in draft !5181 (closed). This MR will run its own CI against develop; review and merge coordination should avoid landing the same change twice.

Edited by Huginn Ai

Merge request reports

Loading
Loading