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

Fix decoding issues with previous formats #237

Merged
merged 7 commits into from
May 9, 2024
Merged

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented May 9, 2024

This PR addresses decoding of existing data in the index that was changed in meantime. This will all be reverted after we remove such an existing network (previewnet).

Summary by CodeRabbit

  • New Features
    • Enhanced error messaging for API failures.
    • Improved transaction handling in case of missing data types.
  • Bug Fixes
    • Added checks for missing transactions in blocks to prevent errors.
    • Updated receipt decoding logic to handle single receipts properly.
  • Refactor
    • Updated import statements across multiple modules for better code organization.

@devbugging devbugging self-assigned this May 9, 2024
Copy link
Contributor

coderabbitai bot commented May 9, 2024

Walkthrough

This update involves modifications across several files in the Flow EVM Gateway codebase, focusing on error handling, transaction processing, and receipt decoding. The changes aim to improve robustness and adapt to new data structures, ensuring more reliable operations and better error feedback in blockchain interactions.

Changes

File Path Change Summary
api/api.go Updated imports, modified return statements for block retrieval, enhanced error messaging, and added transaction not found handling.
models/transaction.go Added logic to handle a breaking change in transaction data unmarshalling.
storage/pebble/receipts.go Enhanced receipt decoding with new imports and error handling.

🐇✨
In the garden of code, where the data trees grow,
A rabbit hops in, with updates in tow.
Through lines of logic and blocks of care,
It tweaks and it tunes with a meticulous flare.
Celebrate the changes, for they make us thrive,
In this digital burrow, where our codes come alive!
🌟🐾


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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@devbugging devbugging requested a review from janezpodhostnik May 9, 2024 17:16
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: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6d66d37 and 98c9f24.
Files selected for processing (3)
  • api/api.go (6 hunks)
  • models/transaction.go (1 hunks)
  • storage/pebble/receipts.go (2 hunks)
Additional comments not posted (2)
api/api.go (2)

285-290: Ensure that the prepareBlockResponse function correctly handles all cases as expected.


320-325: Confirm that the prepareBlockResponse function is used consistently and correctly across different scenarios.

Verification successful

The prepareBlockResponse function is used consistently and correctly within the api.go file. It appears in two identical calls and is defined once in the same file. There are no other occurrences in the rest of the codebase, indicating that its usage is confined to specific scenarios within this file, which is typical for specialized functions.

  • File: api/api.go
    • Usage: Called twice with identical parameters and context.
    • Definition: Clearly defined in the same file.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for consistent usage of `prepareBlockResponse` across different scenarios.

# Test: Search for inconsistent usage patterns.
rg --type go $'prepareBlockResponse' api/api.go

Length of output: 214



Script:

#!/bin/bash
# Description: Search for all occurrences of `prepareBlockResponse` across the entire repository to verify consistent usage.

# Search for the function usage across all Go files.
rg --type go 'prepareBlockResponse'

Length of output: 236

Comment on lines +169 to +174
// todo remove this after previewnet is reset
// breaking change on transaction data, try without type
if err := tx.UnmarshalBinary(value); err == nil {
return TransactionCall{Transaction: tx}, nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results confirm that the temporary decoding logic, marked with a "todo" comment about removing it after the previewnet reset, is still present in the models/transaction.go file. This indicates that the intended removal has not yet been executed.


Temporary Decoding Logic Still Present in models/transaction.go

  • The temporary decoding logic that was supposed to be removed after the previewnet reset is still present in the codebase. This needs attention to ensure the code aligns with the intended changes post-reset.
Analysis chain

Temporary decoding logic added to handle breaking changes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the temporary decoding logic is removed after the previewnet reset.

# Test: Search for the temporary decoding logic. Expect: No occurrences after the reset.
rg --type go $'// todo remove this after previewnet is reset' models/transaction.go

Length of output: 132

Comment on lines +142 to +150
if err = rlp.DecodeBytes(val, &storeReceipts); err != nil {
// todo remove this after previewnet is reset
// try to decode single receipt (breaking change migration)
var storeReceipt models.StorageReceipt
if err = rlp.DecodeBytes(val, &storeReceipt); err != nil {
return nil, err
}

storeReceipts = []*models.StorageReceipt{&storeReceipt}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results confirm that the comment indicating the temporary logic for decoding single receipts due to breaking changes is still present in the storage/pebble/receipts.go file. This suggests that the temporary logic has not been removed following the previewnet reset as initially planned.


Temporary Logic for Decoding Single Receipts Still Present

  • The temporary logic intended for removal after the previewnet reset is still in the codebase. This needs attention to ensure the code aligns with the intended lifecycle of temporary fixes.
  • Location: storage/pebble/receipts.go
Analysis chain

Temporary logic added to decode single receipts due to breaking changes.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the temporary logic for decoding single receipts is removed after the previewnet reset.

# Test: Search for the temporary logic. Expect: No occurrences after the reset.
rg --type go $'// todo remove this after previewnet is reset' storage/pebble/receipts.go

Length of output: 137

@devbugging devbugging merged commit 553fca6 into main May 9, 2024
2 checks passed
@peterargue peterargue deleted the gregor/receipt-decoder branch May 9, 2024 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants