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

fix(contracts): make releaseValueToRecipient internal #4989

Merged
merged 4 commits into from
Dec 13, 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
5 changes: 5 additions & 0 deletions .changeset/nine-eyes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperlane-xyz/core': minor
---

Made releaseValueToRecipient internal
32 changes: 16 additions & 16 deletions solidity/contracts/isms/hook/AbstractMessageIdAuthorizedIsm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,35 +78,20 @@
) external virtual returns (bool) {
bool verified = isVerified(message);
if (verified) {
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
}
return verified;
}

// ============ Public Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function releaseValueToRecipient(bytes calldata message) public {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if a message is verified through preVerifyMessage first.
* @param message Message to check.
*/
function isVerified(bytes calldata message) public view returns (bool) {
bytes32 messageId = message.id();

Check notice

Code scanning / Olympix Integrated Security

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables Low

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables
// check for the first bit (used for verification)

Check notice

Code scanning / Olympix Integrated Security

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables Low

Local variables in test functions are not properly fuzzed, potentially reducing the effectiveness of property-based testing. For more information, visit: http://detectors.olympixdevsectools.com/article/web3-vulnerability/unfuzzed-local-variables
return verifiedMessages[messageId].isBitSet(VERIFIED_MASK_INDEX);
}

Expand Down Expand Up @@ -138,6 +123,21 @@

// ============ Internal Functions ============

/**
* @notice Release the value to the recipient if the message is verified.
* @param message Message to release value for.
*/
function _releaseValueToRecipient(bytes calldata message) internal {
bytes32 messageId = message.id();
uint256 _msgValue = verifiedMessages[messageId].clearBit(
VERIFIED_MASK_INDEX
);
if (_msgValue > 0) {
verifiedMessages[messageId] -= _msgValue;
payable(message.recipientAddress()).sendValue(_msgValue);
}
}

/**
* @notice Check if sender is authorized to message `preVerifyMessage`.
*/
Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/ArbL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract ArbL2ToL1Ism is
_verifyWithOutboxCall(metadata, message);
require(isVerified(message), "ArbL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion solidity/contracts/isms/hook/OPL2ToL1Ism.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ contract OPL2ToL1Ism is
_verifyWithPortalCall(metadata, message);
require(isVerified(message), "OPL2ToL1Ism: message not verified");
}
releaseValueToRecipient(message);
_releaseValueToRecipient(message);
return true;
}

Expand Down
Loading