Skip to content

csnode: an uncertain block replaced in place must have the same trusted mask - #88

Open
EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/uncertain-block-mask
Open

EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/uncertain-block-mask

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented Nov 1, 2026

Copy link
Copy Markdown

Why this PR

When a node's own last block turns out to be "uncertain" (its hash is not the one the network signed), BlockChain::storeBlock() fetches the network's block. If testContentEqual() says the two have the same content, the node swaps it in place without touching the wallet caches. testContentEqual() ignores the trusted mask (numberTrusted/realTrusted), which decides which confidants receive the block reward and the fees (WalletsCache::Updater::fundConfidantsWalletsWitnReward, fundConfidantsWalletsWithFee). A trusted node that built the block with another mask therefore keeps the rewards and fees credited under its own mask, while the other nodes credit them under the network's: a permanent, silent difference in the balances of trusted nodes.

What changes

  • csnode/src/blockchain.cpp: the content compared by testContentEqual() includes the trusted mask. When it differs, storeBlock takes its existing "different content" branch: removeLastBlock() reverts the own block from the caches with its own mask, and the network's block is applied through the normal sync path.
  • csnode/include/csnode/blockchain.hpp: testContentEqual() is public, for the unit test.

Effect on the network

No new rule and nothing on the wire: the node applies the block the network signed, with the network's mask, as every other node does; its balances stop drifting from theirs.

Tests

tests/csnode/blockchain_content_tests.cpp (new): BlockChainContent.ContentEqualRequiresSameTrustedMask (failed before). Built and run on 4a95aaa (GCC 13).

Same change in the community fork: CreditsCommunity#9, running on mainnet community nodes.

… differs

When a node's own last block turns out to be "uncertain" (its hash is not the one the network
signed), BlockChain::storeBlock() fetches the network's block. If testContentEqual() says the two
have the same content, the node swaps it in place (deferredBlock_ = pool) without touching the
wallet caches.

testContentEqual() ignored the trusted mask (numberTrusted/realTrusted), which decides which
confidants receive the block reward and the fees (WalletsCache::Updater:
fundConfidantsWalletsWitnReward, fundConfidantsWalletsWithFee). A trusted node that built block N
with another mask therefore kept the rewards and fees credited under its own mask, while every
other node credits them under the network's mask: a permanent, silent balance difference on the
wallets of trusted nodes.

The trusted mask is now part of the compared content. When it differs, storeBlock takes the
existing "different content" branch: removeLastBlock() reverts the own block from the caches with
its own mask, and the network's block is applied through the normal sync path.

testContentEqual() is public so that it can be unit-tested
(tests/csnode/blockchain_content_tests.cpp).

Same change in the community fork: #9.

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

EnzinoBB commented Nov 1, 2026

Copy link
Copy Markdown
Author

#80 also edits csnode/include/csnode/blockchain.hpp: a small conflict is possible when both are merged.

This branch has not been deployed

No deployments
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