Skip to content

Commit

Permalink
chore: resolving TODOs, adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed May 13, 2024
1 parent df5966b commit c00a2e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions contracts/multisigs/GuardCM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,11 @@ contract GuardCM is VerifyData {
/// @dev Sets bridge mediator and L2 verifier contracts addresses on L1 and L2 chain Ids.
/// @notice It is the contract owner responsibility to set correct L1 bridge mediator contracts,
/// corresponding L2 verifier contracts, and supported chain Ids.
/// Note that it is out of scope of the verification procedure to check if any other chain Id formats,
/// like Wormhole one, is correctly setup during the bridge call.
/// @param bridgeMediatorL1s Bridge mediator contract addresses on L1.
/// @param verifierL2s Corresponding L2 verifier contract addresses on L1.
/// @param chainIds Corresponding L2 chain Ids.
/// @param chainIds Corresponding L2 chain Ids (original EVM numbers).
/// @param bridgeMediatorL2s Corresponding L2 bridge mediators.
function setBridgeMediatorL1BridgeParams(
address[] memory bridgeMediatorL1s,
Expand All @@ -373,7 +375,6 @@ contract GuardCM is VerifyData {
for (uint256 i = 0; i < chainIds.length; ++i) {
// Check for zero addresses
// Note that bridgeMediatorL2-s can be zero addresses, for example, for Arbitrum case
// TODO: make possible bridgeMediatorL1s[i] to be address(0) in order to remove the L2 chain from the list?
if (bridgeMediatorL1s[i] == address(0) || verifierL2s[i] == address(0)) {
revert ZeroAddress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ contract ProcessBridgedDataWormhole is VerifyBridgedData {
// sendPayloadToEvm selector in bridge mediator L1
bytes4 public constant SEND_MESSAGE = bytes4(keccak256(bytes("sendPayloadToEvm(uint16,address,bytes,uint256,uint256)")));
// Minimum payload length for message sent via Wormhole accounting for all required encoding and at least one selector
uint256 public constant MIN_OPTIMISM_PAYLOAD_LENGTH = 324;
uint256 public constant MIN_WORMHOLE_PAYLOAD_LENGTH = 324;

/// @dev Processes bridged data: checks the header and verifies the payload.
/// @notice It is out of scope of the verification procedure to check if the Wormhole format chain Id corresponding
/// to the original EVM chain Id is correctly setup during the bridge call.
/// @param data Full data bytes with the header.
/// @param bridgeMediatorL2 Address of a bridged mediator on L2.
/// @param chainId L2 chain Id.
Expand All @@ -47,8 +49,8 @@ contract ProcessBridgedDataWormhole is VerifyBridgedData {
}

// Check if the data length is less than a size of a selector plus the message minimum payload size
if (data.length < MIN_OPTIMISM_PAYLOAD_LENGTH) {
revert IncorrectDataLength(data.length, MIN_OPTIMISM_PAYLOAD_LENGTH);
if (data.length < MIN_WORMHOLE_PAYLOAD_LENGTH) {
revert IncorrectDataLength(data.length, MIN_WORMHOLE_PAYLOAD_LENGTH);
}

// Copy the data without the selector
Expand Down

0 comments on commit c00a2e1

Please sign in to comment.