Repository navigation
Conversation
getStateReply accepted a contract state from any signed peer, and net_update_contract_state cached it whenever no new_state with the same ref was found in the following MaxRoundsCancelContract blocks. A state with a future ref was cached too, and then every real update looked outdated, so a single message froze the contract on this node. Remember the contracts this node asked the confidants about (the round of the last request, kept for 1000 rounds because several confidants answer) and ignore states for any other contract, or with a ref later than the current round. A state whose new_state is not stored yet is still accepted: that is how a lagging node catches up, and refusing it would leave it without the state. 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
getStateReplyaccepts a contract state from any signed peer, andSmartContracts::net_update_contract_statecaches it whenever nonew_statewith the same reference is found in the followingMaxRoundsCancelContractblocks. A state with a reference in the future is cached too, and then every real update of that contract looks outdated: the node can keep a contract state that is not the one the chain declares. Found while auditing the node and reported to the Credits team.What changes
solver/src/smartcontracts.cpp,solver/include/solver/smartcontracts.hpp: the node remembers the contracts it asked the confidants about (the round of the last request, kept for 1000 rounds because several confidants answer) and ignores states of any other contract, or with a reference later than the current round. A state whosenew_stateis not stored yet is still accepted, as a lagging node needs it.Effect on the network
None on the wire: requests and replies are unchanged; a node only refuses states it did not ask for.
Note: the PR "fetch stale contract states from the confidants, verified against the chain" replaces this bookkeeping with its own request tracking; if that one is taken, this one is not needed.
Tests
Built and run on 4a95aaa (GCC 13).
Same change in the community fork: CreditsCommunity#32, running on mainnet community nodes.