Skip to content

csnode: bootstrap tables of 9 to 25 confidants are weighed (same choice as now up to 8) - #78

Open
EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/bootstrap-weight
Open

EnzinoBB wants to merge 1 commit into
CREDITSCOM:masterfrom
CreditsCommunity:official/bootstrap-weight

Conversation

@EnzinoBB

@EnzinoBB EnzinoBB commented Nov 1, 2026

Copy link
Copy Markdown

Why this PR

Node::calculateBootStrapWeight returns a uint8_t and returns 0 for any table of more than 8 confidants, and getBootstrapTable drops 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 (new csnode/include/csnode/bootstrapweight.hpp) replaces the body of Node::calculateBootStrapWeight, now a const member returning cs::BootstrapWeight (32 bits). bootStrapWeight_ uses the same type.
  • Up to 8 keys it gives exactly the current values on x86-64 (each confidant matched in the sorted order of the initial confidants adds 2^(n-1-k)), so nodes with and without this change pick the same table.
  • From 9 to 25 keys (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.
  • A table signed with the blockchain key weighs kSignedBootstrapWeight (the maximum), above every unsigned table.
  • getBootstrapTable logs 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.

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

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