Repository navigation
Conversation
Node::calculateBootStrapWeight could only weigh tables of up to 8 confidants, so a network of 9 or more initial confidants never bootstrapped (testnet, 9 nodes: sequence 0 for 45 min). cs::bootstrapWeight (csnode/bootstrapweight.hpp) replaces it: up to 8 keys it gives exactly the official values on x86-64, so community and official nodes choose the same table; from 9 to 25 keys (MaxTrustedNodes) it weighs well-formed tables of initial confidants, a larger one above a smaller one. 32-bit weight, no undefined behaviour in the loop, signed tables above unsigned ones. "Bootstrap on" logs the table's size and weight, and a table that is not taken is logged. Unit tests compare it with the official loop on every table of up to 8 keys. 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
Node::calculateBootStrapWeightreturns auint8_tand returns 0 for any table of more than 8 confidants, andgetBootstrapTabledrops a table that does not weigh more than the last one taken. A network that starts with 9 or more initial confidants therefore never takes a bootstrap round table and never starts (on a 9-node test network: sequence 0 after 45 minutes). The same limit applies when a stalled network of more than 8 initial confidants bootstraps again. Reported privately to the Credits team (problem 1 of our report).What changes
cs::bootstrapWeight(newcsnode/include/csnode/bootstrapweight.hpp) replaces the body ofNode::calculateBootStrapWeight, now aconstmember returningcs::BootstrapWeight(32 bits).bootStrapWeight_uses the same type.Consensus::MaxTrustedNodes) it weighs only a well-formed table (initial confidants in their order, each once), with 2^n on top so a larger table beats a smaller one; any other table of 9 or more keys weighs 0 and is dropped as today.kSignedBootstrapWeight(the maximum), above every unsigned table.getBootstrapTablelogs a table that is not taken and the size and weight of the table that starts a bootstrap.Effect on the network
For unsigned tables of up to 8 confidants the result is the same as today, so mixed networks agree on which table to take. The one difference up to 8 keys: today a signed table weighs 255, the same as a full unsigned table of 8, and is then not taken after it; with this change a signed table is always taken. Networks of 9 to 25 initial confidants can now bootstrap. Nothing changes on the wire.
Tests
tests/csnode/bootstrapweight_tests.cpp(new) compares the new function with the current loop on every table of up to 8 keys, and checks the 9-25 key rules. Built and run on 4a95aaa (GCC 13).Same change in the community fork: CreditsCommunity#70, running on mainnet community nodes.