-
Notifications
You must be signed in to change notification settings - Fork 33
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: Zellic-3.3 (safety checks missing) #1462
Conversation
- remoteSlashAgent from the same domain
WalkthroughThe changes primarily focus on introducing new checks to prevent messages from being sent or executed within the same domain. This is achieved by adding new exceptions, Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- packages/contracts-core/contracts/manager/BondingManager.sol (2 hunks)
- packages/contracts-core/test/suite/manager/BondingManager.t.sol (2 hunks)
Additional comments (Suppressed): 5
packages/contracts-core/contracts/manager/BondingManager.sol (2)
11-11: The new error
IncorrectOriginDomain
has been added. Ensure that this error is properly handled in all places where it can be thrown.172-178: The check for the origin of the message has been added. This is a security enhancement that prevents an agent from being slashed from the local domain. The change looks good, but make sure to update any relevant documentation or comments to reflect this new behavior.
- // TODO: do we need to save this? - msgOrigin; + // Message needs to be sent from the remote chain + if (msgOrigin == localDomain) revert IncorrectOriginDomain();packages/contracts-core/test/suite/manager/BondingManager.t.sol (3)
9-15: The new error
IncorrectOriginDomain
has been imported fromErrors.sol
. Ensure that this error is defined and implemented correctly inErrors.sol
.252-258: A new test
test_remoteSlashAgent_revert_sameOriginDomain
has been added. This test checks if theIncorrectOriginDomain
error is thrown when the origin of a message is the local domain. The test seems to be correctly implemented.260-262: The function
test_completeSlashing_active
has been modified. Ensure that the changes in the function signature are reflected wherever this function is called.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1462 +/- ##
===================================================
+ Coverage 50.44029% 50.44437% +0.00408%
===================================================
Files 356 356
Lines 24302 24304 +2
Branches 269 271 +2
===================================================
+ Hits 12258 12260 +2
Misses 10863 10863
Partials 1181 1181
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
- `execute` sent from the same domain
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.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- packages/contracts-core/contracts/hubs/ExecutionHub.sol (2 hunks)
- packages/contracts-core/test/suite/hubs/ExecutionHub.t.sol (2 hunks)
Additional comments (Suppressed): 4
packages/contracts-core/test/suite/hubs/ExecutionHub.t.sol (2)
7-13: The new exception
IncorrectOriginDomain
has been added to the list of exceptions. This is in line with the changes described in the PR summary.330-343: A new test case
test_execute_base_revert_originSameDomain
has been added. This test case checks if the contract correctly throws theIncorrectOriginDomain
exception when the origin and destination domains are the same. The test case seems to be correctly set up and should work as expected.packages/contracts-core/contracts/hubs/ExecutionHub.sol (2)
15-18: The new exception
IncorrectOriginDomain
has been added to handle cases where the origin and destination domains are the same. This is a good addition for safety checks.122-129: The check for the origin of the message has been added. If the origin is the same as the local domain, the function will revert with the
IncorrectOriginDomain
error. This is a good security measure to prevent execution of messages originating from the local domain.+ // Ensure message was not sent from this domain + if (header.origin() == localDomain) revert IncorrectOriginDomain();
- Sending base message to the same domain - Sending manager message to the same domain
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.
Review Status
Actionable comments generated: 0
Files selected for processing (5)
- packages/contracts-core/contracts/Origin.sol (4 hunks)
- packages/contracts-core/contracts/interfaces/IExecutionHub.sol (1 hunks)
- packages/contracts-core/contracts/interfaces/InterfaceBondingManager.sol (1 hunks)
- packages/contracts-core/contracts/interfaces/InterfaceOrigin.sol (2 hunks)
- packages/contracts-core/test/suite/Origin.t.sol (2 hunks)
Files skipped from review due to trivial changes (2)
- packages/contracts-core/contracts/interfaces/IExecutionHub.sol
- packages/contracts-core/contracts/interfaces/InterfaceBondingManager.sol
Additional comments (Suppressed): 9
packages/contracts-core/contracts/interfaces/InterfaceOrigin.sol (2)
7-16: The new conditions for revert in the
sendBaseMessage
function are well documented. Ensure that these conditions are properly handled in the implementation of this function and that all calls to this function throughout the codebase are updated to match these conditions.33-39: The new revert condition in the
sendManagerMessage
function is well documented. Ensure that this condition is properly handled in the implementation of this function and that all calls to this function throughout the codebase are updated to match this condition.packages/contracts-core/contracts/Origin.sol (4)
4-15: The new hunk introduces the
IncorrectDestinationDomain
error from theErrors.sol
library. This error is used to handle cases where the destination domain is the local domain, which is not allowed in the updated contract. This is a good addition for error handling and improves the robustness of the contract.40-46: The
onlyRemoteDestination
modifier is introduced to check if the destination domain is not the local domain. If it is, it reverts the transaction with anIncorrectDestinationDomain
error. This is a good practice to encapsulate this logic in a modifier for reusability and readability.73-79: The
sendMessage
function now includes theonlyRemoteDestination
modifier to ensure that the destination is not the local domain. This is a good practice to prevent messages from being sent to the local domain. However, ensure that all calls to this function throughout the codebase have been updated to match the new function signature.95-101: The
sendManagerMessage
function now includes theonlyRemoteDestination
modifier to ensure that the destination is not the local domain. This is a good practice to prevent manager messages from being sent to the local domain. However, ensure that all calls to this function throughout the codebase have been updated to match the new function signature.packages/contracts-core/test/suite/Origin.t.sol (3)
4-15: The new hunk introduces the
IncorrectDestinationDomain
error from theErrors.sol
library. This error is used in the new test cases to verify that thesendBaseMessage
andsendManagerMessage
functions in theOrigin
contract correctly prevent messages from being sent to the local domain.106-112: This new test case,
test_sendBaseMessage_revert_sameDestination
, checks if thesendBaseMessage
function in theOrigin
contract correctly throws theIncorrectDestinationDomain
error when the destination is the local domain. Thevm.expectRevert
function is used to expect theIncorrectDestinationDomain
error, and thevm.prank
function is used to set the sender of the transaction.114-118: This new test case,
test_sendManagementMessage_revert_sameDestination
, checks if thesendManagerMessage
function in theOrigin
contract correctly throws theIncorrectDestinationDomain
error when the destination is the local domain. Thevm.expectRevert
function is used to expect theIncorrectDestinationDomain
error, and thevm.prank
function is used to set the sender of the transaction.
Description
BondingManager.remoteSlashAgent()
andDestination.execute()
Origin
Summary by CodeRabbit