Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dataverse)!: rework and enhance vc stored context #625

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

amimart
Copy link
Member

@amimart amimart commented Aug 23, 2024

Closes #615

Details

Brings the changes proposed in #615 by making the difference between VC's body and context (i.e. considered as headers in the RDF), and enhance this context with block information (i.e. height, timestamp & tx_index).

Those changes are considered breaking as it breaks the model stored in the cognitarium.

Summary by CodeRabbit

  • New Features

    • Enhanced claims processing by integrating environmental context into contract execution.
    • Updated DataverseCredential structure to include new fields for better context representation.
  • Bug Fixes

    • Improved logic for handling credential attributes, ensuring accuracy in data representation.
  • Documentation

    • Updated test cases to reflect changes in credential structure and logic adjustments.
  • Refactor

    • Restructured NamedNode constants for clarity and improved semantic organization.

Copy link

coderabbitai bot commented Aug 23, 2024

Walkthrough

The changes involve modifications to the DataverseCredential structure, expanding its metadata to include contextual information such as transaction height, timestamp, and sender address. The functions handling claims have been updated to incorporate these new fields, enhancing how credentials are processed and stored. Additionally, constants used in RDF representation have been reorganized for better clarity.

Changes

File Path Change Summary
contracts/axone-dataverse/src/contract.rs, contracts/axone-dataverse/src/execute.rs Updated function signatures to include env parameter for enhanced claims processing and environmental context.
contracts/axone-dataverse/src/registrar/credential.rs Modified DataverseCredential struct to add new fields (height, timestamp, tx_index, sender) and updated conversion logic.
contracts/axone-dataverse/src/registrar/rdf.rs Reorganized constants for credential attributes into header and body categories, updating associated logic for clarity.
contracts/axone-dataverse/testdata/vc-unsupported-4.nq Changed the predicate for claims in RDF representation to reflect the new structure (dataverse:credential:body#claim).

Assessment against linked issues

Objective Addressed Explanation
Store additional context data for claims (e.g., block height, transaction index, sender address) (#[615])
Organize credential attributes into header and body categories (#[615])

🐇 In the meadow, the credentials bloom,
With heights and timestamps, they make room.
From submitter's address to claims anew,
Each change a hop, a leap, a view.
Through the blockchain, they dance and sway,
Celebrating facts in a merry way! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@amimart amimart self-assigned this Aug 23, 2024
@amimart amimart marked this pull request as ready for review August 23, 2024 08:50
@amimart amimart requested review from bdeneux and ccamel August 23, 2024 08:50
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
contracts/axone-dataverse/src/contract.rs 96.27% <100.00%> (+0.04%) ⬆️
...tracts/axone-dataverse/src/registrar/credential.rs 98.00% <100.00%> (+0.10%) ⬆️
contracts/axone-dataverse/src/registrar/rdf.rs 93.56% <100.00%> (+0.58%) ⬆️

@bot-anik
Copy link
Member

size-limit report 📦

Path Size
target/wasm32-unknown-unknown/release/axone_objectarium.wasm 458.07 KB (0%)
target/wasm32-unknown-unknown/release/axone_law_stone.wasm 648.51 KB (0%)
target/wasm32-unknown-unknown/release/axone_cognitarium.wasm 831.35 KB (0%)
target/wasm32-unknown-unknown/release/axone_dataverse.wasm 672.44 KB (+0.31% 🔺)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 63b8573 and eb52ace.

Files selected for processing (4)
  • contracts/axone-dataverse/src/contract.rs (4 hunks)
  • contracts/axone-dataverse/src/registrar/credential.rs (4 hunks)
  • contracts/axone-dataverse/src/registrar/rdf.rs (6 hunks)
  • contracts/axone-dataverse/testdata/vc-unsupported-4.nq (1 hunks)
Additional comments not posted (19)
contracts/axone-dataverse/testdata/vc-unsupported-4.nq (1)

3-3: LGTM! Predicate namespace update.

The change from <dataverse:credential#claim> to <dataverse:credential:body#claim> aligns with the new structure for differentiating between the VC's body and context.

contracts/axone-dataverse/src/registrar/credential.rs (6)

4-4: Import statement update.

The addition of Env and MessageInfo imports is necessary for the updated TryFrom implementation.


9-12: New fields added to DataverseCredential.

The addition of height, timestamp, tx_index, and sender fields enhances the credential's metadata with blockchain context information.


44-54: Updated TryFrom implementation.

The conversion logic now includes environment and message information, allowing the population of new fields with relevant blockchain data.


70-73: Test utilities import update.

The imports for message_info, addr, SENDER, and mock_env_addr are necessary for simulating environment and message information in tests.


80-88: Test case update for DataverseCredential.

The test case now checks for the correct population of new fields, ensuring alignment with the updated conversion logic.


133-134: Test case update for unsupported credentials.

The test case ensures that the updated conversion logic correctly handles unsupported credentials.

contracts/axone-dataverse/src/registrar/rdf.rs (9)

11-20: Reorganized constants for RDF predicates.

The reorganization of constants into VC_HEADER_ and VC_BODY_ categories improves clarity and semantic organization.


24-52: New and updated constants for RDF predicates.

The new constants for header and body predicates align with the enhanced structure for VC metadata.


100-139: Updated triples creation logic.

The logic for creating triples now uses the new header and body predicates, enhancing the RDF representation of credentials.


144-150: Conditional handling of tx_index.

The conditional check for tx_index allows for flexible serialization of optional attributes.


256-256: Updated claim triple creation.

The use of VC_BODY_CLAIM for claim triples aligns with the new structure for RDF representation.


278-280: Test utilities import update.

The imports for message_info, addr, SENDER, and mock_env_addr are necessary for simulating environment and message information in tests.


287-303: Test case update for serialization.

The test case ensures that the serialization output aligns with the new structure of header and body predicates.


319-338: Test case update for named hierarchy serialization.

The test case checks the proper serialization of named hierarchies, reflecting the updated RDF structure.


354-356: Test case for reserved predicates.

The test case ensures that claims with reserved predicates are correctly identified and handled.

contracts/axone-dataverse/src/contract.rs (3)

71-71: LGTM! The env parameter enhances functionality.

The addition of the env parameter allows the execute function to access environmental context, improving its robustness and flexibility.


78-78: LGTM! Propagating env to submit_claims aligns with the updated signature.

Including the env parameter in the submit_claims function call ensures that environmental context is utilized throughout the claims processing workflow.


Line range hint 95-106: LGTM! The env parameter enhances credential verification.

The updated function signature and logic in submit_claims leverage the env parameter, improving the processing and verification of credentials.

Copy link
Contributor

@bdeneux bdeneux left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Lgtm 👍

@amimart amimart merged commit 3f79933 into main Aug 23, 2024
17 checks passed
@amimart amimart deleted the feat/dataverse-vc-headers branch August 23, 2024 09:56
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.

🌐 Extend VC context
4 participants