Skip to content

#58 Add shard id verification against state id#62

Open
martti007 wants to merge 3 commits intoissue-60from
issue-58
Open

#58 Add shard id verification against state id#62
martti007 wants to merge 3 commits intoissue-60from
issue-58

Conversation

@martti007
Copy link
Copy Markdown
Contributor

No description provided.

@martti007 martti007 requested a review from MastaP April 29, 2026 14:58
@MastaP MastaP linked an issue Apr 29, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ShardIdMatchesStateIdRule to verify that a shard ID is a prefix of the transaction's state ID, integrating this check into the InclusionProofVerificationRule and adding a new SHARD_ID_MISMATCH status. A review comment suggests enhancing the robustness of the new verification logic by adding null checks and validating data lengths to prevent potential NullPointerException or ArrayIndexOutOfBoundsException.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds verification to ensure the shard id carried by the unicity certificate’s shard tree certificate matches (is a prefix of) the transaction-derived state id.

Changes:

  • Introduces ShardIdMatchesStateIdRule to validate shard-id prefix vs. transaction StateId.
  • Adds SHARD_ID_MISMATCH to InclusionProofVerificationStatus.
  • Integrates the shard-id check into InclusionProofVerificationRule prior to unicity certificate verification.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/main/java/org/unicitylabs/sdk/transaction/verification/ShardIdMatchesStateIdRule.java New verification rule that checks shard id prefix against transaction state id.
src/main/java/org/unicitylabs/sdk/transaction/verification/InclusionProofVerificationStatus.java Adds a dedicated status for shard-id mismatch failures.
src/main/java/org/unicitylabs/sdk/transaction/verification/InclusionProofVerificationRule.java Runs the new shard-id rule during inclusion proof verification and maps failure to the new status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@MastaP MastaP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see the feedback

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.

Add BFT-based sharding support

3 participants