Skip to content

UTB parity 4/4: verification by trust-base history (seals by epoch, weighted quorum, typed no-entry, 256-signature bound); V1 authority removed - #7

Merged
ristik merged 2 commits into
mainfrom
dev3/java-4-verification
Nov 8, 2026
Merged

ristik merged 2 commits into
mainfrom
dev3/java-4-verification

Conversation

@ristik

@ristik ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Owner §51, plan PR 4 (based on #3, parallel to dev2's #4/#5). Mirrors JS SealVerificationSession/TrustBaseEntryResult/UnicitySealTrustBaseEntryRule/UnicityCertificateVerifier and Rust verify/seal.rs, tests/trust_base_seal_history.rs. Breaking, no compatibility mode (§30).

  • V1 authority removed: RootTrustBase (JSON) is deleted. TrustBaseHistoryView (read-only face of a history, same name and members as dev2's PR6 interface plus getGenesisPin(); TrustBaseHistory implements it) replaces it in UnicityCertificateVerifier, the operation verifier, SealVerificationSession, NonInclusionVerifier, ProofConsolidator, TokenProofClient, StateTransitionClient, the transactions' verify methods, InclusionProofUtils, VerificationContext.
  • Seals by their own epoch: structure -> network -> the entry of the seal's epoch -> round in [start, next start) -> weighted quorum of that entry. Placement runs on every call, memo hits included; the memo key is the entry id plus the complete seal (witnesses included).
  • Typed no-entry: NoTrustBaseEntryResult (epoch, held tip) for an epoch above the tip or an empty history; NoTrustBaseEntryResult.find(result) finds it in nested results (tested through Token.verify). Wrong network, pre-genesis epoch, bad interval and bad quorum are final (UnicityCertificateFailure: new NO_TRUST_BASE_ENTRY, AFTER_EPOCH_END; UNSUPPORTED_AUTHORITY removed). Consolidation maps them to UNAUTHENTICATED with the typed reason in the message (its outcome names are shared fixtures).
  • Weighted counting replaces the unit-stake restriction. The permissive seal-extras rule is kept (unknown/bad/non-65-byte witnesses count zero); SealVerificationSession.checkSealStructure still rejects empty signer ids and empty signatures.
  • 256-signature bound (UnicitySeal.MAX_WITNESSES): at decode (header count, before any element), in the structure check, in the session before the memo key, and first in the quorum rule.
  • VerificationPolicy and the legacy quorum-only path are removed: a historical proof verifies against the entry of its epoch or not at all. beginOperation(pins); new beginOperation(pins, sessionFactory) and SealQuorumRule (size the memo / in-flight bound or supply a quorum check; used by the busy-session tests).
  • Docs: README first connection and docs/api-reference.md snippets use a bundle + pinned genesis id (the session and release pins arrive with PRs 6-8).
  • Tests: fixtures migrate to synthetic V2 histories (TrustBaseTestUtils, TestChain.Authority.trustBaseThrough/weightedTrustBase; the recorded corpora's V1 authority JSON is converted to a genesis entry); new: epoch placement/interval/exclusive end, memo hit with a growing history, weighted 5,1,1,1, unsigned epochs/rounds across 2^63, 256-signature seals (accept 256, refuse 257 at decode/structure/session/rule, all 256 members of a 256-member authority stop at 171), typed no-entry through nested token verification.
  • Mutants killed (13): 256 bound at decode/structure/rule, threshold stop, weight vs count, network/no-entry-vs-before-genesis/start/end placement, exclusive end, memo key witnesses. Equivalent: memo key without the entry id (a session has one view and an epoch maps to one entry) and signed threshold compare (weights sum below 2^48).

Evidence: ./gradlew test checkstyleMain animalsnifferMain under Temurin 11 green (800+ tests). Integration/e2e tests compile but still need the hermetic V2 stack (the JS unicitynetwork#16/unicitynetwork#23 equivalent) and a bundle; not run here.
Not merged by me; owner list.

…placed in the entry of their own epoch; weighted quorum; typed no-entry; 256-signature bound; V1 authority removed

RootTrustBase (the V1 JSON authority) is removed with no compatibility mode. TrustBaseHistoryView (read-only face of a history) replaces it in every verifier and caller. SealVerificationSession: structure, network, the entry of the seal's epoch, round inside [start, next start), then the weighted quorum of that entry, memoized by entry id and the complete seal. A seal of an epoch the history lacks is the typed NoTrustBaseEntryResult (found through nested results); VerificationPolicy and the legacy quorum-only path are gone. UnicitySeal.MAX_WITNESSES=256 at decode, structure, session and rule. Test fixtures migrate to synthetic V2 histories.
@ristik

ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

java#7 at 067ef25: no blockers. APPROVE once CI is green. UnicitySealTrustBaseEntryRule places each seal in its own epoch:

  • network first; an epoch above the tip is the typed NoTrustBaseEntryResult, and an epoch below the genesis is a final EPOCH_MISMATCH (the rs#27 parity point is already right here);
  • the round must be at least the epoch's start and below the next held epoch's start.

The quorum is weighted with an unsigned compare. MAX_WITNESSES = 256 is checked in the structure check, before the memo key and in the rule. Consolidation evidence: it goes through verifier.verifyCertificate, whose two paths (UnicityCertificateVerification and the operation verifier) both call SealVerificationSession.authenticate, so evidence seals are placed in their epoch. js#16's quorum-only gap isn't present. RootTrustBase is removed, and no V1 or TESTNET reference is left. Tests: the full suite at this head passes, 806 tests, 4 skipped, 0 failures, with compileJava and animalsnifferMain clean (JDK 11, /Users/risto/uni/agre/jdk11).

@ristik

ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

java#7 at 067ef25: changes requested, for red CI only. CI build fails in :javadoc with one error: src/main/java/org/unicitylabs/sdk/api/bft/verification/SealAuthenticator.java:30: error: reference not found, a {@link SealVerificationSession#verifyLegacyQuorum} to the method this PR removed (run 42433639972). It's a one-line doc fix. My local run used test compileJava animalsnifferMain, not build, so it didn't run javadoc; I'll include build from now on. Everything else in my review above stands, and I'll approve on green.

@ristik

ristik commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

java#7 at 424b44d: APPROVE, for the owner's list. The delta is javadoc only: SealAuthenticator no longer links the removed verifyLegacyQuorum, and its text now describes epoch placement. CI build (javadoc included) is green. My code review stands. Your nits on #1 to #3 as one follow-up commit after the merges is fine by me.

@ristik
ristik changed the base branch from dev3/java-3-history to main November 8, 2026 03:05
@ristik
ristik merged commit f2c9ff5 into main Nov 8, 2026
1 check passed
@ristik
ristik deleted the dev3/java-4-verification 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