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/fb v2 sender nonce [SLT-183] #3212

Closed
wants to merge 2 commits into from
Closed
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 @@ -28,9 +28,8 @@
mapping(bytes32 => BridgeTxDetails) public bridgeTxDetails;
/// @notice Relay details on destination chain
mapping(bytes32 => BridgeRelay) public bridgeRelayDetails;

/// @dev to prevent replays
uint256 public nonce;
/// @notice Unique bridge nonces tracked per originSender
mapping(address => uint256) public senderNonces;

// @dev the block the contract was deployed at
uint256 public immutable deployBlock;
Expand Down Expand Up @@ -71,7 +70,7 @@
originFeeAmount: originFeeAmount,
sendChainGas: params.sendChainGas,
deadline: params.deadline,
nonce: nonce++ // increment nonce on every bridge
nonce: senderNonces[params.sender]++ // increment nonce on every bridge
})
);
bytes32 transactionId = keccak256(request);
Expand Down Expand Up @@ -156,6 +155,12 @@
return _timeSince(bridgeTxDetails[transactionId].proofBlockTimestamp) > DISPUTE_PERIOD;
}

/// @notice This function is deprecated and should not be used.
/// @dev Replaced by senderNonces
function nonce() external pure returns (uint256) {
return 0;

Check warning on line 161 in packages/contracts-rfq/contracts/FastBridgeV2.sol

View check run for this annotation

Codecov / codecov/patch

packages/contracts-rfq/contracts/FastBridgeV2.sol#L161

Added line #L161 was not covered by tests
}

parodime marked this conversation as resolved.
Show resolved Hide resolved
/// @inheritdoc IFastBridgeV2
function relay(bytes memory request, address relayer) public payable {
if (relayer == address(0)) revert ZeroAddress();
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts-rfq/test/FastBridgeV2.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,18 @@ contract FastBridgeV2SrcTest is FastBridgeV2SrcBaseTest {
}

function test_bridge_userSpecificNonce() public {
vm.skip(true); // TODO: unskip when implemented
bridge({caller: userA, msgValue: 0, params: tokenParams});
assertEq(fastBridge.senderNonces(userA), 1);
assertEq(fastBridge.senderNonces(userB), 0);
// UserB nonce is 0
ethTx.nonce = 0;
ethParams.sender = userB;
ethTx.originSender = userB;
bytes32 txId = getTxId(ethTx);
expectBridgeRequested(ethTx, txId);
bridge({caller: userB, msgValue: ethParams.originAmount, params: ethParams});
assertEq(fastBridge.senderNonces(userA), 1);
assertEq(fastBridge.senderNonces(userB), 1);
assertEq(fastBridge.bridgeStatuses(txId), IFastBridgeV2.BridgeStatus.REQUESTED);
checkEthBalancesAfterBridge(userB);
}
Expand Down
Loading