Repository navigation
Conversation
… 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>
Author
|
#80 also edits |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. IftestContentEqual()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 bytestContentEqual()includes the trusted mask. When it differs,storeBlocktakes 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.