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

Ds/validate event test #297

Merged
merged 9 commits into from
Dec 20, 2024
Merged

Ds/validate event test #297

merged 9 commits into from
Dec 20, 2024

Conversation

dshiell
Copy link
Collaborator

@dshiell dshiell commented Dec 20, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced receipt parsing logic for improved accuracy in handling RLP-encoded receipts.
    • Introduced a new dependency for validating sequencer signatures.
  • Bug Fixes

    • Updated comments for clarity in the receipt parsing function.
  • Tests

    • Restructured test cases to focus on direct method invocation with new validation logic.
    • Disabled outdated test functions related to previous implementations.
    • Removed tests for invalid scenarios to streamline the testing process.

@dshiell dshiell requested a review from RnkSngh December 20, 2024 06:32
Copy link

coderabbitai bot commented Dec 20, 2024

Warning

Rate limit exceeded

@dshiell has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 74f372a and 0e66fa1.

📒 Files selected for processing (16)
  • package.json (2 hunks)
  • src/evm/contracts/factories/CrossL2Prover__factory.ts (1 hunks)
  • src/evm/contracts/factories/Dispatcher__factory.ts (1 hunks)
  • src/evm/contracts/factories/Earth__factory.ts (1 hunks)
  • src/evm/contracts/factories/FeeVault__factory.ts (1 hunks)
  • src/evm/contracts/factories/IbcUtils__factory.ts (1 hunks)
  • src/evm/contracts/factories/Ibc__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/Mars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Moon__factory.ts (1 hunks)
  • src/evm/contracts/factories/UniversalChannelHandler__factory.ts (1 hunks)
  • test/proofApi/CrossL2EventProposer.t.sol (3 hunks)

Walkthrough

The pull request introduces modifications to two key files: contracts/libs/Ibc.sol and test/proofApi/CrossL2EventProposer.t.sol. In Ibc.sol, the parseLog function is updated to improve RLP-encoded receipt handling by using inline assembly to detect and process typed receipts. The test file CrossL2EventProposer.t.sol is restructured with a new SequencerSignatureVerifier import, modified test setup, and changes to the testing approach, focusing on direct method invocations.

Changes

File Change Summary
contracts/libs/Ibc.sol Enhanced parseLog function with inline assembly to handle typed receipts by reading the first byte of receiptRLP. Refactored comments and removed commented-out code.
test/proofApi/CrossL2EventProposer.t.sol Added SequencerSignatureVerifier import, modified test setup to include a new instance of SequencerSignatureVerifier, commented out existing tests, and introduced new testing logic with direct method calls to CrossL2Prover. Removed several tests related to invalid scenarios.

Possibly related PRs

  • increment height in peptide proof #277: The changes in the validateReceipt function of the CrossL2Prover contract may relate to the modifications in the parseLog function of Ibc.sol, as both involve receipt handling and verification logic within the context of blockchain transactions.

Suggested reviewers

  • alfredo-stonk

Poem

🐰 Hop, hop, through the code we go,
RLP receipts now flow with grace so,
Typed or untyped, we parse with care,
Inline assembly dancing in the air!
A rabbit's leap of logic so 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

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

🧹 Nitpick comments (7)
test/proofApi/CrossL2EventProposer.t.sol (6)

9-9: Repeated forge-std/Test.sol import.
It appears that “forge-std/Test.sol” is imported twice (lines 1 and 9). Consider removing the duplicate import if it is not strictly required.


64-71: Commented-out test code for test_clientUpdate_success.
If these tests are still relevant, consider re-enabling and updating them to match the new signature-verification approach. Otherwise, fully remove them to avoid confusion.


87-88: New data variable (cdataI).
Similar to updateD1, ensure this test data aligns with the targeted receipt or event you want to simulate. Documenting the origin or purpose of this hex can aid maintainability.


90-93: Receipt update data (updateD, cdata).
Large hex strings can be difficult to maintain. If feasible, consider programmatically generating or referencing them from test fixtures to reduce the chance of transcription errors.


100-104: Commented-out alternative SequencerSignatureVerifier parameters.
If you no longer need these lines, remove them to keep the test file clear of unused code. Otherwise, consider adding a short comment clarifying why they’re retained.


113-125: Multiple commented-out test blocks.
A large portion of tests are disabled, which may reduce overall coverage. If these tests are obsolete, remove them. Otherwise, consider reworking and re-enabling them to ensure thorough coverage.

Would you like help converting these tests to match the new approach?

Also applies to: 127-139, 141-153, 155-165, 167-174, 176-188

contracts/libs/Ibc.sol (1)

342-342: Clarifying comment on unindexed data.
The code comment clarifies that the final bytes segment is simply an ABI-encoded uint64. This is helpful context.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f26b246 and c43c8ee.

📒 Files selected for processing (2)
  • contracts/libs/Ibc.sol (2 hunks)
  • test/proofApi/CrossL2EventProposer.t.sol (3 hunks)
🔇 Additional comments (5)
test/proofApi/CrossL2EventProposer.t.sol (4)

7-7: New import seems reasonable.
The direct import of SequencerSignatureVerifier indicates a new dependency for verifying sequencer-signed data. This aligns well with the newly introduced test logic.


84-85: New data variable (updateD1).
The test data is large and opaque, making it difficult to determine correctness by inspection. Confirm that this hex data accurately represents the intended scenario.


95-97: Instantiation of SequencerSignatureVerifier with custom parameters.
This code looks consistent with the overall strategy of verifying block ancestry or signature authenticity from a specified address. Make sure any environment-specific addresses (like 0x11a7...) are set to valid test addresses.


112-112: Empty line addition.
No functional issue; possibly just a spacing change.

contracts/libs/Ibc.sol (1)

308-314: Typed receipt detection in parseLog.
• Good approach to strip the type byte when the receipt is typed.
• Validate that other typed receipt formats won’t require additional processing.

Also applies to: 316-317

test/proofApi/CrossL2EventProposer.t.sol Outdated Show resolved Hide resolved
Copy link
Collaborator

@RnkSngh RnkSngh left a comment

Choose a reason for hiding this comment

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

LGTM aside from minor nits, more so questions

contracts/libs/Ibc.sol Show resolved Hide resolved
contracts/libs/Ibc.sol Show resolved Hide resolved
contracts/libs/Ibc.sol Show resolved Hide resolved
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

🧹 Nitpick comments (3)
test/proofApi/CrossL2EventProposer.t.sol (3)

94-102: Consider parameterizing the SequencerSignatureVerifier configuration.

The hardcoded addresses and values in the SequencerSignatureVerifier constructor could make tests brittle and environment-dependent. Consider:

  1. Moving these values to test configuration files
  2. Using environment variables
  3. Creating helper functions to generate test-specific configurations

This will make the tests more maintainable and easier to run in different environments.

-        SequencerSignatureVerifier sigV = new SequencerSignatureVerifier(
-            address(0x11a72195e668328fEe607a309EfA2C42B2893E1d),
-            bytes32(0x0000000000000000000000000000000000000000000000000000000000000385)
-        );
+        SequencerSignatureVerifier sigV = new SequencerSignatureVerifier(
+            vm.envAddress("SEQUENCER_ADDRESS"),
+            bytes32(uint256(vm.envUint("SEQUENCER_CHAIN_ID")))
+        );

63-70: Document why the test is commented out.

The test_clientUpdate_success function is commented out without explanation. If this is temporary:

  1. Add a TODO comment explaining why it's disabled
  2. Create a tracking issue for re-enabling it
  3. If it's obsolete, consider removing it entirely

Line range hint 111-182: Track TODOs systematically.

The skipped tests have well-documented implementation steps, but they should be tracked systematically.

Would you like me to:

  1. Create GitHub issues for each TODO with the implementation steps?
  2. Set up a tracking project board for these test implementations?
  3. Generate a test implementation plan with priorities and dependencies?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c43c8ee and 74f372a.

📒 Files selected for processing (2)
  • contracts/libs/Ibc.sol (2 hunks)
  • test/proofApi/CrossL2EventProposer.t.sol (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • contracts/libs/Ibc.sol

test/proofApi/CrossL2EventProposer.t.sol Outdated Show resolved Hide resolved
@dshiell dshiell merged commit b292b1d into main Dec 20, 2024
3 checks passed
@dshiell dshiell deleted the ds/validate_event_test branch December 20, 2024 07:52
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.

2 participants