!4469odin/fix-solvency-oscillation → develop1ecb08babd

Regression test for the solvency halt/unhalt oscillation fix

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

2commits
1files
161lines changed
161lines to read
0production lines
3 / 6mutants caught
8test steps

Where the diff is

Read these1 files · 161 lines

x/thorchain/handler_solvency_test.go+161 −0

Tests1 files · 161 lines

x/thorchain/handler_solvency_test.go+161 −0
1insolvent halts at 1002refresh holds solvent at 1013solvent first unhalts at 10243 blocks stay halted5recovery unhalts; manual 1 sticks

4-minute explainer

What changed

The bug it guards

One insolvent and one solvent vault used to flip the chain.

A insolvent → HALTB solvent → openA insolvent → HALTB solvent → open
fix already on develop (86fad7343d); this MR adds the test only

The rule on develop

Insolvent sets halt = block; solvent unhalts only older halts.

halt ≥ block or halt == 1 → returninsolvent: halt = blocksolvent: halt = 0handler_solvency_helpers.go L254-295

Test setup

Two 1000 ETH vaults, 4 nodes; two signers reach consensus.

vault1 = Avault2 = Bwallet 100 → insolventwallet 1000 → solvent2 of 4 signers

Same block holds

A refreshes halt to 101, so B can't unhalt in 101.

100: A → 100101: A → 101101: B → 101

Solvent first unhalts

In block 102 B unhalts before A re-halts; test calls it correct.

102: B → 0 (open)102: A → 102
across blocks only bifrost's all-solvent rule stops this

Steady state, then recovery

Three blocks stay halted; A's solvent report unhalts at 106.

103104105106 open

Manual halt stays

Halt value 1 is neither overwritten nor lifted for two blocks.

  • insolvent keeps 1
  • solvent keeps 1
fails only if both the == 1 and > 1 guards go

What the test catches

Catches refresh and same-block mutants; three single-guard mutants survive.

  • drop refresh → fails L420
  • >= → > → fails L428
  • drop both manual guards → fails L491
survive: drop > 1 only · drop == 1 only · >= → ==

Line by line · every changed logic line, narrated

4:32runtime
10code chapters
100%logic lines narrated (122/122)
5flagged spots
speed

Chapters

What to check

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

Bifrost
The observer each node runs beside THORNode. It sends solvent reports only when every vault on the chain is solvent. how-bifrost-works.md ↗ ethereum.go ↗
Halt refresh
The fix on develop: each insolvent report moves the halt height to the current block, so a solvent report in the same block returns early. handler_solvency_helpers.go ↗
HasMinority
The consensus rule for solvency votes: more than a third of active nodes signing the same report. types.go ↗
Mimir
Node-voted or admin-set runtime values stored on chain, read by key; halts are mimir values. docs/mimir.md ↗
Mutant
A deliberately broken copy of the production code. A good test fails on it (caught); a passing test means the mutant survives.
Solvency check
Bifrost reports each vault's on-chain wallet balance (MsgSolvency); THORNode compares it to the vault record. A wallet short by more than the permitted gap is insolvent. handler_solvency_helpers.go ↗
SolvencyHalt<Chain>Chain
Mimir key the solvency checker writes. 0 is open, 1 is a manual indefinite halt, and a block height halts from that block on. docs/mimir.md ↗ keeper_halt.go ↗
Vault
A threshold-signed (TSS) address set holding a chain's funds. One chain can have several vaults, here vault1 (A) and vault2 (B). docs/bifrost/vault-behaviors.md ↗