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

exclusivityEndtime default 0 [SLT-391] #3336

Merged
merged 6 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {

/// @inheritdoc IFastBridgeV2
function bridge(BridgeParams memory params, BridgeParamsV2 memory paramsV2) public payable {
int256 exclusivityEndTime = int256(block.timestamp) + paramsV2.quoteExclusivitySeconds;
int256 exclusivityEndTime = 0;
// if relayer exclusivity is not intended for this bridge, set exclusivityEndTime to static zero
// otherwise, set exclusivity to expire at the current block ts offset by quoteExclusivitySeconds
if (paramsV2.quoteRelayer != address(0)) {
exclusivityEndTime = int256(block.timestamp) + paramsV2.quoteExclusivitySeconds;
}
_validateBridgeParams(params, paramsV2, exclusivityEndTime);

// transfer tokens to bridge contract
Expand Down Expand Up @@ -206,7 +211,7 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
deadline: params.deadline,
nonce: senderNonces[params.sender]++, // increment nonce on every bridge
exclusivityRelayer: paramsV2.quoteRelayer,
// We checked exclusivityEndTime to be in range (0 .. params.deadline] above, so can safely cast
// We checked exclusivityEndTime to be in range [0 .. params.deadline] above, so can safely cast
exclusivityEndTime: uint256(exclusivityEndTime),
callValue: paramsV2.callValue,
callParams: paramsV2.callParams
Expand Down Expand Up @@ -443,8 +448,8 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
if (paramsV2.callValue != 0 && params.destToken == UniversalTokenLib.ETH_ADDRESS) {
revert NativeTokenCallValueNotSupported();
}
// exclusivityEndTime must be in range (0 .. params.deadline]
if (exclusivityEndTime <= 0 || exclusivityEndTime > int256(params.deadline)) {
// exclusivityEndTime must be in range [0 .. params.deadline]
if (exclusivityEndTime < 0 || exclusivityEndTime > int256(params.deadline)) {
parodime marked this conversation as resolved.
Show resolved Hide resolved
revert ExclusivityParamsIncorrect();
}
}
Expand Down
11 changes: 0 additions & 11 deletions packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
ethTx.nonce = 5;
}

function createFixturesV2() public virtual override {
super.createFixturesV2();
bridgedTokenTx.exclusivityEndTime = block.timestamp;
provenTokenTx.exclusivityEndTime = block.timestamp;
bridgedEthTx.exclusivityEndTime = block.timestamp;
provenEthTx.exclusivityEndTime = block.timestamp;
// Actual tx will be submitted one block later
tokenTx.exclusivityEndTime = block.timestamp + BLOCK_TIME;
ethTx.exclusivityEndTime = block.timestamp + BLOCK_TIME;
}

function mintTokens() public virtual override {
super.mintTokens();
srcToken.mint(relayerA, INITIAL_RELAYER_BALANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ contract FastBridgeV2SrcExclusivityNegativeTest is FastBridgeV2SrcTest {
bridge(caller, msgValue, params, paramsV2);
}

function test_bridge_revert_exclusivityEndTimeZero() public {
function test_bridge_exclusivityEndTimeZero() public {
tokenParamsV2.quoteExclusivitySeconds = -int256(block.timestamp);
vm.expectRevert(ExclusivityParamsIncorrect.selector);
bridge({caller: userA, msgValue: 0, params: tokenParams, paramsV2: tokenParamsV2});
}

Expand All @@ -35,9 +34,8 @@ contract FastBridgeV2SrcExclusivityNegativeTest is FastBridgeV2SrcTest {
bridge({caller: userA, msgValue: 0, params: tokenParams, paramsV2: tokenParamsV2});
}

function test_bridge_eth_revert_exclusivityEndTimeZero() public {
function test_bridge_eth_exclusivityEndTimeZero() public {
ethParamsV2.quoteExclusivitySeconds = -int256(block.timestamp);
vm.expectRevert(ExclusivityParamsIncorrect.selector);
bridge({caller: userA, msgValue: ethParams.originAmount, params: ethParams, paramsV2: ethParamsV2});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-rfq/test/FastBridgeV2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ abstract contract FastBridgeV2Test is Test, IFastBridgeV2Errors {
});

tokenTx.exclusivityRelayer = address(0);
tokenTx.exclusivityEndTime = block.timestamp;
tokenTx.exclusivityEndTime = 0;
ethTx.exclusivityRelayer = address(0);
ethTx.exclusivityEndTime = block.timestamp;
ethTx.exclusivityEndTime = 0;
}

function setStorageBridgeTxV2(
Expand Down
Loading