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: Zellic-3.3 (safety checks missing) #1462

Merged
merged 8 commits into from
Oct 23, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
CallerNotDestination,
CallerNotSummit,
IncorrectAgentDomain,
IncorrectOriginDomain,
IndexOutOfRange,
MerkleTreeFull,
MustBeSynapseDomain,
Expand Down Expand Up @@ -171,8 +172,9 @@ contract BondingManager is AgentManager, InterfaceBondingManager {
// Check that merkle proof is mature enough
// TODO: separate constant for slashing optimistic period
if (proofMaturity < BONDING_OPTIMISTIC_PERIOD) revert SlashAgentOptimisticPeriod();
// TODO: do we need to save this?
msgOrigin;
// TODO: do we need to save domain where the agent was slashed?
// Message needs to be sent from the remote chain
if (msgOrigin == localDomain) revert IncorrectOriginDomain();
// Slash agent and notify local AgentSecured contracts
_slashAgent(domain, agent, prover);
// Magic value to return is selector of the called function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AgentNotUnstaking,
CallerNotSummit,
MustBeSynapseDomain,
IncorrectOriginDomain,
SlashAgentOptimisticPeriod,
SynapseDomainForbidden
} from "../../../contracts/libs/Errors.sol";
Expand Down Expand Up @@ -248,6 +249,14 @@ contract BondingManagerTest is AgentManagerTest {
managerMsgPrank(msgPayload);
}

function test_remoteSlashAgent_revert_sameOriginDomain() public {
uint32 proofMaturity = BONDING_OPTIMISTIC_PERIOD;
skip(proofMaturity);
bytes memory msgPayload = managerMsgPayload(DOMAIN_SYNAPSE, remoteSlashAgentCalldata(0, address(0), address(0)));
vm.expectRevert(IncorrectOriginDomain.selector);
managerMsgPrank(msgPayload);
}

function test_completeSlashing_active(uint256 domainId, uint256 agentId, address slasher) public {
(uint32 domain, address agent) = getAgent(domainId, agentId);
// Initiate slashing
Expand Down
Loading