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

feat(rfq-api): check both relayer role and quoter role #3398

Closed
wants to merge 12 commits into from

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Nov 18, 2024

null
913658f: explorer-ui preview link
913658f: synapse-interface preview link

Summary by CodeRabbit

  • New Features

    • Introduced a cancellation feature for bridge transactions.
    • Added new optional parameters (destAddress and address) to API endpoints for enhanced functionality.
    • Expanded GraphQL queries to include bridgeModule for more detailed transaction context.
  • Bug Fixes

    • Improved error handling in various API methods and tests.
  • Documentation

    • Updated API documentation to reflect new parameters and response structures.
  • Chores

    • Updated changelog for the @synapsecns/contracts-rfq package to include new features and version changes.

aureliusbtc and others added 12 commits November 16, 2024 22:56
* explorer UI updated

* rfq-indexer update

* explorer backend update

* [goreleaser] trigger explorer version bump

* rfq indexer with the right contracts

* [goreleaser] adding catch

* response error fixes and wld decimals

* adding address

* feat(rfq-indexer): add `request` column to `BridgeRequested` for refunds (#3287)

* feat(rfq-relayer): add MaxRelayAmount (#3259)

* Feat: add quoteParams helper for test

* Feat: add MaxQuoteAmount to relconfig

* Feat: use MaxQuoteAmount

* Feat: handle MaxQuoteAmount in quoter test

* Replace: MaxQuoteAmount -> MaxRelayAmount

* Feat: shouldProcess() returns false if max relay amount exceeded

* Feat: add test for MaxRelayAmount

* add request field for refunds

* adding to events typing

---------

Co-authored-by: dwasse <wassermandaniel8@gmail.com>
Co-authored-by: defi-moses <jakedinero@protonmail.com>

* fix api docs

* linting fixes

* fixing irrelavent files

* wc fixes and tests solved

* fix linting errors

* [goreleaser]

* refining tests

* adding bridge Module to graphql

* Adding to all bridge watcher queries

* adding worldchain to the chart

* adding other rfq events to the rfq events db

* fixing wld coingecko ticker [goreleaser]

* [goreleaser] coingecko update and new topic parsing

* small lint fix

* [goreleaser] linting fixes

* fix(rfq-indexer): add missing fields (#3309)

* add missing fields

---------

Co-authored-by: abtestingalpha <abtestingalpha@gmail.com>

---------

Co-authored-by: vro <168573323+golangisfun123@users.noreply.github.com>
Co-authored-by: dwasse <wassermandaniel8@gmail.com>
Co-authored-by: abtestingalpha <abtestingalpha@gmail.com>
* feat: start with identical AdminV2

* refactor: refund -> cancel

* test: update the tests, add coverage for deprecated method

* feat: scaffold `setCancelDelay`

* test: coverage for `calcelDelay` management

* feat: configurable cancel delay

* refactor: custom error `FeeRateAboveMax`

* test: chainGasAmount deprecation

* feat: deprecate `chainGasAmount`

* refactor: drop `UniversalTokenLib` in AdminV2

* refactor: event before external call, docs

* relabel RELAYER_ROLE -> PROVER_ROLE

* retain RELAYER_ROLE in addtn to PROVER_ROLE, for offchain perms

* refactor: RELAYER_ROLE -> QUOTER_ROLE, docs

* docs: AdminV2 other constants

---------

Co-authored-by: parodime <jordan@protochainresearch.com>
 - @synapsecns/contracts-rfq@0.13.0
* Feat: call filterQuoteAge() in handlePassiveRFQ()

* Feat: refactor into getPassiveQuote() func

* Feat: add TestGetPassiveQuote

* Config: lower max quote age
Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve updates across multiple files, primarily focusing on the introduction of a new AdminV2 contract, enhancements to the FastBridgeV2 contract, and modifications to the handling of bridge and swap operations in the API. Key updates include the addition of cancellation functionality, updates to the .gitattributes file to manage generated files, and enhancements to the API endpoints to accommodate new parameters. The changelog has also been updated to reflect these changes, ensuring comprehensive documentation of the package's evolution.

Changes

File Change Summary
.gitattributes Added rule for *.contractinfo.json as generated; clarified Go file handling.
packages/contracts-rfq/CHANGELOG.md Updated for version 0.13.0, added release notes for permissionless cancellation feature.
packages/contracts-rfq/contracts/AdminV2.sol Introduced AdminV2 contract with access control roles and fee management functions.
packages/contracts-rfq/contracts/FastBridgeV2.sol Replaced Admin with AdminV2, added cancel function, modified access control for prove.
packages/contracts-rfq/contracts/interfaces/IAdminV2.sol Added IAdminV2 interface with events and functions for admin tasks.
packages/contracts-rfq/contracts/interfaces/IAdminV2Errors.sol Introduced IAdminV2Errors interface with custom error types.
packages/contracts-rfq/contracts/interfaces/IFastBridgeV2.sol Added cancel function to interface for bridge transactions.
packages/contracts-rfq/package.json Updated version to 0.13.0.
packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol Renamed refund tests to cancellation tests, updated logic accordingly.
packages/contracts-rfq/test/FastBridgeV2.Management.t.sol Enhanced management tests with new cancellation delay features and error handling.
packages/contracts-rfq/test/FastBridgeV2.Src.Base.t.sol Updated role assignments and renamed refund functions to cancellation.
packages/contracts-rfq/test/FastBridgeV2.Src.t.sol Renamed refund functions to cancellation and updated related logic.
packages/rest-api/src/controllers/bridgeController.ts Added optional destAddress parameter to requests, updated response handling.
packages/rest-api/src/controllers/swapController.ts Added optional address parameter to swap requests.
packages/rest-api/src/routes/bridgeRoute.ts Updated API documentation to include destAddress, added validation.
packages/rest-api/src/routes/swapRoute.ts Updated API documentation to include address, added validation.
services/explorer/graphql/client/client.go Added BridgeModule field to GraphQL response types.
services/explorer/types/fastbridge/eventtype.go Added new event types for bridge transactions.
services/rfq/api/config/config.go Updated defaultMaxQuoteAge from 1 hour to 5 minutes.

Possibly related PRs

Suggested labels

size/m, needs-go-generate-services/rfq

Suggested reviewers

  • aureliusbtc
  • trajan0x
  • ChiTimesChi

Poem

In the fields where rabbits play,
New contracts hop, brightening the day.
With cancellation now in sight,
We leap for joy, oh what a delight!
Hopping through code, with roles anew,
A world of bridges, just for you! 🐇✨

Warning

Rate limit exceeded

@github-actions[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 83cef1d and 13d978c.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

services/explorer/graphql/client/queries/queries.graphql

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module '@babel/core/package.json'
Require stack:

  • /node_modules/@babel/eslint-parser/lib/parse.cjs
  • /node_modules/@babel/eslint-parser/lib/index.cjs
  • /node_modules/@eslint/eslintrc/dist/eslintrc.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Function.resolve (node:internal/modules/helpers:145:19)
    at Object. (/node_modules/@babel/eslint-parser/lib/parse.cjs:14:19)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
🔧 golangci-lint

level=warning msg="[config_reader] The configuration option run.skip-files is deprecated, please use issues.exclude-files."
level=warning msg="[config_reader] The configuration option run.skip-dirs is deprecated, please use issues.exclude-dirs."
level=warning msg="[config_reader] The configuration option run.skip-dirs-use-default is deprecated, please use issues.exclude-dirs-use-default."
level=warning msg="[lintersdb] The linter "maligned" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "exhaustivestruct" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "ifshort" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "interfacer" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The linter "nosnakecase" is deprecated (step 2) and deactivated. It should be removed from the list of disabled linters. https://golangci-lint.run/product/roadmap/#linter-deprecation-cycle"
level=warning msg="[lintersdb] The name "goerr113" is deprecated. The linter has been renamed to: err113."
level=warning msg="The linter 'execinquery' is deprecated (since v1.58.0) due to: The repository of the linter has been archived by the owner. "
level=warning msg="The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar."


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.

@dwasse dwasse closed this Nov 18, 2024
@github-actions github-actions bot deleted the feat/quoter-role-no-relayer branch November 18, 2024 21:13
@dwasse dwasse restored the feat/quoter-role-no-relayer branch November 18, 2024 21:14
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 26.69992%. Comparing base (83cef1d) to head (13d978c).
Report is 9 commits behind head on feat/relayer-arb-call.

Additional details and impacted files
@@                       Coverage Diff                       @@
##           feat/relayer-arb-call       #3398         +/-   ##
===============================================================
+ Coverage               26.60645%   26.69992%   +0.09346%     
===============================================================
  Files                        214         215          +1     
  Lines                      13617       13633         +16     
  Branches                      82          82                 
===============================================================
+ Hits                        3623        3640         +17     
+ Misses                      9711        9710          -1     
  Partials                     283         283                 
Flag Coverage Δ
opbot 0.18337% <ø> (ø)
packages 90.44834% <ø> (ø)
promexporter 6.81642% <ø> (ø)
solidity 98.73418% <100.00000%> (+0.08097%) ⬆️

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.


🚨 Try these New Features:

Copy link

Changes to gas cost

Generated at commit: 913658fd48bb0e4a8f7f472315398b6c06043c75, compared to commit: 83cef1de2ceb886958ccda1a9a12f161d0e05e5d

🧾 Summary (50% most significant diffs)

Contract Method Avg (+/-) %
FastBridgeV2 bridgeProofs
bridgeRelayDetails
bridgeStatuses
getBridgeTransaction
getBridgeTransactionV2
grantRole
senderNonces
+22 ❌
-22 ✅
+22 ❌
-64 ✅
+23 ❌
-4,527 ✅
-22 ✅
+3.26%
-3.27%
+1.84%
-1.49%
+0.91%
-3.95%
-1.96%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
FastBridgeV2 3,469,866 (+47,031) GOVERNOR_ROLE
GUARD_ROLE
bridge
bridgeProofs
bridgeRelayDetails
bridgeStatuses
claim(bytes)
claim(bytes,address)
dispute
getBridgeTransaction
getBridgeTransactionV2
grantRole
nonce
prove(bytes,bytes32)
prove(bytes32,bytes32,address)
relay(bytes)
relay(bytes,address)
senderNonces
setProtocolFeeRate
339 (+45)
286 (+22)
69,002 (-44)
696 (+22)
650 (-22)
638 (+22)
40,032 (+66)
42,961 (+22)
31,167 (+45)
4,233 (-64)
1,130 (+23)
29,395 (-72,010)
307 (+45)
34,534 (+22)
32,063 (+45)
61,362 (+22)
61,814 (+67)
603 (-22)
47,398 (-23)
+15.31%
+8.33%
-0.06%
+3.26%
-3.27%
+3.57%
+0.17%
+0.05%
+0.14%
-1.49%
+2.08%
-71.01%
+17.18%
+0.06%
+0.14%
+0.04%
+0.11%
-3.52%
-0.05%
339 (+45)
286 (+22)
80,380 (-44)
696 (+22)
650 (-22)
1,220 (+22)
46,943 (+66)
48,622 (+22)
31,177 (+45)
4,233 (-64)
2,557 (+23)
110,010 (-4,527)
307 (+45)
34,847 (+22)
32,071 (+45)
67,816 (+22)
68,268 (+67)
1,103 (-22)
47,398 (-23)
+15.31%
+8.33%
-0.05%
+3.26%
-3.27%
+1.84%
+0.14%
+0.05%
+0.14%
-1.49%
+0.91%
-3.95%
+17.18%
+0.06%
+0.14%
+0.03%
+0.10%
-1.96%
-0.05%
339 (+45)
286 (+22)
81,081 (-44)
696 (+22)
650 (-22)
638 (+22)
47,527 (+66)
49,206 (+22)
31,179 (+45)
4,233 (-64)
3,194 (+23)
118,484 (-21)
307 (+45)
34,558 (+22)
32,075 (+45)
67,740 (+23)
68,192 (+68)
603 (-22)
47,398 (-23)
+15.31%
+8.33%
-0.05%
+3.26%
-3.27%
+3.57%
+0.14%
+0.04%
+0.14%
-1.49%
+0.73%
-0.02%
+17.18%
+0.06%
+0.14%
+0.03%
+0.10%
-3.52%
-0.05%
339 (+45)
286 (+22)
93,185 (-43)
696 (+22)
650 (-22)
2,638 (+22)
54,986 (+66)
55,415 (+22)
31,179 (+45)
4,233 (-64)
3,347 (+23)
118,484 (-21)
307 (+45)
35,498 (+22)
32,075 (+45)
76,933 (+23)
77,385 (+68)
2,603 (-22)
47,398 (-23)
+15.31%
+8.33%
-0.05%
+3.26%
-3.27%
+0.84%
+0.12%
+0.04%
+0.14%
-1.49%
+0.69%
-0.02%
+17.18%
+0.06%
+0.14%
+0.03%
+0.09%
-0.84%
-0.05%
88 (+67)
67 (0)
260 (0)
12 (0)
12 (0)
426 (0)
6 (0)
6 (0)
6 (0)
1 (0)
3 (0)
356 (+67)
4 (0)
68 (0)
68 (0)
6 (0)
6 (0)
248 (0)
21 (0)

Copy link

codecov bot commented Nov 18, 2024

Bundle Report

Changes will decrease total bundle size by 3.83MB (-10.75%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sdk-router-@synapsecns/sdk-router-esm 255.26kB 609 bytes (0.24%) ⬆️
sdk-router-@synapsecns/sdk-router-cjs 117.55kB 312 bytes (0.27%) ⬆️
explorer-ui-server-cjs 724.75kB 141.31kB (-16.32%) ⬇️
explorer-ui-client-array-push 2.17MB 146.19kB (-6.32%) ⬇️
synapse-interface-client-array-push 7.41MB 132.38kB (1.82%) ⬆️
synapse-interface-server-cjs 1.65MB 160.38kB (10.73%) ⬆️
widget-cjs-esm* 271.27kB 2.03kB (-0.74%) ⬇️
docs-bridge-client-array-push* 7.28MB 619.12kB (-7.83%) ⬇️
docs-bridge-server-cjs* 11.31MB 3.57MB (-23.98%) ⬇️
synapse-constants-esm-cjs* 174.63kB 174.63kB (100%) ⬆️
synapse-constants-cjs-esm* 174.18kB 174.18kB (100%) ⬆️

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants