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 3 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
7 changes: 5 additions & 2 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ 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 = paramsV2.quoteRelayer != address(0)
// prettier-ignore
? int256(block.timestamp) + paramsV2.quoteExclusivitySeconds
: int256(0);
ChiTimesChi marked this conversation as resolved.
Show resolved Hide resolved
_validateBridgeParams(params, paramsV2, exclusivityEndTime);

// transfer tokens to bridge contract
Expand Down Expand Up @@ -444,7 +447,7 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
revert NativeTokenCallValueNotSupported();
}
// exclusivityEndTime must be in range (0 .. params.deadline]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update the comment here to reflect that the range now includes zero.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually thought it was incorrect before (0 was not technically in range before, but was specified in the comment) - but now happens to be accurate & left it alone.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parodime I meant purely in terms of the exclusive/inclusive range notation: (0 .. X] vs [0 .. X]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm blind - thanks

if (exclusivityEndTime <= 0 || exclusivityEndTime > int256(params.deadline)) {
if (exclusivityEndTime < 0 || exclusivityEndTime > int256(params.deadline)) {
parodime marked this conversation as resolved.
Show resolved Hide resolved
revert ExclusivityParamsIncorrect();
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {

function createFixturesV2() public virtual override {
ChiTimesChi marked this conversation as resolved.
Show resolved Hide resolved
super.createFixturesV2();
bridgedTokenTx.exclusivityEndTime = block.timestamp;
provenTokenTx.exclusivityEndTime = block.timestamp;
bridgedEthTx.exclusivityEndTime = block.timestamp;
provenEthTx.exclusivityEndTime = block.timestamp;
bridgedTokenTx.exclusivityEndTime = 0;
provenTokenTx.exclusivityEndTime = 0;
bridgedEthTx.exclusivityEndTime = 0;
provenEthTx.exclusivityEndTime = 0;
// Actual tx will be submitted one block later
tokenTx.exclusivityEndTime = block.timestamp + BLOCK_TIME;
ethTx.exclusivityEndTime = block.timestamp + BLOCK_TIME;
tokenTx.exclusivityEndTime = 0;
ethTx.exclusivityEndTime = 0;
}

function mintTokens() public virtual override {
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