From b56567e49eed99f31e88e99eca31fd3262969778 Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Tue, 20 Aug 2024 18:48:06 -0300 Subject: [PATCH] fix: make fisherman deposit a fixed value (OZ L-01) --- .../contracts/DisputeManager.sol | 75 ++++++++++--------- .../contracts/DisputeManagerStorage.sol | 4 +- .../contracts/interfaces/IDisputeManager.sol | 17 ++--- .../test/SubgraphBaseTest.t.sol | 2 +- .../test/disputes/DisputeManager.t.sol | 18 +++-- .../test/disputes/accept.t.sol | 22 ++---- .../test/disputes/cancel.t.sol | 12 +-- .../test/disputes/create.t.sol | 49 +++++------- .../subgraph-service/test/disputes/draw.t.sol | 12 +-- .../subgraph-service/test/utils/Constants.sol | 2 +- 10 files changed, 94 insertions(+), 119 deletions(-) diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 6d4577153..5ad0d8d56 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -97,14 +97,14 @@ contract DisputeManager is * @notice Initialize this contract. * @param arbitrator Arbitrator role * @param disputePeriod Dispute period in seconds - * @param minimumDeposit Minimum deposit required to create a Dispute + * @param disputeDeposit Deposit required to create a Dispute * @param fishermanRewardCut_ Percent of slashed funds for fisherman (ppm) * @param maxSlashingCut_ Maximum percentage of indexer stake that can be slashed (ppm) */ function initialize( address arbitrator, uint64 disputePeriod, - uint256 minimumDeposit, + uint256 disputeDeposit, uint32 fishermanRewardCut_, uint32 maxSlashingCut_ ) external override initializer { @@ -113,7 +113,7 @@ contract DisputeManager is _setArbitrator(arbitrator); _setDisputePeriod(disputePeriod); - _setMinimumDeposit(minimumDeposit); + _setDisputeDeposit(disputeDeposit); _setFishermanRewardCut(fishermanRewardCut_); _setMaxSlashingCut(maxSlashingCut_); } @@ -122,40 +122,45 @@ contract DisputeManager is * @notice Create an indexing dispute for the arbitrator to resolve. * The disputes are created in reference to an allocationId and specifically * a POI for that allocation. - * This function is called by a challenger that will need to `_deposit` at - * least `minimumDeposit` GRT tokens. + * This function is called by a challenger and it will pull `disputeDeposit` GRT tokens. + * + * Requirements: + * - Challenger must have previously approved this contract to pull `disputeDeposit` amount + * of tokens from their balance. + * * @param allocationId The allocation to dispute * @param poi The Proof of Indexing (POI) being disputed - * @param deposit Amount of tokens staked as deposit */ function createIndexingDispute( address allocationId, - bytes32 poi, - uint256 deposit + bytes32 poi ) external override returns (bytes32) { // Get funds from submitter - _pullSubmitterDeposit(deposit); + _pullSubmitterDeposit(); // Create a dispute - return _createIndexingDisputeWithAllocation(msg.sender, deposit, allocationId, poi); + return _createIndexingDisputeWithAllocation(msg.sender, disputeDeposit, allocationId, poi); } /** * @notice Create a query dispute for the arbitrator to resolve. - * This function is called by a fisherman that will need to `_deposit` at - * least `minimumDeposit` GRT tokens. - * @param attestationData Attestation bytes submitted by the fisherman - * @param deposit Amount of tokens staked as deposit - */ - function createQueryDispute(bytes calldata attestationData, uint256 deposit) external override returns (bytes32) { + * This function is called by a challenger and it will pull `disputeDeposit` GRT tokens. + * + * * Requirements: + * - Challenger must have previously approved this contract to pull `disputeDeposit` amount + * of tokens from their balance. + * + * @param attestationData Attestation bytes submitted by the challenger + */ + function createQueryDispute(bytes calldata attestationData) external override returns (bytes32) { // Get funds from submitter - _pullSubmitterDeposit(deposit); + _pullSubmitterDeposit(); // Create a dispute return _createQueryDisputeWithAttestation( msg.sender, - deposit, + disputeDeposit, Attestation.parse(attestationData), attestationData ); @@ -303,12 +308,12 @@ contract DisputeManager is } /** - * @notice Set the minimum deposit required to create a dispute. - * @dev Update the minimum deposit to `_minimumDeposit` Graph Tokens - * @param minimumDeposit The minimum deposit in Graph Tokens + * @notice Set the dispute deposit required to create a dispute. + * @dev Update the dispute deposit to `_disputeDeposit` Graph Tokens + * @param disputeDeposit The dispute deposit in Graph Tokens */ - function setMinimumDeposit(uint256 minimumDeposit) external override onlyOwner { - _setMinimumDeposit(minimumDeposit); + function setDisputeDeposit(uint256 disputeDeposit) external override onlyOwner { + _setDisputeDeposit(disputeDeposit); } /** @@ -577,15 +582,11 @@ contract DisputeManager is } /** - * @notice Pull deposit from submitter account. - * @param _deposit Amount of tokens to deposit + * @notice Pull `disputeDeposit` from submitter account. */ - function _pullSubmitterDeposit(uint256 _deposit) private { - // Ensure that fisherman has staked at least the minimum amount - require(_deposit >= minimumDeposit, DisputeManagerInsufficientDeposit(_deposit, minimumDeposit)); - + function _pullSubmitterDeposit() private { // Transfer tokens to deposit from fisherman to this contract - _graphToken().pullTokens(msg.sender, _deposit); + _graphToken().pullTokens(msg.sender, disputeDeposit); } /** @@ -642,14 +643,14 @@ contract DisputeManager is } /** - * @notice Internal: Set the minimum deposit required to create a dispute. - * @dev Update the minimum deposit to `_minimumDeposit` Graph Tokens - * @param _minimumDeposit The minimum deposit in Graph Tokens + * @notice Internal: Set the dispute deposit required to create a dispute. + * @dev Update the dispute deposit to `_disputeDeposit` Graph Tokens + * @param _disputeDeposit The dispute deposit in Graph Tokens */ - function _setMinimumDeposit(uint256 _minimumDeposit) private { - require(_minimumDeposit != 0, DisputeManagerInvalidMinimumDeposit(_minimumDeposit)); - minimumDeposit = _minimumDeposit; - emit MinimumDepositSet(minimumDeposit); + function _setDisputeDeposit(uint256 _disputeDeposit) private { + require(_disputeDeposit != 0, DisputeManagerInvalidDisputeDeposit(_disputeDeposit)); + disputeDeposit = _disputeDeposit; + emit DisputeDepositSet(disputeDeposit); } /** diff --git a/packages/subgraph-service/contracts/DisputeManagerStorage.sol b/packages/subgraph-service/contracts/DisputeManagerStorage.sol index 19e217f12..8ff0685bf 100644 --- a/packages/subgraph-service/contracts/DisputeManagerStorage.sol +++ b/packages/subgraph-service/contracts/DisputeManagerStorage.sol @@ -15,8 +15,8 @@ abstract contract DisputeManagerV1Storage { /// @notice dispute period in seconds uint64 public disputePeriod; - /// @notice Minimum deposit required to create a Dispute - uint256 public minimumDeposit; + /// @notice Deposit required to create a Dispute + uint256 public disputeDeposit; /// @notice Percentage of indexer slashed funds to assign as a reward to fisherman in successful dispute. In PPM. uint32 public fishermanRewardCut; diff --git a/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol b/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol index b0616824d..09b13aec4 100644 --- a/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol +++ b/packages/subgraph-service/contracts/interfaces/IDisputeManager.sol @@ -55,10 +55,10 @@ interface IDisputeManager { event DisputePeriodSet(uint64 disputePeriod); /** - * @notice Emitted when minimum deposit is set. - * @param minimumDeposit The minimum deposit required to create a dispute. + * @notice Emitted when dispute deposit is set. + * @param disputeDeposit The dispute deposit required to create a dispute. */ - event MinimumDepositSet(uint256 minimumDeposit); + event DisputeDepositSet(uint256 disputeDeposit); /** * @notice Emitted when max slashing cut is set. @@ -151,12 +151,11 @@ interface IDisputeManager { error DisputeManagerDisputePeriodZero(); error DisputeManagerZeroTokens(); error DisputeManagerInvalidDispute(bytes32 disputeId); - error DisputeManagerInvalidMinimumDeposit(uint256 minimumDeposit); + error DisputeManagerInvalidDisputeDeposit(uint256 disputeDeposit); error DisputeManagerInvalidFishermanReward(uint32 cut); error DisputeManagerInvalidMaxSlashingCut(uint32 maxSlashingCut); error DisputeManagerInvalidTokensSlash(uint256 tokensSlash, uint256 maxTokensSlash); error DisputeManagerDisputeNotPending(IDisputeManager.DisputeStatus status); - error DisputeManagerInsufficientDeposit(uint256 deposit, uint256 minimumDeposit); error DisputeManagerDisputeAlreadyCreated(bytes32 disputeId); error DisputeManagerDisputePeriodNotFinished(); error DisputeManagerMustAcceptRelatedDispute(bytes32 disputeId, bytes32 relatedDisputeId); @@ -174,7 +173,7 @@ interface IDisputeManager { function initialize( address arbitrator, uint64 disputePeriod, - uint256 minimumDeposit, + uint256 disputeDeposit, uint32 fishermanRewardCut, uint32 maxSlashingCut ) external; @@ -183,7 +182,7 @@ interface IDisputeManager { function setArbitrator(address arbitrator) external; - function setMinimumDeposit(uint256 minimumDeposit) external; + function setDisputeDeposit(uint256 disputeDeposit) external; function setFishermanRewardCut(uint32 cut) external; @@ -191,14 +190,14 @@ interface IDisputeManager { // -- Dispute -- - function createQueryDispute(bytes calldata attestationData, uint256 deposit) external returns (bytes32); + function createQueryDispute(bytes calldata attestationData) external returns (bytes32); function createQueryDisputeConflict( bytes calldata attestationData1, bytes calldata attestationData2 ) external returns (bytes32, bytes32); - function createIndexingDispute(address allocationId, bytes32 poi, uint256 deposit) external returns (bytes32); + function createIndexingDispute(address allocationId, bytes32 poi) external returns (bytes32); function acceptDispute(bytes32 disputeId, uint256 tokensSlash) external; diff --git a/packages/subgraph-service/test/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/SubgraphBaseTest.t.sol index 1ebcf6683..a381d1695 100644 --- a/packages/subgraph-service/test/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/SubgraphBaseTest.t.sol @@ -138,7 +138,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { users.governor, abi.encodeCall( DisputeManager.initialize, - (users.arbitrator, disputePeriod, minimumDeposit, fishermanRewardPercentage, maxSlashingPercentage) + (users.arbitrator, disputePeriod, disputeDeposit, fishermanRewardPercentage, maxSlashingPercentage) ) ); disputeManager = DisputeManager(disputeManagerProxy); diff --git a/packages/subgraph-service/test/disputes/DisputeManager.t.sol b/packages/subgraph-service/test/disputes/DisputeManager.t.sol index 8b6f95b12..954cef783 100644 --- a/packages/subgraph-service/test/disputes/DisputeManager.t.sol +++ b/packages/subgraph-service/test/disputes/DisputeManager.t.sol @@ -28,17 +28,20 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { * HELPERS */ - function _createIndexingDispute(address _allocationID, bytes32 _poi, uint256 tokens) internal returns (bytes32 disputeID) { + function _createIndexingDispute(address _allocationID, bytes32 _poi) internal returns (bytes32 disputeID) { address msgSender; (, msgSender,) = vm.readCallers(); resetPrank(users.fisherman); - token.approve(address(disputeManager), tokens); - bytes32 _disputeID = disputeManager.createIndexingDispute(_allocationID, _poi, tokens); + uint256 beforeFishermanBalance = token.balanceOf(users.fisherman); + token.approve(address(disputeManager), disputeDeposit); + bytes32 _disputeID = disputeManager.createIndexingDispute(_allocationID, _poi); + uint256 afterFishermanBalance = token.balanceOf(users.fisherman); + assertEq(afterFishermanBalance, beforeFishermanBalance - disputeDeposit, "Fisherman should be charged the dispute deposit"); resetPrank(msgSender); return _disputeID; } - function _createQueryDispute(uint256 tokens) internal returns (bytes32 disputeID) { + function _createQueryDispute() internal returns (bytes32 disputeID) { address msgSender; (, msgSender,) = vm.readCallers(); resetPrank(users.fisherman); @@ -49,8 +52,11 @@ contract DisputeManagerTest is SubgraphServiceSharedTest { }); bytes memory attestationData = _createAtestationData(receipt, allocationIDPrivateKey); - token.approve(address(disputeManager), tokens); - bytes32 _disputeID = disputeManager.createQueryDispute(attestationData, tokens); + uint256 beforeFishermanBalance = token.balanceOf(users.fisherman); + token.approve(address(disputeManager), disputeDeposit); + bytes32 _disputeID = disputeManager.createQueryDispute(attestationData); + uint256 afterFishermanBalance = token.balanceOf(users.fisherman); + assertEq(afterFishermanBalance, beforeFishermanBalance - disputeDeposit, "Fisherman should be charged the dispute deposit"); resetPrank(msgSender); return _disputeID; } diff --git a/packages/subgraph-service/test/disputes/accept.t.sol b/packages/subgraph-service/test/disputes/accept.t.sol index ee9bbec27..8e7a7f593 100644 --- a/packages/subgraph-service/test/disputes/accept.t.sol +++ b/packages/subgraph-service/test/disputes/accept.t.sol @@ -17,7 +17,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_IndexingDispute( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash, uint256 delegationAmount ) public useIndexer useAllocation(tokens) { @@ -29,10 +28,9 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { uint256 stakeSnapshot = disputeManager.getStakeSnapshot(users.indexer); uint256 tokensSlashCap = stakeSnapshot.mulPPM(maxSlashingPercentage); tokensSlash = bound(tokensSlash, 1, tokensSlashCap); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); uint256 fishermanPreviousBalance = token.balanceOf(users.fisherman); - bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); resetPrank(users.arbitrator); disputeManager.acceptDispute(disputeID, tokensSlash); @@ -44,7 +42,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_QueryDispute( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash, uint256 delegationAmount ) public useIndexer useAllocation(tokens) { @@ -56,10 +53,9 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { uint256 stakeSnapshot = disputeManager.getStakeSnapshot(users.indexer); uint256 tokensSlashCap = stakeSnapshot.mulPPM(maxSlashingPercentage); tokensSlash = bound(tokensSlash, 1, tokensSlashCap); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); uint256 fishermanPreviousBalance = token.balanceOf(users.fisherman); - bytes32 disputeID = _createQueryDispute(tokensDispute); + bytes32 disputeID = _createQueryDispute(); resetPrank(users.arbitrator); disputeManager.acceptDispute(disputeID, tokensSlash); @@ -120,7 +116,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_IndexingDispute_RevertIf_SlashAmountTooHigh( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash, uint256 delegationAmount ) public useIndexer useAllocation(tokens) { @@ -132,9 +127,8 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { uint256 stakeSnapshot = disputeManager.getStakeSnapshot(users.indexer); uint256 tokensSlashCap = stakeSnapshot.mulPPM(maxSlashingPercentage); tokensSlash = bound(tokensSlash, tokensSlashCap + 1 wei, type(uint256).max); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); resetPrank(users.arbitrator); bytes memory expectedError = abi.encodeWithSelector( @@ -148,7 +142,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_QueryDispute_RevertIf_SlashAmountTooHigh( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash, uint256 delegationAmount ) public useIndexer useAllocation(tokens) { @@ -160,9 +153,8 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { uint256 stakeSnapshot = disputeManager.getStakeSnapshot(users.indexer); uint256 tokensSlashCap = stakeSnapshot.mulPPM(maxSlashingPercentage); tokensSlash = bound(tokensSlash, tokensSlashCap + 1 wei, type(uint256).max); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID = _createQueryDispute(tokensDispute); + bytes32 disputeID = _createQueryDispute(); resetPrank(users.arbitrator); bytes memory expectedError = abi.encodeWithSelector( @@ -176,7 +168,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_ConflictingQueryDispute_RevertIf_SlashAmountTooHigh( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash, uint256 delegationAmount ) public useIndexer useAllocation(tokens) { @@ -188,7 +179,6 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { uint256 stakeSnapshot = disputeManager.getStakeSnapshot(users.indexer); uint256 tokensSlashCap = stakeSnapshot.mulPPM(maxSlashingPercentage); tokensSlash = bound(tokensSlash, tokensSlashCap + 1 wei, type(uint256).max); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); bytes32 responseCID1 = keccak256(abi.encodePacked("Response CID 1")); bytes32 responseCID2 = keccak256(abi.encodePacked("Response CID 2")); @@ -219,13 +209,11 @@ contract DisputeManagerAcceptDisputeTest is DisputeManagerTest { function testAccept_RevertIf_CallerIsNotArbitrator( uint256 tokens, - uint256 tokensDispute, uint256 tokensSlash ) public useIndexer useAllocation(tokens) { tokensSlash = bound(tokensSlash, 1, uint256(maxSlashingPercentage).mulPPM(tokens)); - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); // attempt to accept dispute as fisherman resetPrank(users.fisherman); diff --git a/packages/subgraph-service/test/disputes/cancel.t.sol b/packages/subgraph-service/test/disputes/cancel.t.sol index f61e7c099..4affbd6f4 100644 --- a/packages/subgraph-service/test/disputes/cancel.t.sol +++ b/packages/subgraph-service/test/disputes/cancel.t.sol @@ -13,12 +13,10 @@ contract DisputeManagerCancelDisputeTest is DisputeManagerTest { */ function testCancel_Dispute( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); uint256 fishermanPreviousBalance = token.balanceOf(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); // skip to end of dispute period skip(disputePeriod + 1); @@ -61,11 +59,9 @@ contract DisputeManagerCancelDisputeTest is DisputeManagerTest { } function testCancel_RevertIf_CallerIsNotFisherman( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); resetPrank(users.arbitrator); vm.expectRevert(abi.encodeWithSelector(IDisputeManager.DisputeManagerNotFisherman.selector)); diff --git a/packages/subgraph-service/test/disputes/create.t.sol b/packages/subgraph-service/test/disputes/create.t.sol index 5112aea0a..eb1907ebe 100644 --- a/packages/subgraph-service/test/disputes/create.t.sol +++ b/packages/subgraph-service/test/disputes/create.t.sol @@ -13,20 +13,16 @@ contract DisputeManagerCreateDisputeTest is DisputeManagerTest { */ function testCreate_IndexingDispute( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); assertTrue(disputeManager.isDisputeCreated(disputeID), "Dispute should be created."); } function testCreate_QueryDispute( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID = _createQueryDispute(tokensDispute); + bytes32 disputeID = _createQueryDispute(); assertTrue(disputeManager.isDisputeCreated(disputeID), "Dispute should be created."); } @@ -54,51 +50,44 @@ contract DisputeManagerCreateDisputeTest is DisputeManagerTest { } function testCreate_RevertWhen_DisputeAlreadyCreated( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI1")); // Create another dispute with different fisherman address otherFisherman = makeAddr("otherFisherman"); resetPrank(otherFisherman); - mint(otherFisherman, tokensDispute); - token.approve(address(disputeManager), tokensDispute); + mint(otherFisherman, disputeDeposit); + token.approve(address(disputeManager), disputeDeposit); bytes memory expectedError = abi.encodeWithSelector( IDisputeManager.DisputeManagerDisputeAlreadyCreated.selector, disputeID ); vm.expectRevert(expectedError); - disputeManager.createIndexingDispute(allocationID, bytes32("POI1"), tokensDispute); + disputeManager.createIndexingDispute(allocationID, bytes32("POI1")); vm.stopPrank(); } - function testCreate_RevertIf_DepositUnderMinimum( - uint256 tokensDispute - ) public useFisherman { - tokensDispute = bound(tokensDispute, 1, minimumDeposit - 1); - bytes memory expectedError = abi.encodeWithSelector( - IDisputeManager.DisputeManagerInsufficientDeposit.selector, - tokensDispute, - minimumDeposit + function testCreate_RevertIf_TokensNotApproved() public useFisherman { + bytes memory expectedError = abi.encodeWithSignature( + "ERC20InsufficientAllowance(address,uint256,uint256)", + address(disputeManager), + 0, + disputeDeposit ); vm.expectRevert(expectedError); - disputeManager.createIndexingDispute(allocationID, bytes32("POI3"), tokensDispute); + disputeManager.createIndexingDispute(allocationID, bytes32("POI3")); vm.stopPrank(); } - function testCreate_RevertIf_AllocationDoesNotExist( - uint256 tokens - ) public useFisherman { - tokens = bound(tokens, minimumDeposit, 10_000_000_000 ether); - token.approve(address(disputeManager), tokens); + function testCreate_RevertIf_AllocationDoesNotExist() public useFisherman { + token.approve(address(disputeManager), disputeDeposit); bytes memory expectedError = abi.encodeWithSelector( IDisputeManager.DisputeManagerIndexerNotFound.selector, allocationID ); vm.expectRevert(expectedError); - disputeManager.createIndexingDispute(allocationID, bytes32("POI4"), tokens); + disputeManager.createIndexingDispute(allocationID, bytes32("POI4")); vm.stopPrank(); } diff --git a/packages/subgraph-service/test/disputes/draw.t.sol b/packages/subgraph-service/test/disputes/draw.t.sol index e28561b10..e5ef827de 100644 --- a/packages/subgraph-service/test/disputes/draw.t.sol +++ b/packages/subgraph-service/test/disputes/draw.t.sol @@ -14,12 +14,10 @@ contract DisputeManagerDrawDisputeTest is DisputeManagerTest { */ function testDraw_Dispute( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); uint256 fishermanPreviousBalance = token.balanceOf(users.fisherman); - bytes32 disputeID =_createIndexingDispute(allocationID, bytes32("POI32"), tokensDispute); + bytes32 disputeID = _createIndexingDispute(allocationID, bytes32("POI32")); resetPrank(users.arbitrator); disputeManager.drawDispute(disputeID); @@ -57,11 +55,9 @@ contract DisputeManagerDrawDisputeTest is DisputeManagerTest { } function testDraw_RevertIf_CallerIsNotArbitrator( - uint256 tokens, - uint256 tokensDispute + uint256 tokens ) public useIndexer useAllocation(tokens) { - tokensDispute = bound(tokensDispute, minimumDeposit, tokens); - bytes32 disputeID =_createIndexingDispute(allocationID,bytes32("POI1"), tokens); + bytes32 disputeID = _createIndexingDispute(allocationID,bytes32("POI1")); // attempt to draw dispute as fisherman resetPrank(users.fisherman); diff --git a/packages/subgraph-service/test/utils/Constants.sol b/packages/subgraph-service/test/utils/Constants.sol index e533fd549..b28362653 100644 --- a/packages/subgraph-service/test/utils/Constants.sol +++ b/packages/subgraph-service/test/utils/Constants.sol @@ -5,7 +5,7 @@ abstract contract Constants { uint256 internal constant MAX_TOKENS = 10_000_000_000 ether; // Dispute Manager uint64 internal constant disputePeriod = 300; // 5 minutes - uint256 internal constant minimumDeposit = 100 ether; // 100 GRT + uint256 internal constant disputeDeposit = 100 ether; // 100 GRT uint32 internal constant fishermanRewardPercentage = 100000; // 10% uint32 internal constant maxSlashingPercentage = 500000; // 50% // Subgraph Service