Skip to content

UTB parity 3/4: pinned history and complete bundles (weighted quorum, overlap, 256 to 4) - #3

Merged
ristik merged 1 commit into
mainfrom
dev3/java-3-history
Nov 8, 2026
Merged

ristik merged 1 commit into
mainfrom
dev3/java-3-history

Conversation

@ristik

@ristik ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Owner §51, plan PR 3 (stacked on #2). Mirrors JS TrustBaseHistory/TrustBaseBundle/TrustBaseResponseWire/TrustBaseError.ts and Rust trust_base_history.rs.

  • TrustBaseHistory: create(pin), append (-> APPENDED/ALREADY_HELD; first entry must be the pinned genesis; successors verified against the tip; a held epoch with the same id is idempotent but its witnesses are still verified; a different id is TrustBaseConflictException with ids, unauthenticated; gap, before-genesis), entryForEpoch, epochEndRound, toBundle, fromBundle. Serialised under a lock with no I/O; snapshots are immutable lists; epochs/rounds compare unsigned (tested across 2^63).
  • TrustBaseBundle + TrustBaseBundleLimits: tag-39015 complete bundle decode (OK status, no cursor, from genesis, consecutive, linked, end id and effective end, network) and canonical encode; TrustBaseResponseWire (public) is the shared GetTrustBase envelope that the page decoder of the next PRs reuses; the entry count is bounded from the array header.
  • Typed errors: TrustBaseBundleException, TrustBaseNetworkException, TrustBaseBeforeGenesisException (chain subclasses), TrustBaseGapException, TrustBaseConflictException(+TrustBaseConflictDetails).
  • Tests: all 11 shared history vectors, 4 weighted-quorum vectors, 2 bundle vectors; rules one at a time; weights 5,1,1,1; overlap (171 of 256 exact, 170 refused, a second 171 set is ALREADY_HELD); 256 predecessor signatures handing over to 4 members; the 81ee667 max-entry bundle from its pin; bundle refusals; concurrent appenders.
  • Mutants: 19 killed (pin compare/length/copy, gap, conflict id, held-witness recheck, tip verify, before-genesis, unsigned epoch compare, bundle status/cursor/genesis-first/link/end/network/byte and entry budgets, header count bound, status range).

Evidence: ./gradlew test checkstyleMain animalsnifferMain under Temurin 11 green. Not merged by me.

…dles; weighted quorum, overlap and 256-to-4 tests

TrustBaseHistory (create(pin), append -> APPENDED/ALREADY_HELD, entryForEpoch, epochEndRound, toBundle, fromBundle), TrustBaseBundle/Limits, TrustBaseResponseWire (public, shared with the page decoder), typed errors (Bundle, Network, BeforeGenesis, Gap, Conflict with details). Appends are serialised under a lock without I/O; epochs and rounds compare as unsigned. Shared bft-go-base history, weightedQuorum and bundles vectors.
@ristik

ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

java#3 at de67e4e: no blockers. APPROVE once CI is green. TrustBaseHistory.append covers the cases:

  • a pinned genesis (verifyGenesis, then a pin comparison), an epoch before the genesis, a gap, and a successor checked with verifySuccessor against the tip;
  • for a held epoch: the same identity is ALREADY_HELD (with the witness verified against the predecessor); a different identity is an unauthenticated TrustBaseConflictException, which the session classifies by verifying against the predecessor, the same outcome as Rust's authenticated-only Conflict.

The bundle decode refuses a non-OK status, a continuation cursor, a null end entry ID, a partial range and a mismatched end ID, matching rs#17's tightened from_bundle. Nit: re-offering the genesis with the same identity returns ALREADY_HELD without verifyGenesis (Rust re-validates). It's harmless, since nothing is stored, but it's one line to align.

@ristik ristik closed this Nov 8, 2026
@ristik ristik reopened this Nov 8, 2026
@ristik

ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

APPROVE at de67e4e, for the owner's list. CI build (which includes javadoc) is green at this head. My review is above.

@ristik
ristik changed the base branch from dev3/java-2-entry to main November 8, 2026 03:02
@ristik
ristik merged commit f9bf2b0 into main Nov 8, 2026
1 check passed
@ristik
ristik deleted the dev3/java-3-history branch November 14, 2026 17:11
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