Skip to content

contracts-bedrock: portal opaque data test#10443

Merged
tynes merged 8 commits intodevelopfrom
ctb/portal-opaque-data
May 10, 2024
Merged

contracts-bedrock: portal opaque data test#10443
tynes merged 8 commits intodevelopfrom
ctb/portal-opaque-data

Conversation

@tynes
Copy link
Contributor

@tynes tynes commented May 7, 2024

Description

  • contracts-bedrock: add deposit event coverage
  • contracts-bedrock: revert diff to portal

contracts-bedrock: add deposit event coverage

Adds deposit event differential coverage for the two
different places where the deposit tx event exists.
This ensures that a valid event ends up getting emitted.

A commit 372ec6b
is reverted that modularizes the code for serializing
the event so that there are not footguns when computing
the "opaque data". We can bring this back easily if
we would like.

@tynes tynes requested a review from a team as a code owner May 7, 2024 23:17
@tynes tynes requested a review from smartcontracts May 7, 2024 23:17
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 7, 2024

Walkthrough

Walkthrough

The recent update focuses on enhancing the OptimismPortal test suite in the contracts-bedrock package. It includes adjusting the semantic version constant in OptimismPortal.sol from "2.8.0" to "2.7.0". Additionally, new functionality has been introduced in OptimismPortal.t.sol, such as importing VmSafe from forge-std/Vm.sol and adding a test function test_setGasPayingToken_correctEvent_succeeds() to OptimismPortal_Test.

Changes

File Path Change Summary
.../contracts-bedrock/src/L1/OptimismPortal.sol Updated semantic version constant version from "2.8.0" to "2.7.0"
.../contracts-bedrock/test/L1/OptimismPortal.t.sol Added import { VmSafe } from "forge-std/Vm.sol" and new test function test_setGasPayingToken_correctEvent_succeeds() to OptimismPortal_Test

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between bdf4b7e and a71528e.
Files selected for processing (1)
  • packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (2 hunks)
Additional comments not posted (2)
packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (2)

6-6: Import of VmSafe from forge-std/Vm.sol added.

This import is likely used to enhance testing safety or capabilities, aligning with the PR's focus on improving test environments.


474-517: New test function test_setGasPayingToken_correctEvent_succeeds added.

This function appropriately tests the event emission for setting a gas-paying token, ensuring that the contract behaves as expected under these conditions. The use of VmSafe for recording and asserting logs is a robust method for verifying the correctness of event-related functionality.


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.

@codecov
Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.22%. Comparing base (6c6dc18) to head (a71528e).

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10443       +/-   ##
============================================
- Coverage    42.31%   29.22%   -13.09%     
============================================
  Files           73       31       -42     
  Lines         4838     2898     -1940     
  Branches       766      614      -152     
============================================
- Hits          2047      847     -1200     
+ Misses        2682     1976      -706     
+ Partials       109       75       -34     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
common-ts-tests ?
contracts-ts-tests 12.25% <ø> (ø)
core-utils-tests ?
sdk-tests 40.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 42 files with indirect coverage changes

Copy link
Contributor

@geoknee geoknee left a comment

Choose a reason for hiding this comment

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

LGTM, left one suggestion.

@tynes tynes force-pushed the ctb/portal-opaque-data branch from bafd7c4 to bdf4b7e Compare May 9, 2024 15:41
@tynes tynes enabled auto-merge May 9, 2024 15:45
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

Out of diff range and nitpick comments (1)
packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (1)

Line range hint 741-741: Incorrect usage of blockhash(block.number).

The use of blockhash(block.number) will always return 0, which is likely not the intended behavior. Consider using a different block number that is within the last 256 blocks.

- blockhash(block.number)
+ blockhash(block.number - 1) // Assuming the previous block's hash is required

tynes added 8 commits May 10, 2024 19:26
Adds deposit event differential coverage for the two
different places where the deposit tx event exists.
This ensures that a valid event ends up getting emitted.
Also modularizes the code for serializing the event so that
there are not footguns when computing the "opaque data".
Removes the diff to the portal, perhaps we want it
but test still passes without it
@tynes tynes force-pushed the ctb/portal-opaque-data branch from d18c90a to a71528e Compare May 10, 2024 17:26
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

Out of diff range and nitpick comments (1)
packages/contracts-bedrock/test/L1/OptimismPortal.t.sol (1)

Line range hint 743-743: Incorrect use of blockhash(block.number) in testing environment.

- blockhash(block.number)
+ blockhash(block.number - 1)

The use of blockhash(block.number) always returns 0 in the Ethereum environment, which can lead to incorrect test outcomes. It should be replaced with blockhash(block.number - 1) to fetch the hash of the most recently mined block.

@tynes tynes added this pull request to the merge queue May 10, 2024
Merged via the queue into develop with commit 7daf06d May 10, 2024
@tynes tynes deleted the ctb/portal-opaque-data branch May 10, 2024 18:13
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.

3 participants