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

✉️ Improve event attributes for store_object #584

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

bdeneux
Copy link
Contributor

@bdeneux bdeneux commented Jun 19, 2024

Implement #556 by adding more attributes on the returned result when storing object in Objectarium. See comments in issue (#556) for more information about event attributes choices.

Summary by CodeRabbit

  • New Features

    • Enhanced object storage to include attributes for action, size, compressed size, and pinned status.
  • Bug Fixes

    • Improved functionality for pinning objects and returning pinned status.
  • Tests

    • Added test cases to verify attributes for stored objects in various scenarios.

Copy link

coderabbitai bot commented Jun 19, 2024

Walkthrough

Recent changes in the Axone Objectarium's contract.rs file enhance object storage and management by adding attributes for size, compressed size, and pinned status during storage in the execute module. This functionality is fortified with new tests to ensure correct handling of these attributes across various scenarios.

Changes

Files Change Summary
contracts/axone-objectarium/src/... execute module: Enhanced store_object and pin_object functions; added attributes to Response object.
contracts/axone-objectarium/src/tests Added test cases to validate new attributes and scenarios for stored objects.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Contract
    participant Storage
    participant Response
    
    User->>Contract: store_object(object_data)
    Contract->>Storage: save_object(object_data)
    Storage-->>Contract: object_id, object_attributes
    Contract->>Response: include attributes (size, compressed_size, pinned, action)
    Response-->>User: send response with attributes

    User->>Contract: pin_object(object_id)
    Contract->>Storage: update_object_as_pinned(object_id)
    Storage-->>Contract: updated_object_data
    Contract-->>User: confirm pinning
Loading

Poem

In the code's deep, snug warren,
Where objects now get pinned tight,
Their sizes clear as day now,
And tests ensure they're right.
A happy dance, in bunny lands,
For code that's smooth and bright! 🐰✨


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 Configration 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.

@bdeneux bdeneux linked an issue Jun 19, 2024 that may be closed by this pull request
@bdeneux bdeneux marked this pull request as ready for review June 19, 2024 14:04
@bdeneux bdeneux changed the title ✉️ Improve event attribute for store_object ✉️ Improve event attributes for store_object Jun 19, 2024
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
contracts/axone-objectarium/src/contract.rs 99.89% <100.00%> (+0.01%) ⬆️

@bot-anik
Copy link
Member

size-limit report 📦

Path Size
target/wasm32-unknown-unknown/release/axone_objectarium.wasm 400.67 KB (+0.34% 🔺)
target/wasm32-unknown-unknown/release/axone_law_stone.wasm 544.59 KB (0%)
target/wasm32-unknown-unknown/release/axone_cognitarium.wasm 762.25 KB (0%)
target/wasm32-unknown-unknown/release/axone_dataverse.wasm 622.17 KB (0%)

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 922c757 and 11aea99.

Files selected for processing (1)
  • contracts/axone-objectarium/src/contract.rs (11 hunks)
Additional comments not posted (5)
contracts/axone-objectarium/src/contract.rs (5)

Line range hint 123-147: The function store_object has been updated to handle additional attributes like size and compressed_size which are added based on the compression results. This change aligns with the PR objectives to enhance the event attribute returned when storing an object. However, ensure that all potential callers of this function are updated to handle these new attributes correctly.


171-171: The function now returns a Response object with an attribute indicating the pin status. This change enhances the traceability and debuggability of pin operations. Ensure that all consumers of this function are aware of this new attribute to handle it appropriately in their logic.


171-171: The update to the pin_object function to manage the pinning status directly is a significant change. It simplifies the management of object states by directly modifying the pin status and ensures that the state is consistently managed across the system. This change should be thoroughly tested, especially in scenarios involving concurrent access to the same object by multiple clients.


171-171: The unpin_object function has been correctly updated to handle the unpinning logic. This includes decrementing the pin count and removing the pin record if applicable. It's important to ensure that this function is called in all scenarios where an object's pin status needs to be revoked, to maintain the integrity of the system's state.


164-171: The handling of the pin parameter within store_object has been enhanced. The function now correctly updates the pinned attribute based on whether the object was successfully pinned or not. This is a crucial update for maintaining the integrity of pin state in the system. It is recommended to verify that the may_pin_object function handles all edge cases correctly, especially with concurrent pin operations which might affect the pin count.

contracts/axone-objectarium/src/contract.rs Show resolved Hide resolved
@bdeneux bdeneux requested review from ccamel and amimart June 19, 2024 14:23
@bdeneux bdeneux self-assigned this Jun 19, 2024
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! Thanks 👍

Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Perfect thanks 🙏

@bdeneux bdeneux merged commit 2864de5 into main Jun 20, 2024
17 checks passed
@bdeneux bdeneux deleted the feat/objectarium-event-attribute branch June 20, 2024 12:55
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.

🛡️ Insufficient information in Events
4 participants