Repository navigation
Conversation
…art caches BlockChain keeps the consensus reward settings (special transaction order 37) so that they survive restarts through the quick-start caches. Three defects affect a restarted node: - BlockChain::setMiningOn() wrote stakingOn_ and setStakingOn() wrote miningOn_, so after a restart from caches Consensus::stakingOn got the mining value and Consensus::miningOn the staking value - the quick-start path emitted successfullQuickStartEvent(..., miningOn_, miningOn_, ...), so Node::onSuccessQS set stakingOn from miningOn - blockRewardIntegral_/Fraction_, miningCoefficientIntegral_/Fraction_, stakingOn_, miningOn_ and TimeMinStage1_ had no initializer; they are saved into every checkpoint and read back on the --set-bc-top path, possibly before anything assigned them. They now have the defaults of BlockChain_Serializer::clear(): zero amounts, both flags off, TimeMinStage1 = 500 stakingOn and miningOn drive the block reward computed by trusted nodes (SolverCore::setBlockReward), so a restarted node computed other rewards than a node that kept running whenever the two flags differ. With both flags equal (mainnet today) nothing changes, and existing caches keep their meaning. WalletsCache::Updater::fundConfidantsWalletsWitnReward also logs a warning (one line per 10,000) when it drops a confidant reward above the local blockReward, so that a node whose settings differ from the network's shows it. Logging only. Tests: tests/csnode/blockchain_settings_tests.cpp. Same change in the community fork: #8 and #12. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
BlockChainkeeps the consensus reward settings set by special transaction order 37 (block reward, mining coefficient, stakingOn, miningOn, TimeMinStage1) so that they survive restarts through the quick-start caches. A restarted node can come back with other settings than a node that kept running:BlockChain::setMiningOn()writesstakingOn_andsetStakingOn()writesminingOn_, so after a restart from cachesConsensus::stakingOngets the mining value andConsensus::miningOnthe staking value;successfullQuickStartEvent(..., miningOn_, miningOn_, ...), soNode::onSuccessQSsets stakingOn from miningOn;--set-bc-toppath, possibly before anything assigned them.stakingOn and miningOn drive the block reward computed by trusted nodes (
SolverCore::setBlockReward). With both flags on, as on mainnet today, the first two defects have no effect; they would as soon as order 37 changes only one flag.What changes
csnode/src/blockchain.cpp: the two setters write their own member; the quick-start event passesstakingOn_.csnode/include/csnode/blockchain.hpp: the members get the defaults ofBlockChain_Serializer::clear()(zero amounts, both flags off, TimeMinStage1 = 500).csnode/src/walletscache.cpp:fundConfidantsWalletsWitnRewardlogs a warning (one line per 10,000) when it drops a confidant reward above the local blockReward, so a node whose settings differ from the network's shows it. Logging only.Effect on the network
No change while stakingOn and miningOn are equal, and existing caches keep their meaning. If order 37 ever sets them to different values, restarted nodes with and without this change would compute different rewards, so it should be deployed by all nodes before such an order.
Tests
tests/csnode/blockchain_settings_tests.cpp(new): the setters are independent; the members have defined defaults. Built and run on 4a95aaa (GCC 13).Same change in the community fork: CreditsCommunity#8 and #12, running on mainnet community nodes.