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(contracts-rfq): save destination chain ID for requested bridges [SLT-423] #3356

Merged
merged 4 commits into from
Nov 4, 2024
Merged
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
20 changes: 10 additions & 10 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
// Aggregate the read operations from the same storage slot
address disputedRelayer = $.proofRelayer;
BridgeStatus status = $.status;
uint40 proofBlockTimestamp = $.proofBlockTimestamp;
uint56 proofBlockTimestamp = $.proofBlockTimestamp;
// Can only dispute a RELAYER_PROVED transaction within the dispute period
if (status != BridgeStatus.RELAYER_PROVED) revert StatusIncorrect();
if (_timeSince(proofBlockTimestamp) > DISPUTE_PERIOD) {
@@ -100,7 +100,6 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
$.status = BridgeStatus.REQUESTED;
$.proofRelayer = address(0);
$.proofBlockTimestamp = 0;
$.proofBlockNumber = 0;

emit BridgeProofDisputed(transactionId, disputedRelayer);
}
@@ -221,7 +220,9 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
})
);
bytes32 transactionId = keccak256(request);
// Note: the tx status will be updated throughout the tx lifecycle, while destChainId is set once here
bridgeTxDetails[transactionId].status = BridgeStatus.REQUESTED;
bridgeTxDetails[transactionId].destChainId = params.dstChainId;

emit BridgeRequested({
transactionId: transactionId,
@@ -313,8 +314,7 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
// Update status to RELAYER_PROVED and store the proof details
// Note: these are storage writes
$.status = BridgeStatus.RELAYER_PROVED;
$.proofBlockTimestamp = uint40(block.timestamp);
$.proofBlockNumber = uint48(block.number);
$.proofBlockTimestamp = uint56(block.timestamp);
$.proofRelayer = relayer;

emit BridgeProofProvided(transactionId, relayer, destTxHash);
@@ -328,7 +328,7 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
// Aggregate the read operations from the same storage slot
address proofRelayer = $.proofRelayer;
BridgeStatus status = $.status;
uint40 proofBlockTimestamp = $.proofBlockTimestamp;
uint56 proofBlockTimestamp = $.proofBlockTimestamp;

// Can only claim a RELAYER_PROVED transaction after the dispute period
if (status != BridgeStatus.RELAYER_PROVED) revert StatusIncorrect();
@@ -425,14 +425,14 @@ contract FastBridgeV2 is Admin, MulticallTarget, IFastBridgeV2, IFastBridgeV2Err
}

/// @notice Calculates time since proof submitted
/// @dev proof.timestamp stores casted uint40(block.timestamp) block timestamps for gas optimization
/// _timeSince(proof) can accomodate rollover case when block.timestamp > type(uint40).max but
/// proof.timestamp < type(uint40).max via unchecked statement
/// @dev proof.timestamp stores casted uint56(block.timestamp) block timestamps for gas optimization
/// _timeSince(proof) can accomodate rollover case when block.timestamp > type(uint56).max but
/// proof.timestamp < type(uint56).max via unchecked statement
/// @param proofBlockTimestamp The bridge proof block timestamp
/// @return delta Time delta since proof submitted
function _timeSince(uint40 proofBlockTimestamp) internal view returns (uint256 delta) {
function _timeSince(uint56 proofBlockTimestamp) internal view returns (uint256 delta) {
unchecked {
delta = uint40(block.timestamp) - proofBlockTimestamp;
delta = uint56(block.timestamp) - proofBlockTimestamp;
}
}

Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ interface IFastBridgeV2 is IFastBridge {

struct BridgeTxDetails {
ChiTimesChi marked this conversation as resolved.
Show resolved Hide resolved
BridgeStatus status;
uint40 proofBlockTimestamp;
uint48 proofBlockNumber;
uint32 destChainId;
uint56 proofBlockTimestamp;
address proofRelayer;
}

Loading
Loading