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

Patch models.StorageReceipt to accommodate the old format #343

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

m-Peter
Copy link
Collaborator

@m-Peter m-Peter commented Jul 10, 2024

Description

Add the models.StorageReceiptV0, to accommodate the encoding/decoding of the old format.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • New Features
    • Introduced a temporary StorageReceiptV0 type for handling receipts until the PreviewNet reset.
  • Refactor
    • Updated receipt decoding logic to use the new StorageReceiptV0 type.

@m-Peter m-Peter added this to the Flow-EVM-M2 milestone Jul 10, 2024
@m-Peter m-Peter self-assigned this Jul 10, 2024
Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Walkthrough

The change introduces a new type, StorageReceiptV0, with methods for converting between different receipt types. This is part of an interim solution for receipt management until a full reset in PreviewNet. Modifications are made to decoding logic and type handling in storage/pebble/receipts.go, ensuring compatibility and seamless transition to the new receipt structure.

Changes

File(s) Change Summary
models/receipt.go Introduced StorageReceiptV0 type and added method ToNewReceipt for conversion to StorageReceipt.
storage/pebble/receipts.go Modified decoding logic for receipts to handle StorageReceiptV0, adjusting variable types accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StorageSystem
    participant Decoder
    participant PreviewNet
    User->>StorageSystem: Request receipt
    StorageSystem->>Decoder: Decode receipt
    Decoder->>StorageSystem: Return StorageReceiptV0
    StorageSystem->>PreviewNet: Convert to new format
    PreviewNet->>StorageSystem: Provide StorageReceipt
    StorageSystem->>User: Return updated receipt
Loading

Poem

In the code where data flows,
A new type, V0, now shows. 🐇
Decoding changed with careful art,
To keep our system smart.
PreviewNet awaits the day,
When V0 can fade away. ✨


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.

@m-Peter m-Peter changed the title Patch models.StorageReceipt to accomodate the old decoding Patch models.StorageReceipt to accommodate the old decoding Jul 10, 2024
@m-Peter m-Peter changed the title Patch models.StorageReceipt to accommodate the old decoding Patch models.StorageReceipt to accommodate the old format Jul 10, 2024
Copy link
Contributor

@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 56c5fcb and 9341598.

Files selected for processing (2)
  • models/receipt.go (1 hunks)
  • storage/pebble/receipts.go (1 hunks)
Additional comments not posted (5)
storage/pebble/receipts.go (3)

137-147: Ensure Robust Decoding Logic for StorageReceiptV0.

The decoding logic for StorageReceiptV0 is appropriate for handling the older format. Ensure that the ToNewReceipt method correctly converts all necessary fields.


149-151: Approve Conversion Logic to New Receipt Format.

The loop correctly converts StorageReceiptV0 instances to the newer StorageReceipt type using the ToNewReceipt method. This ensures compatibility with existing receipt handling logic.


153-162: Verify Fallback Decoding to StorageReceipt.

The fallback decoding logic ensures that the system can handle receipts in the older format. Ensure that this fallback mechanism is thoroughly tested.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

models/receipt.go (2)

18-35: Temporary Type Definition for StorageReceiptV0.

The StorageReceiptV0 type is defined with all necessary fields for receipt data. Ensure this type is removed after the PreviewNet reset as indicated by the TODO comment.


37-56: Approve Conversion Method for StorageReceiptV0 to StorageReceipt.

The ToNewReceipt method correctly maps all fields from StorageReceiptV0 to StorageReceipt. This ensures compatibility with the new receipt format.

@devbugging devbugging merged commit 90de2f5 into main Jul 11, 2024
2 checks passed
@m-Peter m-Peter deleted the patch-storage-receipt-decoding-v2 branch July 29, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants