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

Update Faucet contract to use bridging on drip function #10621

Merged
merged 10 commits into from
May 29, 2024

Conversation

tarunkhasnavis
Copy link
Contributor

@tarunkhasnavis tarunkhasnavis commented May 22, 2024

This PR aims to update our Faucet contract design by modifying the drip function.

  • We introduce a new parameter to the drip function _bridge which is expected to be an address to the L1Standard bridge for a given OP Chain.
  • We then create an interface for the L1StandardBridge and utilize the depositETHTo function within the drip function. the specified bridge address is the target contract for the function.
  • In the case that the recipient is expecting to receive test ETH on L1 Sepolia itself we expect a null address (address(0)). The backend will supply a null address as the bridge param for this case
  • We have updated the unit tests to reflect these changes

More context: https://www.notion.so/oplabs/Superchain-Faucet-in-Dev-Console-dea77a1062b24b40abc0f0752c111dc1?pvs=4#7a7014cac2b34560893115ebe4e2e6a2

@tarunkhasnavis tarunkhasnavis requested a review from a team as a code owner May 22, 2024 21:33
Copy link
Contributor

coderabbitai bot commented May 22, 2024

Walkthrough

Walkthrough

The updates primarily enhance the Faucet.sol contract by adding support for bridging funds to other chains, introducing new parameters (data and gasLimit) to the DripParameters struct, and ensuring safe ETH transfers using SafeCall.call. Additionally, corresponding tests have been updated to reflect these changes, ensuring comprehensive verification of the new functionalities.

Changes

Files/Paths Change Summaries
packages/contracts-bedrock/src/periphery/faucet/Faucet.sol Added SafeCall import, modified DripParameters struct, added recipient check, updated drip function, and modified Drip event.
packages/contracts-bedrock/test/periphery/faucet/Faucet.t.sol Introduced bridgeAddress variable and updated faucet.drip function calls to include new parameters.
packages/contracts-bedrock/test/periphery/faucet/authmodules/AdminFaucetAuthModule.t.sol Updated test functions to include data and gasLimit variables in Faucet.DripParameters struct.
.changeset/selfish-donuts-camp.md, .changeset/cold-frogs-join.md, .changeset/... Introduced changesets documenting the updates to the @eth-optimism/contracts-bedrock package.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant Faucet
    participant SafeCall
    participant Bridge

    User->>Faucet: Call drip(recipient, amount, bridge, data, gasLimit)
    Faucet->>Faucet: Check recipient != faucet address
    Faucet->>SafeCall: SafeCall.call{value: amount}(recipient, data, gasLimit)
    SafeCall-->>Faucet: Transfer status
    Faucet->>Bridge: Log Drip event with bridge parameter
    Faucet-->>User: Drip transaction completed
Loading

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 958ff1d and 039d2fd.
Files selected for processing (1)
  • .changeset/witty-pants-move.md (1 hunks)
Additional comments not posted (1)
.changeset/witty-pants-move.md (1)

1-5: The changeset documentation is clear and aligns well with the PR's objectives.


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 full the 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.

@tarunkhasnavis tarunkhasnavis changed the title adding bridging to the faucet drip call Update Faucet contract to use bridging on drip function May 22, 2024
@tarunkhasnavis tarunkhasnavis requested a review from tynes May 22, 2024 21:50
Copy link
Contributor

@tremarkley tremarkley left a comment

Choose a reason for hiding this comment

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

I think you will need to add a changeset to this, but would confirm with member of the smart contracts team

Copy link

semgrep-app bot commented May 24, 2024

Semgrep found 2 invalid-usage-of-modified-variable findings:

Variable unsafeInNode is likely modified and later used on error. In some cases this could result in panics due to a nil dereference

Ignore this finding from invalid-usage-of-modified-variable.

@tarunkhasnavis tarunkhasnavis force-pushed the faucet_bridging_implementation branch from 95e0c9d to 060b6f5 Compare May 28, 2024 05:48
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

Outside diff range and nitpick comments (1)
.changeset/cold-frogs-join.md (1)

5-5: Typographical error in the description. Consider correcting "recieving" to "receiving".

Copy link
Contributor

@smartcontracts smartcontracts left a comment

Choose a reason for hiding this comment

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

Nice work

Copy link

semgrep-app bot commented May 28, 2024

Semgrep found 2 invalid-usage-of-modified-variable findings:

Variable unsafeInNode is likely modified and later used on error. In some cases this could result in panics due to a nil dereference

Ignore this finding from invalid-usage-of-modified-variable.

Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.26%. Comparing base (3b374c2) to head (039d2fd).
Report is 30 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #10621       +/-   ##
============================================
- Coverage    55.13%   39.26%   -15.88%     
============================================
  Files           37       27       -10     
  Lines         2900     1821     -1079     
  Branches       415      415               
============================================
- Hits          1599      715      -884     
+ Misses        1269     1106      -163     
+ Partials        32        0       -32     
Flag Coverage Δ
cannon-go-tests ?
chain-mon-tests 27.14% <ø> (ø)
sdk-tests 40.27% <ø> (ø)

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

see 10 files with indirect coverage changes

@tremarkley tremarkley enabled auto-merge May 28, 2024 22:27
@tremarkley tremarkley added this pull request to the merge queue May 28, 2024
@tremarkley tremarkley removed this pull request from the merge queue due to a manual request May 28, 2024
@tremarkley tremarkley enabled auto-merge May 28, 2024 23:27
@tremarkley tremarkley added this pull request to the merge queue May 28, 2024
Merged via the queue into develop with commit eb454ac May 29, 2024
69 checks passed
@tremarkley tremarkley deleted the faucet_bridging_implementation branch May 29, 2024 00:07
This was referenced May 29, 2024
Copy link

@magkooh magkooh left a comment

Choose a reason for hiding this comment

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

packages/contracts-bedrock/snapshots/abi/AdminFaucetAuthModule.json

rdovgan pushed a commit to rdovgan/optimism that referenced this pull request Jun 24, 2024
…imism#10621)

* adding bridging to the faucet drip call

* updating the logic based on suggesstions

* adding changeset

* fixing ci issue

* update auth module tests

* final fix

* lint fix

* update snapshots

* update changeset

* change to patch

---------

Co-authored-by: Tarun Khasnavis <tarunkhasnavis@Taruns-MacBook-Pro.local>
Co-authored-by: tre <tremarkley@gmail.com>
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.

None yet

4 participants