Skip to content

Apply known state corrections proven by stored block rewards (7hWM6wvs, one contract-state fee) - #184

Merged
EnzinoBB merged 2 commits into
masterfrom
fix/known-state-correction
Nov 10, 2026
Merged

EnzinoBB merged 2 commits into
masterfrom
fix/known-state-correction

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Community nodes are the stage-3 minority on mainnet (failed=block+round, trusted hash agreed) in every round where 7hWM6wvsojdPy3A2pQjqWKtfJM4hQRCWe3YC2hB2WzbE is a confidant, which is half of the rounds.

Recomputing SolverCore::setBlockReward exactly (same csdb::Amount operations) from our node's wallet data via the API:

  • every recent block without 7hWM6wvs reproduces the stored reward split bit for bit (151/151, then 300/300 with the fix);
  • every block with it differs only in 7hWM6wvs's share (and the last-paid remainder);
  • adding exactly 0.008740234375 CS (one contract-state fee) to 7hWM6wvs's balance makes all 149 such blocks match bit for bit; 0.008740234374 or 0.008740234376 do not.

The component that differs is the balance (the 500,000 CS time delegation, coeff Anni, and the staking rules are the same). Origin (traced): dice payout 176760929.2 in block 176,760,929 (2026-06-05) pays MooNRor8… the win of its call 176760925.1. The lineage of the published pruned snapshots replayed that contract state with the official rule (before #94); the replay failed, the stale ref_execute still pointed to the previous successful call, by 7hWM6wvs, and the payout's contract-state fee was charged to 7hWM6wvs. The majority that executed the contract did not. This is the same divergence that stopped our node at 176,776,317 (the transfer exceeded our balance by exactly one fee). Mainnet nodes themselves disagree (7 vs 13 in October), and the other always-gray-listed confidants (M9kkJAc7, Gc4X25fU, 74xsody1, EVnmYugp, CGHoC52e, 6ZW39KmR) are excluded in 100 % (94 % for 6ZW39KmR) of the rounds where 7hWM6wvs is a co-confidant and in none of the others: they hold the same state (synced from scratch with the official rule). GteSXezK is excluded in every round regardless.

What

csnode/statecorrection: a table of known state differences (one entry: 7hWM6wvs, +0.008740234375 CS, mainnet uuid only, from block 176,760,929; entries can carry counterpart adjustments applied in the same step). WalletsCache::Updater::loadNextBlock checks a correction only at a block where the wallet is a trusted confidant: it recomputes the reward split from this node's stakes and applies the delta only if the stored split (signed by the majority) differs from the one this node's stakes give and is reproduced exactly with the delta. So:

  • a node whose state is already right never applies it;
  • an applied correction is never applied twice (the next block matches without it);
  • a block neither value explains is only logged (rate-limited warning, counted per entry);
  • an entry applies only on its chain (BlockChain::uuid() == mainnet, also known to nodes started from a snapshot; so never on the test network or private networks) and only from its fromSequence;
  • counterpart adjustments: if a counterpart balance is below its adjustment, nothing is applied and a warning is logged (no balance becomes negative);
  • blockRewardSplit takes stakingOn as setBlockReward does (oneMiningPart = 0 when off); with staking off the split does not depend on the stakes, so the decision proves nothing. Below StartingDPOS the stored split sums to 0 and nothing is checked.

The decision is in decideKnownStateCorrection (wallet state through an injectable lookup); applyKnownStateCorrections reads the wallets, calls it and applies the entry.

BlockChain::getStakingCoefficient becomes static so the stake can be computed outside the solver with the same operations; the solver is untouched.

Classification: option (b), a one-time state correction, verified by the chain rather than tied to a block number. It changes no consensus rule and no official behaviour; it moves a wrong node to the value the majority signs. Option (a) does not apply (no fork code path produces the difference today; #94 charges the fee as the majority does). Option (c), a corrected snapshot, follows from this fix: the next snapshot built from a corrected node carries the right value, and nodes that restore older snapshots correct themselves at their first 7hWM6wvs block.

No counterpart. MooNRor8… (the payout's real payer) was expected to be one fee too high in our state, and a paired −0.008740234375 was planned. A read-only check of the public API (WalletDataGet, same block 187,731,527, 2026-11-10) contradicts it: 8 majority nodes and 3 minority nodes all report MooNRor8… = 900.821476562547572367, while 7hWM6wvs… is exactly one fee higher on the majority (53538.950025036183020160 vs 53538.941284801808020160). The emitted fee is already part of MooNRor8…'s call fee on every lineage, so adjusting it would create a difference. The counterpart mechanism stays (tested with a test-only entry) but the mainnet entry has none.

Side observation from the same check: AL3dpJg3… differs among majority nodes themselves (+1 fee on 2 of them, +5 fees on 6, vs. the minority), so the majority's states are not uniform for non-confidant dice players either. Not addressed here.

Rounds where the trusted majority is the uncorrected group may still put a corrected node in the minority.

Tests

  • nodetests: StateCorrection tests on two real mainnet blocks (187722654 without the wallet, 187722656 with it) with the confidants' wallet state as our node holds it, plus StateCorrectionTrigger tests of the decision with injected state: fires once and applies both adjustments (test entry with a counterpart), not on a correct state, not again on the next proving block, not below fromSequence, not on testnet/private/unknown uuid, not with staking off, the counterpart-balance guard (one unit below the fee, zero, exactly the fee), an unexplained difference, and the mainnet table changing only 7hWM6wvs. A full WalletsCache test was too heavy (needs a BlockChain and its databases), so the extracted decision is tested instead. Full ctest passes.
  • (first commit) Copy of the mainnet pruned node's data (credits-pruned-c3, read-only, copied), this build, Docker internal network (no route out): quick start from qs/187700000, the correction fired once at block 187,700,001 (balance of 7hWM6wvs… += 0.008740234375), no "does not explain" warning, replay to 187,722,885 with no error; afterwards the recomputation against this node's API matches 300/300 stored blocks with no adjustment.
  • Testnet workflow run on this branch: see the checks (the table never triggers there; it checks for regressions).

🤖 Generated with Claude Code

EnzinoBB and others added 2 commits November 10, 2026 17:37
The lineage of the published pruned snapshots synced the dice-contract
blocks of October 2026 with the official replay rule, so it holds one
contract-state fee (0.008740234375 CS) less for 7hWM6wvs... than the
majority that executed the contract. Being a confidant in half of the
rounds, every reward split a community node signs for it differs from
the majority's by that fee and the node ends up in the stage-3 minority
(stage3 "failed=block+round, trusted hash agreed").

Recomputing SolverCore::setBlockReward from the node's wallet data
reproduces the stored reward split bit for bit for every recent block
without that wallet, and for every block with it only once the fee is
added to its balance (40,000 blocks around 187,722,000; no other value
does). The other always-failing confidants fail exactly in the rounds
where 7hWM6wvs... is a co-confidant, so they carry the same state.

csnode/statecorrection keeps a table of such known differences. A
correction is applied once, at the first block that proves it: the
wallet is a trusted confidant, the stored split (signed by the majority)
differs from the one this node's stakes give, and is reproduced exactly
with the delta applied. A node whose state is right never applies it,
an applied correction is never applied twice, and a block neither value
explains is only logged. getStakingCoefficient becomes static so the
stake can be computed outside the solver with the same operations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…upport

The origin of the 7hWM6wvs... difference is the dice payout 176760929.2
(block 176,760,929, 2026-06-05): a failed replay with a stale ref_execute
charged its contract-state fee to 7hWM6wvs..., the previous caller.

- KnownStateCorrection gets the chain uuid it applies to (mainnet only,
  so never on the test network or private networks; BlockChain::uuid() is
  also known to nodes started from a snapshot), a fromSequence (176,760,929)
  and a list of counterpart adjustments applied in the same step. If a
  counterpart balance is below its adjustment nothing is applied and a
  warning is logged.
- The mainnet entry has no counterpart. MooNRor8... was the expected one,
  but 8 majority and 3 minority nodes report the same MooNRor8... balance
  at block 187,731,527 while 7hWM6wvs... is exactly one fee apart, so an
  adjustment there would create a difference.
- blockRewardSplit takes stakingOn as SolverCore::setBlockReward does; with
  staking off the split does not depend on the stakes and proves nothing.
- The decision is extracted into decideKnownStateCorrection with the wallet
  state read through a lookup, and tested on the stored mainnet blocks:
  fires once and applies both adjustments (test table with a counterpart),
  not on a correct state, not again on the next proving block, not below
  fromSequence, not on other networks, the counterpart guard.
- The rate-limited warning counter is per entry (WalletsCache member).
- docs/differences.md: origin, the MooNRor8... check, and that rounds whose
  trusted majority is the uncorrected group may still put a corrected node
  in the minority.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EnzinoBB
EnzinoBB merged commit 800d432 into master Nov 10, 2026
4 checks passed
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