-
Notifications
You must be signed in to change notification settings - Fork 5
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
refactor and test: addressing internal audit and adding full coverage #124
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,14 @@ abstract contract VerifyData { | |
// target occupies first 160 bits | ||
uint256 targetSelectorChainId = uint256(uint160(target)); | ||
// selector occupies next 32 bits | ||
targetSelectorChainId |= uint256(uint32(bytes4(data))) << 160; | ||
bytes4 targetSelector = bytes4(data); | ||
targetSelectorChainId |= uint256(uint32(targetSelector)) << 160; | ||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small code optimization |
||
// chainId occupies next 64 bits | ||
targetSelectorChainId |= chainId << 192; | ||
|
||
// Check the authorized combination of target and selector | ||
if (!mapAllowedTargetSelectorChainIds[targetSelectorChainId]) { | ||
revert NotAuthorized(target, bytes4(data), chainId); | ||
revert NotAuthorized(target, targetSelector, chainId); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,22 +13,17 @@ error IncorrectDataLength(uint256 expected, uint256 provided); | |
/// @param chainId Chain Id. | ||
error WrongSelector(bytes4 functionSig, uint256 chainId); | ||
|
||
/// @dev Provided wrong L2 bridge mediator address. | ||
/// @param provided Provided address. | ||
/// @param expected Expected address. | ||
error WrongL2BridgeMediator(address provided, address expected); | ||
|
||
/// @title ProcessBridgedDataArbitrum - Smart contract for verifying the Guard CM bridged data on Arbitrum | ||
/// @author Aleksandr Kuperman - <[email protected]> | ||
/// @author Andrey Lebedev - <[email protected]> | ||
/// @author Mariapia Moscatiello - <[email protected]> | ||
contract ProcessBridgedDataArbitrum is VerifyBridgedData { | ||
// unsafeCreateRetryableTicket selector in bridge mediator L1 | ||
bytes4 public constant CREATE_TICKET_UNSAFE = bytes4(keccak256(bytes("unsafeCreateRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,uint256,bytes)"))); | ||
bytes4 public constant CREATE_TICKET_UNSAFE = bytes4(keccak256(bytes("unsafeCreateRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)"))); | ||
Comment on lines
-27
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bugs here and there ;) |
||
// createRetryableTicket selector in bridge mediator L1 | ||
bytes4 public constant CREATE_TICKET = bytes4(keccak256(bytes("createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,uint256,bytes)"))); | ||
bytes4 public constant CREATE_TICKET = bytes4(keccak256(bytes("createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)"))); | ||
// Minimum payload length for message on Arbitrum accounting for all required encoding and at least one selector | ||
uint256 public constant MIN_ARBITRUM_PAYLOAD_LENGTH = 584; | ||
uint256 public constant MIN_ARBITRUM_PAYLOAD_LENGTH = 324; | ||
|
||
/// @dev Processes bridged data: checks the header and verifies the payload. | ||
/// @param data Full data bytes with the header. | ||
|
@@ -57,8 +52,8 @@ contract ProcessBridgedDataArbitrum is VerifyBridgedData { | |
} | ||
|
||
// Decode the payload depending on the selector | ||
(address targetAddress, , , , , , , , bytes memory targetPayload) = | ||
abi.decode(payload, (address, uint256, uint256, address, address, uint256, uint256, uint256, bytes)); | ||
(address targetAddress, , , , , , , bytes memory targetPayload) = | ||
abi.decode(payload, (address, uint256, uint256, address, address, uint256, uint256, bytes)); | ||
|
||
// Verify the scope of the data | ||
_verifyData(targetAddress, targetPayload, chainId); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking that the L2 verifier is a contract