Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/crypto-config/source/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ describe<{
);
});

const withRoundValidators = (value: number) => ({
...cryptoJson,
milestones: cryptoJson.milestones.map((milestone, index) =>
index === 1 ? { ...milestone, roundValidators: value } : milestone,
),
});

it("should reject a milestone with roundValidators above the 64 wire-format cap", ({ configManager }) => {
assert.throws(() => configManager.setConfig(withRoundValidators(65)));
});

it("should accept a milestone with roundValidators at the 64 cap", ({ configManager }) => {
assert.not.throws(() => configManager.setConfig(withRoundValidators(64)));
});

it("should throw on set before config is initialized", () => {
const fresh = new Configuration();

Expand Down
5 changes: 4 additions & 1 deletion packages/crypto-config/source/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ const milestone: AnySchemaObject = {
height: { minimum: 0, type: "integer" },
p2p: milestoneP2p,
reward: { type: "string" },
roundValidators: { minimum: 0, type: "integer" },
// Hard ceiling: the consensus wire format packs the signer bitmap into a fixed uint64
// (serializer.ts / validatorSetPack), so index 64 (the 65th validator) overflows on
// serialize. Guard it here until the wire format is redesigned as a variable bitset.
roundValidators: { maximum: 64, minimum: 0, type: "integer" },
satoshi: milestoneSatoshi,
snapshot: milestoneSnapshot,
timeouts: milestoneTimeouts,
Expand Down
Loading