Closed ChiTimesChi closed 1 month ago
The changes in this pull request enhance the FastBridgeV2
contract by introducing new functionalities and parameters. A constant MAX_CALL_PARAMS_LENGTH
is added, and the bridge
function is modified to include a callParams
field in the BridgeParamsV2
struct. The relay
function is updated to handle this new field, while a new _checkedCallRecipient
method is introduced for safe recipient interactions. Additionally, a new interface IFastBridgeRecipient
is created, and various mock contracts are added for testing purposes, expanding the testing framework for different recipient scenarios.
File | Change Summary |
---|---|
packages/contracts-rfq/contracts/FastBridgeV2.sol |
- Added constant MAX_CALL_PARAMS_LENGTH . - Updated bridge function to include callParams in BridgeParamsV2 . - Modified relay function to handle callParams . - Introduced _checkedCallRecipient method. |
packages/contracts-rfq/contracts/interfaces/IFastBridgeRecipient.sol |
- Added interface IFastBridgeRecipient . - Introduced method fastBridgeTransferReceived with parameters for handling token transfers. |
packages/contracts-rfq/contracts/interfaces/IFastBridgeV2.sol |
- Updated BridgeParamsV2 and BridgeTransactionV2 structs to include callParams . |
packages/contracts-rfq/contracts/interfaces/IFastBridgeV2Errors.sol |
- Added new error declarations: CallParamsLengthAboveMax , RecipientIncorrectReturnValue , RecipientNoReturnValue . |
packages/contracts-rfq/test/FastBridgeV2.Dst.ArbitraryCall.t.sol |
- Added contract FastBridgeV2DstArbitraryCallTest for testing various recipient behaviors with callParams . |
packages/contracts-rfq/test/FastBridgeV2.GasBench.Dst.Excl.t.sol |
- Modified createFixturesV2 to include callParams in BridgeParamsV2 . |
packages/contracts-rfq/test/FastBridgeV2.Src.ArbitraryCall.t.sol |
- Introduced FastBridgeV2SrcArbitraryCallTest for testing callParams behavior and constraints. |
packages/contracts-rfq/test/FastBridgeV2.Src.Exclusivity.t.sol |
- Refactored createFixturesV2 to utilize setTokenTestExclusivityParams and setEthTestExclusivityParams for setting parameters. |
packages/contracts-rfq/test/FastBridgeV2.t.sol |
- Updated createFixturesV2 to initialize BridgeParamsV2 with callParams . |
packages/contracts-rfq/test/mocks/ExcessiveReturnValueRecipient.sol |
- Added mock contract to simulate excessive return values in recipient behavior. |
packages/contracts-rfq/test/mocks/IncorrectReturnValueRecipient.sol |
- Added mock contract to simulate incorrect return values in recipient behavior. |
packages/contracts-rfq/test/mocks/NoOpContract.sol |
- Introduced a mock contract that accepts ETH without additional logic. |
packages/contracts-rfq/test/mocks/NoReturnValueRecipient.sol |
- Added mock contract that simulates a recipient that does not return a value. |
packages/contracts-rfq/test/mocks/NonPayableRecipient.sol |
- Introduced mock contract that simulates a non-payable recipient. |
packages/contracts-rfq/test/mocks/RecipientMock.sol |
- Added mock contract implementing IFastBridgeRecipient for testing transfers. |
FastBridgeV2
contract by adding new fields for relayer exclusivity, which directly relates to the modifications made in the FastBridgeV2
contract in this PR.FastBridgeV2
contract to store detailed relay transaction information, which complements the enhancements made in the main PR regarding relayer functionalities.bridge()
function aligns with the changes made in the main PR, enhancing the contract's functionality.needs-go-generate-services/rfq
, javascript
, Sol
, Typescript
In the meadow, where bunnies play,
FastBridgeV2 hops in a new way.
With callParams, it leaps so high,
Handling tokens that flutter and fly.
Errors caught with a gentle grace,
In our code, we find our place! πβ¨
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?
Generated at commit: 60adda7d462c4d242c1494eb5f29a663598f37d2, compared to commit: 74e16906f3563e8592da5f88364ca51b532aaa4b
Contract | Method | Avg (+/-) | % |
---|---|---|---|
FastBridgeV2 | bridgeProofs bridgeRelayDetails claim(bytes) claim(bytes,address) getBridgeTransactionV2 protocolFees refund |
-22 β
+111 β +1,175 β +1,197 β +1,101 β -22 β +1,175 β |
-3.41% +17.54% +2.34% +2.31% +35.37% -1.92% +2.34% |
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 90.78014%. Comparing base (
ad48cb0
) to head (02ba663
). Report is 37 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Latest commit: |
02ba663
|
Status: | β Deploy successful! |
Preview URL: | https://fc715868.sanguine-fe.pages.dev |
Branch Preview URL: | https://feat-fbv2-arbitrary-call.sanguine-fe.pages.dev |
Bundle size has no change :white_check_mark:
Description This is the first of the two PRs for the "Arbitrary Call" (final name pending) feature. The first PR adds the option to invoke a special function hook once the tokens have been transferred to the recipient:
https://github.com/synapsecns/sanguine/blob/ad7044902e50154faac6022df7d6eae756c699db/packages/contracts-rfq/contracts/interfaces/IFastBridgeRecipient.sol#L4-L13
The origin sender is given an option to provide
callParams
when initiating a bridge on the source chain.callParams
is non-empty,destRecipient.fastBridgeTransferReceived()
function is called after the tokens are transferred to the recipientmsg.value
for the hook function call to avoid calling the recipient twice.The transactions with a hook function call will revert in one of these cases (this does not affect the legacy transactions):
fastBridgeTransferReceived
function, or doesn't return the magic value (the hook function selector) at the end of the callfastBridgeTransferReceived
callThe reverts do not put Relayer or Recipient funds at risk, in fact the transaction is only completed if the tokens are transferred to the recipient AND the hook call is successful (as reported by the recipient itself using the magic return value). The relayers are expected to simulate the transaction prior its submission to minimise the chances of the on-chain reverts.
Summary by CodeRabbit
New Features
FastBridgeV2
contract to support additional call parameters during bridge transactions.IFastBridgeRecipient
for handling token transfer receipts.Bug Fixes
Tests