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

refactor(contracts-rfq): emit events before external calls, more explicit docs [SLT-342] #3316

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Oct 21, 2024

Description
See title.

Summary by CodeRabbit

  • New Features

    • Enhanced dispute functionality with stricter conditions for raising disputes.
    • Updated refund logic to clarify processing conditions and timing.
    • Improved claim functionality allowing claims on behalf of proven relayers.
    • New functions added to retrieve bridge statuses, proofs, and relay information.
  • Bug Fixes

    • Refined error handling across various functions for better transaction reliability.

Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The pull request introduces significant modifications to the FastBridgeV2 contract, focusing on transaction dispute management, refunds, claims, and bridge transaction handling. Key updates include enhanced dispute functionality, clarified refund processes, and refined claim mechanisms. New functions for retrieving bridge statuses and proofs have been added, alongside improved error handling across various functions. These changes aim to bolster the contract's efficiency and clarity in managing transaction states.

Changes

File Path Change Summary
packages/contracts-rfq/contracts/FastBridgeV2.sol Updated dispute, refund, claim, and prove functions; added new functions for status retrieval; refined error handling.

Possibly related PRs

Suggested labels

size/m, M-docs, Sol

Suggested reviewers

  • parodime
  • trajan0x

🐰 In the realm of bridges, we hop and play,
With disputes and claims, we clear the way.
Refunds now dance, with logic so bright,
In FastBridgeV2, everything feels right!
So let’s raise a cheer, for changes so grand,
A smoother transaction, just as we planned! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 06a7efa and 63b04b1.

📒 Files selected for processing (1)
  • packages/contracts-rfq/contracts/FastBridgeV2.sol (4 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/contracts-rfq/contracts/FastBridgeV2.sol (1)
Learnt from: ChiTimesChi
PR: synapsecns/sanguine#3284
File: packages/contracts-rfq/contracts/FastBridgeV2.sol:100-118
Timestamp: 2024-10-14T14:45:57.214Z
Learning: When reviewing code in `packages/contracts-rfq/contracts/FastBridgeV2.sol` (Solidity), focus on changes introduced in the PR and avoid commenting on existing functions like `refund` if they are not modified by the PR, as such comments are considered out of scope.
🔇 Additional comments (11)
packages/contracts-rfq/contracts/FastBridgeV2.sol (11)

86-90: Good practice: Aggregating storage reads for gas optimization

Aggregating the storage reads into local variables improves gas efficiency by reducing redundant storage accesses.


110-113: Ensure correct refund eligibility checks

The logic correctly enforces that refunds can only be processed for transactions with a status of REQUESTED after their deadline expires.


113-116: Permissionless refund logic is correctly implemented

The additional REFUND_DELAY for permissionless refunds is properly handled based on the caller's role.


124-126: Best practice: Emitting events before external calls

Emitting the BridgeDepositRefunded event before any external calls enhances security by minimizing the risk of reentrancy attacks.


292-294: Appropriate status check before proving a transaction

The check ensures that only transactions with status REQUESTED can be proved, maintaining the correct state transitions.


309-318: Good practice: Aggregating storage reads and enforcing claim conditions

Aggregating storage reads improves gas efficiency, and the checks correctly enforce that a transaction can only be claimed after the dispute period has passed.


321-324: Clarification on claim recipient logic

The logic allows anyone to claim the funds on behalf of the proven relayer if to is zero, ensuring flexibility while maintaining security checks.


334-339: Best practice: Emitting events before external calls

Emitting the BridgeDepositClaimed event before external calls enhances security by reducing potential reentrancy risks.


347-349: Addition of bridgeStatuses function enhances transparency

Providing a public view function to retrieve the bridge status of transactions improves the contract's usability for external parties.


Line range hint 352-356: Addition of bridgeProofs function allows retrieval of proof details

Exposing proof timestamps and relayer addresses can be useful for auditors and users to verify transaction proofs.


Line range hint 358-360: Addition of bridgeRelays function to check relay status

This function enhances the ability to verify whether a transaction has been relayed.


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

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

cloudflare-workers-and-pages bot commented Oct 21, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 63b04b1
Status: ✅  Deploy successful!
Preview URL: https://9f3483e1.sanguine-fe.pages.dev
Branch Preview URL: https://refactor-fbv2-final-touches.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.74454%. Comparing base (6415acd) to head (63b04b1).
Report is 21 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3316         +/-   ##
===================================================
- Coverage   31.92469%   28.74454%   -3.18015%     
===================================================
  Files            238         184         -54     
  Lines          14553       12131       -2422     
  Branches         356          82        -274     
===================================================
- Hits            4646        3487       -1159     
+ Misses          9614        8361       -1253     
+ Partials         293         283         -10     
Flag Coverage Δ
packages 90.44834% <ø> (ø)
promexporter ?
solidity 98.65772% <100.00000%> (+3.13638%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@parodime parodime left a comment

Choose a reason for hiding this comment

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

lgtm just a phrasing nit

packages/contracts-rfq/contracts/FastBridgeV2.sol Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants