Skip to content

Commit

Permalink
Add whenNotPaused modifier to ArbitrationPolicyUMA.sol (#318)
Browse files Browse the repository at this point in the history
* add whenNotPaused to arbitration policy UMA

* lint fix
  • Loading branch information
Spablob authored Nov 28, 2024
1 parent c340938 commit 58467f6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract ArbitrationPolicyUMA is
/// @dev Enforced to be only callable by the DisputeModule
/// @param caller Address of the caller
/// @param data The arbitrary data used to raise the dispute
function onRaiseDispute(address caller, bytes calldata data) external onlyDisputeModule nonReentrant {
function onRaiseDispute(address caller, bytes calldata data) external onlyDisputeModule nonReentrant whenNotPaused {
(bytes memory claim, uint64 liveness, address currency, uint256 bond, bytes32 identifier) = abi.decode(
data,
(bytes, uint64, address, uint256, bytes32)
Expand Down Expand Up @@ -185,7 +185,7 @@ contract ArbitrationPolicyUMA is
/// @notice Allows the IP that was targeted to dispute the assertion while providing counter evidence
/// @param assertionId The identifier of the assertion that was disputed
/// @param counterEvidenceHash The hash of the counter evidence
function disputeAssertion(bytes32 assertionId, bytes32 counterEvidenceHash) external nonReentrant {
function disputeAssertion(bytes32 assertionId, bytes32 counterEvidenceHash) external nonReentrant whenNotPaused {
if (counterEvidenceHash == bytes32(0)) revert Errors.ArbitrationPolicyUMA__NoCounterEvidence();

ArbitrationPolicyUMAStorage storage $ = _getArbitrationPolicyUMAStorage();
Expand Down Expand Up @@ -226,7 +226,10 @@ contract ArbitrationPolicyUMA is
/// @notice OOV3 callback function forwhen an assertion is resolved
/// @param assertionId The resolved assertion identifier
/// @param assertedTruthfully Indicates if the assertion was resolved as truthful or not
function assertionResolvedCallback(bytes32 assertionId, bool assertedTruthfully) external nonReentrant {
function assertionResolvedCallback(
bytes32 assertionId,
bool assertedTruthfully
) external nonReentrant whenNotPaused {
ArbitrationPolicyUMAStorage storage $ = _getArbitrationPolicyUMAStorage();
if (msg.sender != address($.oov3)) revert Errors.ArbitrationPolicyUMA__NotOOV3();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity 0.8.26;

import { AccessManager } from "@openzeppelin/contracts/access/manager/AccessManager.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";

import { DisputeModule } from "contracts/modules/dispute/DisputeModule.sol";
import { ArbitrationPolicyUMA } from "contracts/modules/dispute/policies/UMA/ArbitrationPolicyUMA.sol";
Expand Down Expand Up @@ -152,6 +153,21 @@ contract ArbitrationPolicyUMATest is BaseTest {
assertEq(newArbitrationPolicyUMA.ipOwnerTimePercent(), 10);
}

function test_ArbitrationPolicyUMA_onRaiseDispute_revert_paused() public {
newArbitrationPolicyUMA.pause();

bytes memory claim = "test claim";
uint64 liveness = 1;
IERC20 currency = IERC20(susd);
uint256 bond = 0;
bytes32 identifier = bytes32("ASSERT_TRUTH");

bytes memory data = abi.encode(claim, liveness, currency, bond, identifier);

vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector));
newDisputeModule.raiseDispute(address(1), disputeEvidenceHashExample, "IMPROPER_REGISTRATION", data);
}

function test_ArbitrationPolicyUMA_onRaiseDispute_revert_LivenessBelowMin() public {
bytes memory claim = "test claim";
uint64 liveness = 1;
Expand Down Expand Up @@ -438,6 +454,33 @@ contract ArbitrationPolicyUMATest is BaseTest {
assertEq(currentTagAfter, bytes32("IMPROPER_REGISTRATION"));
}

function test_ArbitrationPolicyUMA_disputeAssertion_revert_paused() public {
bytes memory claim = "test claim";
uint64 liveness = 3600 * 24 * 30;
IERC20 currency = IERC20(susd);
uint256 bond = 0;
bytes32 identifier = bytes32("ASSERT_TRUTH");
bytes memory data = abi.encode(claim, liveness, currency, bond, identifier);

address targetIpId = address(1);
uint256 disputeId = newDisputeModule.raiseDispute(
targetIpId,
disputeEvidenceHashExample,
"IMPROPER_REGISTRATION",
data
);

newArbitrationPolicyUMA.pause();

// dispute the assertion
vm.startPrank(targetIpId);
bytes32 assertionId = newArbitrationPolicyUMA.disputeIdToAssertionId(disputeId);
bytes32 counterEvidenceHash = bytes32("COUNTER_EVIDENCE_HASH");

vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector));
newArbitrationPolicyUMA.disputeAssertion(assertionId, counterEvidenceHash);
}

function test_ArbitrationPolicyUMA_disputeAssertion_revert_CannotDisputeAssertionTwice() public {
bytes memory claim = "test claim";
uint64 liveness = 3600 * 24 * 30;
Expand Down Expand Up @@ -754,8 +797,10 @@ contract ArbitrationPolicyUMATest is BaseTest {
assertEq(defenderIpIdOwnerBalAfter - defenderIpIdOwnerBalBefore, bondRecipientAmount);
}

function test_ArbitrationPolicyUMA_assertionResolvedCallback_revert_NotOOV3() public {
vm.expectRevert(Errors.ArbitrationPolicyUMA__NotOOV3.selector);
function test_ArbitrationPolicyUMA_assertionResolvedCallback_revert_paused() public {
newArbitrationPolicyUMA.pause();

vm.expectRevert(abi.encodeWithSelector(PausableUpgradeable.EnforcedPause.selector));
newArbitrationPolicyUMA.assertionResolvedCallback(bytes32(0), false);
}

Expand Down

0 comments on commit 58467f6

Please sign in to comment.