synapsecns / sanguine

Synapse Monorepo
MIT License
43 stars 31 forks source link

feat(contracts-rfq): relayer exclusivity [SLT-187] #3202

Closed ChiTimesChi closed 2 months ago

ChiTimesChi commented 2 months ago

Description User should be able to provide new fields for the bridge() function (field names are tentative):

  1. quoteId - Optional - sent on Deposit, emitted on BridgeRequested. Not included in request bytes. Used for off-chain functionality and tracking only.
  2. quoteRelayer - Optional - sent on Deposit, emitted, included in request bytes, enforced by relay function
  3. quoteRelayerSeconds - Optional - sent on Deposit, generates a timestamp deadline (block ts + X) which is emitted and included in request bytes. Enforced by relay function.

Old bridge() function should be preserved, by using the default empty/zero values for these fields.

Objective: quoteRelayer to have exclusive fill rights until exclusivity deadline.

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

Walkthrough

The pull request introduces updates to the FastBridgeV2 contract and its associated interfaces, enhancing transaction handling with new structures for exclusivity parameters. Key changes include the addition of a new interface IFastBridgeV2, modifications to existing function signatures, and updates to the testing framework to accommodate the new transaction structures. These changes refine the bridge mechanism, ensuring improved management of transaction exclusivity and validation processes.

Changes

Files Change Summary
packages/contracts-rfq/contracts/FastBridgeV2.sol Added getBridgeTransactionV2 function, overloaded bridge function with new parameters, modified transaction request structure to include exclusivity fields, and updated relay function logic.
packages/contracts-rfq/contracts/interfaces/IFastBridgeV2.sol Introduced BridgeParamsV2 and BridgeTransactionV2 structs, added BridgeQuoteDetails event, and updated bridge function signature.
packages/contracts-rfq/test/FastBridgeV2.t.sol Updated tests to transition from IFastBridge to IFastBridgeV2, modified function signatures to use BridgeTransactionV2, and added new tests for exclusivity handling.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol Updated tests to reflect changes in transaction handling and added new tests for exclusivity scenarios in bridging tokens and ETH.
packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol Implemented exclusivity parameters in tests for both token and ETH transactions, ensuring correct handling of exclusivity conditions and reverts.
packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.Negative.t.sol Added tests to validate negative scenarios for exclusivity parameters, checking for expected reverts under incorrect conditions.

Possibly related PRs

Suggested labels

javascript, Sol, Typescript

Suggested reviewers

🐰 In the meadow, where bunnies play,
A bridge was built, brightening the day.
With exclusivity and new paths to roam,
Tokens and ETH now find their home.
So hop along, let the relayers cheer,
For FastBridgeV2 is finally here! 🌟


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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
πŸͺ§ Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 2 months ago

Changes to gas cost

Generated at commit: 7acdf381c46fc911287304b67092a609387d62a6, compared to commit: eead134ff4d19554413efdab732c38e9d90fe763

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 bridgeProofs
claim(bytes)
claim(bytes,address)
prove(bytes,bytes32)
relay(bytes)
+22 ❌
+524 ❌
+634 ❌
+337 ❌
+664 ❌
+3.65%
+1.05%
+1.23%
+0.97%
+0.94%

Full diff report πŸ‘‡
| Contract | Deployment Cost (+/-) | Method | Min (+/-) | % | Avg (+/-) | % | Median (+/-) | % | Max (+/-) | % | # Calls (+/-) | |:-|-:|:-|-:|-:|-:|-:|-:|-:|-:|-:|-:| | **FastBridgeV2** | 2,673,824 (+294,021) | _RELAYER_ROLE_
_bridgeProofs_
_claim(bytes)_
_claim(bytes,address)_
_dispute_
_prove(bytes,bytes32)_
_prove(bytes32,bytes32,address)_
_refund_
_relay(bytes)_
_relay(bytes,address)_ | 307 (+22)
624 (+22)
42,732 (+524)
45,695 (+634)
31,284 (+34)
35,067 (+338)
32,140 (+12)
46,492 (+435)
65,594 (+664)
66,011 (+664) | **+7.72%**
**+3.65%**
**+1.24%**
**+1.41%**
**+0.11%**
**+0.97%**
**+0.04%**
**+0.94%**
**+1.02%**
**+1.02%** | 307 (+22)
624 (+22)
50,266 (+524)
51,979 (+634)
31,284 (+25)
35,094 (+337)
32,140 (+1)
50,198 (+435)
71,489 (+664)
71,906 (+664) | **+7.72%**
**+3.65%**
**+1.05%**
**+1.23%**
**+0.08%**
**+0.97%**
**+0.00%**
**+0.87%**
**+0.94%**
**+0.93%** | 307 (+22)
624 (+22)
50,275 (+524)
51,988 (+634)
31,284 (+22)
35,097 (+338)
32,140 (0)
50,207 (+435)
71,489 (+664)
71,906 (+664) | **+7.72%**
**+3.65%**
**+1.05%**
**+1.23%**
**+0.07%**
**+0.97%**
**0.00%**
**+0.87%**
**+0.94%**
**+0.93%** | 307 (+22)
624 (+22)
57,782 (+524)
58,245 (+634)
31,284 (+22)
35,211 (+338)
32,140 (0)
53,886 (+435)
77,385 (+664)
77,802 (+664) | **+7.72%**
**+3.65%**
**+0.92%**
**+1.10%**
**+0.07%**
**+0.97%**
**0.00%**
**+0.81%**
**+0.87%**
**+0.86%** | 72 (+8)
8 (0)
4 (0)
4 (0)
4 (0)
40 (+4)
40 (+4)
8 (0)
2 (0)
2 (0) |
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.35088%. Comparing base (f0b13bc) to head (ad5bd73). Report is 21 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3202 +/- ## ==================================================== + Coverage 40.97804% 90.35088% +49.37284% ==================================================== Files 459 60 -399 Lines 25643 1254 -24389 Branches 343 150 -193 ==================================================== - Hits 10508 1133 -9375 + Misses 14383 116 -14267 + Partials 752 5 -747 ``` | [Flag](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | Coverage Ξ” | | |---|---|---| | [cctp-relayer](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [core](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [ethergo](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [git-changes-action](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [omnirpc](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [opbot](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [packages](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `90.56974% <ΓΈ> (ΓΈ)` | | | [screener-api](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [scribe](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | | [solidity](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `89.40678% <100.00000%> (-5.29995%)` | :arrow_down: | | [tools](https://app.codecov.io/gh/synapsecns/sanguine/pull/3202/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=synapsecns#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cloudflare-workers-and-pages[bot] commented 2 months ago

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: ad5bd73
Status:🚫  Build failed.

View logs

codecov[bot] commented 2 months ago

Bundle Report

Changes will increase total bundle size by 407.1kB (1.14%) :arrow_up:. This is within the configured threshold :white_check_mark:

Detailed changes | Bundle name | Size | Change | | ----------- | ---- | ------ | | sdk-router-@synapsecns/sdk-router-cjs | 526.74kB | 409.5kB (349.29%) :arrow_up: | | explorer-ui-server-cjs* | 865.43kB | 639 bytes (-0.07%) :arrow_down: | | synapse-interface-client-array-push* | 7.28MB | 147 bytes (0.0%) :arrow_up: | | synapse-interface-server-cjs | 1.49MB | 127 bytes (0.01%) :arrow_up: | | widget-cjs-esm* | 271.27kB | 2.03kB (-0.74%) :arrow_down: |

ℹ️ *Bundle size includes cached data from a previous commit

ChiTimesChi commented 2 months ago

Gas diffs will be much closer to the true values once #3204 is merged