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(contracts-rfq): configurable deployBlock #3437

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

ChiTimesChi
Copy link
Collaborator

@ChiTimesChi ChiTimesChi commented Dec 4, 2024

Description
This PR makes previously immutable deployBlock variable configurable by the contract's admin. This allows to change this value post-deployment on chains like Arbitrum that implement block.number as the L1's block number, which can't be used by the off-chain indexers.

Summary by CodeRabbit

  • New Features

    • Introduced a deployBlock variable to track the contract's deployment block.
    • Added a function for admins to set the deployment block.
    • Updated bridge functionality with new parameters and improved error handling.
    • Deprecated old methods in favor of more efficient replacements.
  • Bug Fixes

    • Enhanced validation checks for bridge and relay transactions.
  • Tests

    • Added tests for the new deploy block functionality and admin access control.

Copy link
Contributor

coderabbitai bot commented Dec 4, 2024

Walkthrough

The pull request introduces significant changes to the AdminV2 and FastBridgeV2 contracts, including the addition of a mutable deployBlock variable and a corresponding setDeployBlock function in AdminV2. The FastBridgeV2 contract sees the removal of the deployBlock variable and updates to its constructor. Additionally, new error handling and validation checks are implemented across various functions. The IAdminV2 interface is updated to reflect these changes, and corresponding tests are added to ensure proper functionality and access control.

Changes

File Path Change Summary
packages/contracts-rfq/contracts/AdminV2.sol - Added: uint256 public deployBlock
- Added: function setDeployBlock(uint256 blockNumber)
- Added: internal _setDeployBlock(uint256 blockNumber) function and event DeployBlockSet(blockNumber)
packages/contracts-rfq/contracts/FastBridgeV2.sol - Removed: uint256 public immutable deployBlock
- Updated: Constructor no longer records deployment block
- Deprecated: function refund replaced by cancelV2
- Added: function cancelV2(bytes calldata request)
- Updated: bridge, relay, and prove functions with new validation checks
packages/contracts-rfq/contracts/interfaces/IAdminV2.sol - Added: event DeployBlockSet(uint256 blockNumber)
- Added: function setDeployBlock(uint256 blockNumber) external
packages/contracts-rfq/test/FastBridgeV2.Management.t.sol - Added: Event DeployBlockSet
- Added: Function setDeployBlock(address caller, uint256 blockNumber)
- Renamed: test_defaultCancelDelay to test_defaultValues
- Added: test_setDeployBlock and test_setDeployBlock_revertNotAdmin functions

Possibly related PRs

Suggested labels

size/m

Suggested reviewers

  • parodime
  • trajan0x
  • aureliusbtc

🐰 In the code where changes bloom,
A deploy block now finds room.
With admin rights to set the stage,
Our contracts dance, a new age!
From FastBridge to Admin's grace,
We hop along, a happy place! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c65b451 and a3f394f.

📒 Files selected for processing (4)
  • packages/contracts-rfq/contracts/AdminV2.sol (4 hunks)
  • packages/contracts-rfq/contracts/FastBridgeV2.sol (1 hunks)
  • packages/contracts-rfq/contracts/interfaces/IAdminV2.sol (2 hunks)
  • packages/contracts-rfq/test/FastBridgeV2.Management.t.sol (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/contracts-rfq/contracts/interfaces/IAdminV2.sol
👮 Files not reviewed due to content moderation or server errors (3)
  • packages/contracts-rfq/contracts/AdminV2.sol
  • packages/contracts-rfq/test/FastBridgeV2.Management.t.sol
  • packages/contracts-rfq/contracts/FastBridgeV2.sol
🧰 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-11-12T03:37:08.148Z
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.

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. (Experiment)
  • @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.

@github-actions github-actions bot added the size/s label Dec 4, 2024
Copy link

cloudflare-workers-and-pages bot commented Dec 4, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: a3f394f
Status: ✅  Deploy successful!
Preview URL: https://113c34f9.sanguine-fe.pages.dev
Branch Preview URL: https://fix-fbv2-setdeployblock.sanguine-fe.pages.dev

View logs

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.79276%. Comparing base (3d3530d) to head (a3f394f).
Report is 3 commits behind head on master.

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #3437         +/-   ##
===================================================
+ Coverage   98.78296%   98.79276%   +0.00979%     
===================================================
  Files              9           9                 
  Lines            493         497          +4     
===================================================
+ Hits             487         491          +4     
  Misses             6           6                 
Flag Coverage Δ
solidity 98.79276% <100.00000%> (+0.00979%) ⬆️

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!

@ChiTimesChi ChiTimesChi merged commit cb43466 into master Dec 10, 2024
64 of 66 checks passed
@ChiTimesChi ChiTimesChi deleted the fix/FbV2-setDeployBlock branch December 10, 2024 23:44
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