From 4ad1ccdf3a6e1229afec0554031cd5fa29fabac9 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 13:04:16 +0100 Subject: [PATCH 01/13] fix: releaseStake n parameter changed to numClaimsToRelease. --- .../data-service/extensions/DataServiceFees.sol | 8 ++++---- .../data-service/interfaces/IDataServiceFees.sol | 4 ++-- .../data-service/extensions/DataServiceFees.t.sol | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol index e0ea587f4..83ebbe971 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol @@ -22,8 +22,8 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat /** * @notice See {IDataServiceFees-releaseStake} */ - function releaseStake(uint256 n) external virtual override { - _releaseStake(msg.sender, n); + function releaseStake(uint256 numClaimsToRelease) external virtual override { + _releaseStake(msg.sender, numClaimsToRelease); } /** @@ -61,14 +61,14 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat /** * @notice See {IDataServiceFees-releaseStake} */ - function _releaseStake(address _serviceProvider, uint256 _n) internal { + function _releaseStake(address _serviceProvider, uint256 _numClaimsToRelease) internal { LinkedList.List storage claimsList = claimsLists[_serviceProvider]; (uint256 claimsReleased, bytes memory data) = claimsList.traverse( _getNextStakeClaim, _processStakeClaim, _deleteStakeClaim, abi.encode(0, _serviceProvider), - _n + _numClaimsToRelease ); emit StakeClaimsReleased(_serviceProvider, claimsReleased, abi.decode(data, (uint256))); diff --git a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol index 483f11274..2677f247e 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol @@ -89,7 +89,7 @@ interface IDataServiceFees is IDataService { * stake claims that releasing them all at once would exceed the block gas limit. * @dev This function can be overriden and/or disabled. * @dev Emits a {StakeClaimsReleased} event, and a {StakeClaimReleased} event for each claim released. - * @param n Amount of stake claims to process. If 0, all stake claims are processed. + * @param numClaimsToRelease Amount of stake claims to process. If 0, all stake claims are processed. */ - function releaseStake(uint256 n) external; + function releaseStake(uint256 numClaimsToRelease) external; } diff --git a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol index f6f31d54c..fef08d094 100644 --- a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol +++ b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol @@ -81,14 +81,14 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { function test_Release_WhenNIsValid( uint256 tokens, uint256 steps, - uint256 n + uint256 numClaimsToRelease ) external useIndexer useProvisionDataService(address(dataService), PROVISION_TOKENS, 0, 0) { // lock all provisioned stake in steps // limit tokens to at least 1 per step // limit steps to at least 15 so we stagger locks every 5 seconds to have some expired tokens = bound(tokens, 50, PROVISION_TOKENS / dataService.STAKE_TO_FEES_RATIO()); steps = bound(steps, 15, 50); - n = bound(n, 0, steps); + numClaimsToRelease = bound(numClaimsToRelease, 0, steps); uint256 stepAmount = tokens / steps; @@ -99,7 +99,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { } // it should release all expired claims - _assert_releaseStake(users.indexer, n); + _assert_releaseStake(users.indexer, numClaimsToRelease); } function test_Release_WhenNIsNotValid( @@ -180,7 +180,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { uint256 tokensReleased; bytes32 head; } - function _assert_releaseStake(address serviceProvider, uint256 n) private { + function _assert_releaseStake(address serviceProvider, uint256 numClaimsToRelease) private { // before state (bytes32 beforeHead, bytes32 beforeTail, uint256 beforeNonce, uint256 beforeCount) = dataService.claimsLists( serviceProvider @@ -195,7 +195,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { tokensReleased: 0, head: beforeHead }); - while (calcValues.head != bytes32(0) && (calcValues.claimsCount < n || n == 0)) { + while (calcValues.head != bytes32(0) && (calcValues.claimsCount < numClaimsToRelease || numClaimsToRelease == 0)) { (uint256 claimTokens, , uint256 releaseAt, bytes32 nextClaim) = dataService.claims(calcValues.head); if (releaseAt > block.timestamp) { break; @@ -209,7 +209,7 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { // it should emit a an event emit IDataServiceFees.StakeClaimsReleased(serviceProvider, calcValues.claimsCount, calcValues.tokensReleased); - dataService.releaseStake(n); + dataService.releaseStake(numClaimsToRelease); // after state (bytes32 afterHead, bytes32 afterTail, uint256 afterNonce, uint256 afterCount) = dataService.claimsLists( From d90b971a19639589f6f6a440edfd4dc3737ddff1 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 13:09:06 +0100 Subject: [PATCH 02/13] fix: function _setPartialPaused(bool _toPause) chnaged to function _setPartialPaused(bool _toPartialPause). --- packages/contracts/contracts/governance/Controller.sol | 6 +++--- packages/contracts/contracts/governance/Pausable.sol | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/contracts/contracts/governance/Controller.sol b/packages/contracts/contracts/governance/Controller.sol index 2b71fd885..707a27fff 100644 --- a/packages/contracts/contracts/governance/Controller.sol +++ b/packages/contracts/contracts/governance/Controller.sol @@ -89,10 +89,10 @@ contract Controller is Governed, Pausable, IController { /** * @notice Change the partial paused state of the contract * Partial pause is intended as a partial pause of the protocol - * @param _toPause True if the contracts should be (partially) paused, false otherwise + * @param _toPartialPause True if the contracts should be (partially) paused, false otherwise */ - function setPartialPaused(bool _toPause) external override onlyGovernorOrGuardian { - _setPartialPaused(_toPause); + function setPartialPaused(bool _toPartialPause) external override onlyGovernorOrGuardian { + _setPartialPaused(_toPartialPause); } /** diff --git a/packages/contracts/contracts/governance/Pausable.sol b/packages/contracts/contracts/governance/Pausable.sol index 6c5d2fd2c..179762527 100644 --- a/packages/contracts/contracts/governance/Pausable.sol +++ b/packages/contracts/contracts/governance/Pausable.sol @@ -31,13 +31,13 @@ abstract contract Pausable { /** * @dev Change the partial paused state of the contract - * @param _toPause New value for the partial pause state (true means the contracts will be partially paused) + * @param _toPartialPause New value for the partial pause state (true means the contracts will be partially paused) */ - function _setPartialPaused(bool _toPause) internal { - if (_toPause == _partialPaused) { + function _setPartialPaused(bool _toPartialPause) internal { + if (_toPartialPause == _partialPaused) { return; } - _partialPaused = _toPause; + _partialPaused = _toPartialPause; if (_partialPaused) { lastPausePartialTime = block.timestamp; } From 9d819efaa308b1aef5a44b0dc302f525396cd3bd Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 13:11:19 +0100 Subject: [PATCH 03/13] fix: lastPausePartialTime now lastPartialPauseTime.. --- packages/contracts/contracts/governance/Pausable.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contracts/contracts/governance/Pausable.sol b/packages/contracts/contracts/governance/Pausable.sol index 179762527..2bc1795cd 100644 --- a/packages/contracts/contracts/governance/Pausable.sol +++ b/packages/contracts/contracts/governance/Pausable.sol @@ -14,7 +14,7 @@ abstract contract Pausable { bool internal _paused; /// Timestamp for the last time the partial pause was set - uint256 public lastPausePartialTime; + uint256 public lastPartialPauseTime; /// Timestamp for the last time the full pause was set uint256 public lastPauseTime; @@ -39,7 +39,7 @@ abstract contract Pausable { } _partialPaused = _toPartialPause; if (_partialPaused) { - lastPausePartialTime = block.timestamp; + lastPartialPauseTime = block.timestamp; } emit PartialPauseChanged(_partialPaused); } From 2d69d2a9eff23403fd7531108c6b25b29285e2f2 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 15:57:36 +0100 Subject: [PATCH 04/13] fix: acceptProvision updated to acceptProvisionPendingParameters --- .../contracts/data-service/interfaces/IDataService.sol | 2 +- .../test/data-service/implementations/DataServiceBase.sol | 2 +- .../implementations/DataServiceBaseUpgradeable.sol | 2 +- .../data-service/implementations/DataServiceImpFees.sol | 2 +- .../implementations/DataServiceImpPausable.sol | 2 +- .../implementations/DataServiceImpPausableUpgradeable.sol | 2 +- packages/subgraph-service/contracts/SubgraphService.sol | 4 ++-- .../test/subgraphService/SubgraphService.t.sol | 2 +- .../test/subgraphService/provision/accept.t.sol | 8 ++++---- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/horizon/contracts/data-service/interfaces/IDataService.sol b/packages/horizon/contracts/data-service/interfaces/IDataService.sol index 3eec64c04..61d032e68 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataService.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataService.sol @@ -88,7 +88,7 @@ interface IDataService { * @param serviceProvider The address of the service provider. * @param data Custom data, usage defined by the data service. */ - function acceptProvision(address serviceProvider, bytes calldata data) external; + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external; /** * @notice Service provider starts providing the service. diff --git a/packages/horizon/test/data-service/implementations/DataServiceBase.sol b/packages/horizon/test/data-service/implementations/DataServiceBase.sol index d98dd2857..0d51241ce 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceBase.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceBase.sol @@ -19,7 +19,7 @@ contract DataServiceBase is DataService { function register(address serviceProvider, bytes calldata data) external {} - function acceptProvision(address serviceProvider, bytes calldata data) external {} + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external {} function startService(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol b/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol index 31309c524..a7ebfd465 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceBaseUpgradeable.sol @@ -15,7 +15,7 @@ contract DataServiceBaseUpgradeable is DataService { function register(address serviceProvider, bytes calldata data) external {} - function acceptProvision(address serviceProvider, bytes calldata data) external {} + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external {} function startService(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol b/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol index efabda6ff..ac5c79c89 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpFees.sol @@ -15,7 +15,7 @@ contract DataServiceImpFees is DataServiceFees { function register(address serviceProvider, bytes calldata data) external {} - function acceptProvision(address serviceProvider, bytes calldata data) external {} + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external {} function startService(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol b/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol index 0ca990ab1..5073207ab 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpPausable.sol @@ -23,7 +23,7 @@ contract DataServiceImpPausable is DataServicePausable { function register(address serviceProvider, bytes calldata data) external {} - function acceptProvision(address serviceProvider, bytes calldata data) external {} + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external {} function startService(address serviceProvider, bytes calldata data) external {} diff --git a/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol b/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol index 39b2bb26b..cea615885 100644 --- a/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol +++ b/packages/horizon/test/data-service/implementations/DataServiceImpPausableUpgradeable.sol @@ -17,7 +17,7 @@ contract DataServiceImpPausableUpgradeable is DataServicePausableUpgradeable { function register(address serviceProvider, bytes calldata data) external {} - function acceptProvision(address serviceProvider, bytes calldata data) external {} + function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external {} function startService(address serviceProvider, bytes calldata data) external {} diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index e50762453..18148faf8 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -131,7 +131,7 @@ contract SubgraphService is /** * @notice Accept staged parameters in the provision of a service provider - * @dev Implements {IDataService-acceptProvision} + * @dev Implements {IDataService-acceptProvisionPendingParameters} * * Requirements: * - The indexer must be registered @@ -142,7 +142,7 @@ contract SubgraphService is * * @param indexer The address of the indexer to accept the provision for */ - function acceptProvision( + function acceptProvisionPendingParameters( address indexer, bytes calldata ) external override onlyProvisionAuthorized(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index e62ce8211..1f441a9c3 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -86,7 +86,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { emit IDataService.ProvisionAccepted(_indexer); // Accept provision - subgraphService.acceptProvision(_indexer, _data); + subgraphService.acceptProvisionPendingParameters(_indexer, _data); // Update provision after acceptance provision = staking.getProvision(_indexer, address(subgraphService)); diff --git a/packages/subgraph-service/test/subgraphService/provision/accept.t.sol b/packages/subgraph-service/test/subgraphService/provision/accept.t.sol index 1c8191275..44ce19b5f 100644 --- a/packages/subgraph-service/test/subgraphService/provision/accept.t.sol +++ b/packages/subgraph-service/test/subgraphService/provision/accept.t.sol @@ -40,7 +40,7 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { ISubgraphService.SubgraphServiceIndexerNotRegistered.selector, users.indexer )); - subgraphService.acceptProvision(users.indexer, ""); + subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } function test_SubgraphService_Provision_Accept_RevertWhen_NotAuthorized() public { @@ -50,7 +50,7 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { users.operator, users.indexer )); - subgraphService.acceptProvision(users.indexer, ""); + subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } function test_SubgraphService_Provision_Accept_RevertIf_InvalidVerifierCut( @@ -75,7 +75,7 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { fishermanRewardPercentage, MAX_PPM )); - subgraphService.acceptProvision(users.indexer, ""); + subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } function test_SubgraphService_Provision_Accept_RevertIf_InvalidDisputePeriod( @@ -100,6 +100,6 @@ contract SubgraphServiceProvisionAcceptTest is SubgraphServiceTest { disputePeriod, type(uint64).max )); - subgraphService.acceptProvision(users.indexer, ""); + subgraphService.acceptProvisionPendingParameters(users.indexer, ""); } } From a4ba0ab5cf0648117e3f329b54beba5f92c0b670 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 15:58:45 +0100 Subject: [PATCH 05/13] fix: rename staged to pending. --- .../horizon/contracts/data-service/interfaces/IDataService.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/horizon/contracts/data-service/interfaces/IDataService.sol b/packages/horizon/contracts/data-service/interfaces/IDataService.sol index 61d032e68..b3f168bbe 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataService.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataService.sol @@ -79,7 +79,7 @@ interface IDataService { function register(address serviceProvider, bytes calldata data) external; /** - * @notice Accepts staged parameters in the provision of a service provider in the {Graph Horizon staking + * @notice Accepts pending parameters in the provision of a service provider in the {Graph Horizon staking * contract}. * @dev Provides a way for the data service to validate and accept provision parameter changes. Call {_acceptProvision}. * From 76bedb3ed5fc88536d98f7b7fb9d62705f511dfa Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 16:38:55 +0100 Subject: [PATCH 06/13] fix: rename maxVerifierCut to newMaxVerifierCut and thawingPeriod to newThawingPeriod. --- .../horizon/contracts/staking/HorizonStaking.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/horizon/contracts/staking/HorizonStaking.sol b/packages/horizon/contracts/staking/HorizonStaking.sol index c8709e639..8d74df83e 100644 --- a/packages/horizon/contracts/staking/HorizonStaking.sol +++ b/packages/horizon/contracts/staking/HorizonStaking.sol @@ -226,16 +226,16 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain { function setProvisionParameters( address serviceProvider, address verifier, - uint32 maxVerifierCut, - uint64 thawingPeriod + uint32 newMaxVerifierCut, + uint64 newThawingPeriod ) external override notPaused onlyAuthorized(serviceProvider, verifier) { Provision storage prov = _provisions[serviceProvider][verifier]; require(prov.createdAt != 0, HorizonStakingInvalidProvision(serviceProvider, verifier)); - if ((prov.maxVerifierCutPending != maxVerifierCut) || (prov.thawingPeriodPending != thawingPeriod)) { - prov.maxVerifierCutPending = maxVerifierCut; - prov.thawingPeriodPending = thawingPeriod; - emit ProvisionParametersStaged(serviceProvider, verifier, maxVerifierCut, thawingPeriod); + if ((prov.maxVerifierCutPending != newMaxVerifierCut) || (prov.thawingPeriodPending != newThawingPeriod)) { + prov.maxVerifierCutPending = newMaxVerifierCut; + prov.thawingPeriodPending = newThawingPeriod; + emit ProvisionParametersStaged(serviceProvider, verifier, newMaxVerifierCut, newThawingPeriod); } } From faafe8267fb0a2cb88be2e156134b738bf8d57dc Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 18:56:09 +0100 Subject: [PATCH 07/13] fix: onlyProvisionAuthorized now onlyAuthorizedForProvision. --- .../data-service/utilities/ProvisionManager.sol | 2 +- .../subgraph-service/contracts/SubgraphService.sol | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol index d1cf94287..fbd3936ac 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol @@ -82,7 +82,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa /** * @notice Checks if the caller is authorized to manage the provision of a service provider. */ - modifier onlyProvisionAuthorized(address serviceProvider) { + modifier onlyAuthorizedForProvision(address serviceProvider) { require( _graphStaking().isAuthorized(msg.sender, serviceProvider, address(this)), ProvisionManagerNotAuthorized(msg.sender, serviceProvider) diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 18148faf8..793b05623 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -110,7 +110,7 @@ contract SubgraphService is function register( address indexer, bytes calldata data - ) external override onlyProvisionAuthorized(indexer) onlyValidProvision(indexer) whenNotPaused { + ) external override onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) whenNotPaused { (string memory url, string memory geohash, address rewardsDestination) = abi.decode( data, (string, string, address) @@ -145,7 +145,7 @@ contract SubgraphService is function acceptProvisionPendingParameters( address indexer, bytes calldata - ) external override onlyProvisionAuthorized(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { + ) external override onlyAuthorizedForProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { _checkProvisionTokens(indexer); _acceptProvisionParameters(indexer); emit ProvisionAccepted(indexer); @@ -181,7 +181,7 @@ contract SubgraphService is ) external override - onlyProvisionAuthorized(indexer) + onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused @@ -216,7 +216,7 @@ contract SubgraphService is function stopService( address indexer, bytes calldata data - ) external override onlyProvisionAuthorized(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { + ) external override onlyAuthorizedForProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { address allocationId = abi.decode(data, (address)); require( allocations.get(allocationId).indexer == indexer, @@ -254,7 +254,7 @@ contract SubgraphService is ) external override - onlyProvisionAuthorized(indexer) + onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused @@ -326,7 +326,7 @@ contract SubgraphService is uint256 tokens ) external - onlyProvisionAuthorized(indexer) + onlyAuthorizedForProvision(indexer) onlyValidProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused From e73cb44777ca5f09f0f08a63cb77b19ea7c0d97b Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 18:56:48 +0100 Subject: [PATCH 08/13] fix: ProvisionAccepted now ProvisionPendingParametersAccepted. --- .../contracts/data-service/interfaces/IDataService.sol | 4 ++-- .../contracts/data-service/utilities/ProvisionManager.sol | 2 +- packages/subgraph-service/contracts/SubgraphService.sol | 4 ++-- .../test/subgraphService/SubgraphService.t.sol | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/horizon/contracts/data-service/interfaces/IDataService.sol b/packages/horizon/contracts/data-service/interfaces/IDataService.sol index b3f168bbe..7770bc9a5 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataService.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataService.sol @@ -25,7 +25,7 @@ interface IDataService { * @notice Emitted when a service provider accepts a provision in {Graph Horizon staking contract}. * @param serviceProvider The address of the service provider. */ - event ProvisionAccepted(address indexed serviceProvider); + event ProvisionPendingParametersAccepted(address indexed serviceProvider); /** * @notice Emitted when a service provider starts providing the service. @@ -83,7 +83,7 @@ interface IDataService { * contract}. * @dev Provides a way for the data service to validate and accept provision parameter changes. Call {_acceptProvision}. * - * Emits a {ProvisionAccepted} event. + * Emits a {ProvisionPendingParametersAccepted} event. * * @param serviceProvider The address of the service provider. * @param data Custom data, usage defined by the data service. diff --git a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol index fbd3936ac..3670fcdbd 100644 --- a/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol +++ b/packages/horizon/contracts/data-service/utilities/ProvisionManager.sol @@ -125,7 +125,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa * the {HorizonStaking} contract. * @dev Checks the pending provision parameters, not the current ones. * - * Emits a {ProvisionAccepted} event. + * Emits a {ProvisionPendingParametersAccepted} event. * * @param _serviceProvider The address of the service provider. */ diff --git a/packages/subgraph-service/contracts/SubgraphService.sol b/packages/subgraph-service/contracts/SubgraphService.sol index 793b05623..a4f6375dd 100644 --- a/packages/subgraph-service/contracts/SubgraphService.sol +++ b/packages/subgraph-service/contracts/SubgraphService.sol @@ -138,7 +138,7 @@ contract SubgraphService is * - Must have previously staged provision parameters, using {IHorizonStaking-setProvisionParameters} * - The new provision parameters must be valid according to the subgraph service rules * - * Emits a {ProvisionAccepted} event + * Emits a {ProvisionPendingParametersAccepted} event * * @param indexer The address of the indexer to accept the provision for */ @@ -148,7 +148,7 @@ contract SubgraphService is ) external override onlyAuthorizedForProvision(indexer) onlyRegisteredIndexer(indexer) whenNotPaused { _checkProvisionTokens(indexer); _acceptProvisionParameters(indexer); - emit ProvisionAccepted(indexer); + emit ProvisionPendingParametersAccepted(indexer); } /** diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index 1f441a9c3..67338fe64 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -83,7 +83,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { uint64 thawingPeriodPending = provision.thawingPeriodPending; vm.expectEmit(address(subgraphService)); - emit IDataService.ProvisionAccepted(_indexer); + emit IDataService.ProvisionPendingParametersAccepted(_indexer); // Accept provision subgraphService.acceptProvisionPendingParameters(_indexer, _data); From 69e1971b199af9f67426779f3dfbfc7de8107493 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 19:02:52 +0100 Subject: [PATCH 09/13] fix: releaseAt updated to releasableAt --- .../data-service/extensions/DataServiceFees.sol | 6 +++--- .../data-service/interfaces/IDataServiceFees.sol | 6 +++--- .../test/data-service/extensions/DataServiceFees.t.sol | 10 +++++----- .../test/subgraphService/SubgraphService.t.sol | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol index 83ebbe971..09102dd4a 100644 --- a/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol +++ b/packages/horizon/contracts/data-service/extensions/DataServiceFees.sol @@ -49,7 +49,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat claims[claimId] = StakeClaim({ tokens: _tokens, createdAt: block.timestamp, - releaseAt: _unlockTimestamp, + releasableAt: _unlockTimestamp, nextClaim: bytes32(0) }); if (claimsList.count != 0) claims[claimsList.tail].nextClaim = claimId; @@ -86,7 +86,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat StakeClaim memory claim = _getStakeClaim(_claimId); // early exit - if (claim.releaseAt > block.timestamp) { + if (claim.releasableAt > block.timestamp) { return (true, LinkedList.NULL_BYTES); } @@ -95,7 +95,7 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat // process feesProvisionTracker.release(serviceProvider, claim.tokens); - emit StakeClaimReleased(serviceProvider, _claimId, claim.tokens, claim.releaseAt); + emit StakeClaimReleased(serviceProvider, _claimId, claim.tokens, claim.releasableAt); // encode _acc = abi.encode(tokensClaimed + claim.tokens, serviceProvider); diff --git a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol index 2677f247e..c94fc6e00 100644 --- a/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol +++ b/packages/horizon/contracts/data-service/interfaces/IDataServiceFees.sol @@ -32,7 +32,7 @@ interface IDataServiceFees is IDataService { // Timestamp when the claim was created uint256 createdAt; // Timestamp when the claim will expire and tokens can be released - uint256 releaseAt; + uint256 releasableAt; // Next claim in the linked list bytes32 nextClaim; } @@ -56,13 +56,13 @@ interface IDataServiceFees is IDataService { * @param serviceProvider The address of the service provider * @param claimId The id of the stake claim * @param tokens The amount of tokens released - * @param releaseAt The timestamp when the tokens were released + * @param releasableAt The timestamp when the tokens were released */ event StakeClaimReleased( address indexed serviceProvider, bytes32 indexed claimId, uint256 tokens, - uint256 releaseAt + uint256 releasableAt ); /** diff --git a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol index fef08d094..a45a7bee2 100644 --- a/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol +++ b/packages/horizon/test/data-service/extensions/DataServiceFees.t.sol @@ -159,12 +159,12 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { assertEq(beforeLockedStake + calcValues.stakeToLock, afterLockedStake); // it should create a stake claim - (uint256 claimTokens, uint256 createdAt, uint256 releaseAt, bytes32 nextClaim) = dataService.claims( + (uint256 claimTokens, uint256 createdAt, uint256 releasableAt, bytes32 nextClaim) = dataService.claims( calcValues.predictedClaimId ); assertEq(claimTokens, calcValues.stakeToLock); assertEq(createdAt, block.timestamp); - assertEq(releaseAt, calcValues.unlockTimestamp); + assertEq(releasableAt, calcValues.unlockTimestamp); assertEq(nextClaim, bytes32(0)); // it should update the list @@ -196,12 +196,12 @@ contract DataServiceFeesTest is HorizonStakingSharedTest { head: beforeHead }); while (calcValues.head != bytes32(0) && (calcValues.claimsCount < numClaimsToRelease || numClaimsToRelease == 0)) { - (uint256 claimTokens, , uint256 releaseAt, bytes32 nextClaim) = dataService.claims(calcValues.head); - if (releaseAt > block.timestamp) { + (uint256 claimTokens, , uint256 releasableAt, bytes32 nextClaim) = dataService.claims(calcValues.head); + if (releasableAt > block.timestamp) { break; } - emit IDataServiceFees.StakeClaimReleased(serviceProvider, calcValues.head, claimTokens, releaseAt); + emit IDataServiceFees.StakeClaimReleased(serviceProvider, calcValues.head, claimTokens, releasableAt); calcValues.head = nextClaim; calcValues.tokensReleased += claimTokens; calcValues.claimsCount++; diff --git a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol index 67338fe64..a5563176b 100644 --- a/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol +++ b/packages/subgraph-service/test/subgraphService/SubgraphService.t.sol @@ -328,7 +328,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { uint64 disputePeriod = disputeManager.getDisputePeriod(); assertEq(stakeClaim.tokens, tokensToLock); assertEq(stakeClaim.createdAt, block.timestamp); - assertEq(stakeClaim.releaseAt, block.timestamp + disputePeriod); + assertEq(stakeClaim.releasableAt, block.timestamp + disputePeriod); assertEq(stakeClaim.nextClaim, bytes32(0)); } else if (_paymentType == IGraphPayments.PaymentTypes.IndexingRewards) { // Update allocation after collecting rewards @@ -419,7 +419,7 @@ contract SubgraphServiceTest is SubgraphServiceSharedTest { } function _getStakeClaim(bytes32 _claimId) private view returns (IDataServiceFees.StakeClaim memory) { - (uint256 tokens, uint256 createdAt, uint256 releaseAt, bytes32 nextClaim) = subgraphService.claims(_claimId); - return IDataServiceFees.StakeClaim(tokens, createdAt, releaseAt, nextClaim); + (uint256 tokens, uint256 createdAt, uint256 releasableAt, bytes32 nextClaim) = subgraphService.claims(_claimId); + return IDataServiceFees.StakeClaim(tokens, createdAt, releasableAt, nextClaim); } } From 78821abd2428fd94a25a361dcae6e9dfcf06c9b1 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 19:04:03 +0100 Subject: [PATCH 10/13] fix: "Resolve the conflicting dispute" updated to "Draw the conflicting dispute". --- packages/contracts/contracts/disputes/DisputeManager.sol | 2 +- packages/subgraph-service/contracts/DisputeManager.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contracts/contracts/disputes/DisputeManager.sol b/packages/contracts/contracts/disputes/DisputeManager.sol index 6700ec341..53bf43b1e 100644 --- a/packages/contracts/contracts/disputes/DisputeManager.sol +++ b/packages/contracts/contracts/disputes/DisputeManager.sol @@ -606,7 +606,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Resolve the conflicting dispute if there is any for the one passed to this function. + * @dev Draw the conflicting dispute if there is any for the one passed to this function. * @param _dispute Dispute * @return True if resolved */ diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index 8bf0f363b..f7e6be9ab 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -560,7 +560,7 @@ contract DisputeManager is } /** - * @notice Resolve the conflicting dispute if there is any for the one passed to this function. + * @notice Draw the conflicting dispute if there is any for the one passed to this function. * @param _dispute Dispute * @return True if resolved */ From 99d9bba0ffaaacac162364b0f8bf6e71e8a9856c Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 19:27:16 +0100 Subject: [PATCH 11/13] fix: MAX_THAWING_PERIOD rename to MAX_WAIT_PERIOD in PaymentsEscrow and Constants --- .../horizon/contracts/interfaces/IPaymentsEscrow.sol | 4 ++-- packages/horizon/contracts/payments/PaymentsEscrow.sol | 10 +++++----- packages/subgraph-service/test/SubgraphBaseTest.t.sol | 2 +- packages/subgraph-service/test/utils/Constants.sol | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol b/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol index 4b98cf0a5..47d5c8308 100644 --- a/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol +++ b/packages/horizon/contracts/interfaces/IPaymentsEscrow.sol @@ -131,9 +131,9 @@ interface IPaymentsEscrow { /** * @notice Thrown when setting the thawing period to a value greater than the maximum * @param thawingPeriod The thawing period - * @param maxThawingPeriod The maximum thawing period + * @param maxWaitPeriod The maximum wait period */ - error PaymentsEscrowThawingPeriodTooLong(uint256 thawingPeriod, uint256 maxThawingPeriod); + error PaymentsEscrowThawingPeriodTooLong(uint256 thawingPeriod, uint256 maxWaitPeriod); /** * @notice Thrown when a collector has insufficient allowance to collect funds diff --git a/packages/horizon/contracts/payments/PaymentsEscrow.sol b/packages/horizon/contracts/payments/PaymentsEscrow.sol index 5d0694346..b96bb56be 100644 --- a/packages/horizon/contracts/payments/PaymentsEscrow.sol +++ b/packages/horizon/contracts/payments/PaymentsEscrow.sol @@ -31,7 +31,7 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory, /// @notice The maximum thawing period (in seconds) for both escrow withdrawal and signer revocation /// @dev This is a precautionary measure to avoid inadvertedly locking funds for too long - uint256 public constant MAX_THAWING_PERIOD = 90 days; + uint256 public constant MAX_WAIT_PERIOD = 90 days; /// @notice Thawing period in seconds for authorized collectors uint256 public immutable REVOKE_COLLECTOR_THAWING_PERIOD; @@ -56,12 +56,12 @@ contract PaymentsEscrow is Initializable, MulticallUpgradeable, GraphDirectory, uint256 withdrawEscrowThawingPeriod ) GraphDirectory(controller) { require( - revokeCollectorThawingPeriod <= MAX_THAWING_PERIOD, - PaymentsEscrowThawingPeriodTooLong(revokeCollectorThawingPeriod, MAX_THAWING_PERIOD) + revokeCollectorThawingPeriod <= MAX_WAIT_PERIOD, + PaymentsEscrowThawingPeriodTooLong(revokeCollectorThawingPeriod, MAX_WAIT_PERIOD) ); require( - withdrawEscrowThawingPeriod <= MAX_THAWING_PERIOD, - PaymentsEscrowThawingPeriodTooLong(withdrawEscrowThawingPeriod, MAX_THAWING_PERIOD) + withdrawEscrowThawingPeriod <= MAX_WAIT_PERIOD, + PaymentsEscrowThawingPeriodTooLong(withdrawEscrowThawingPeriod, MAX_WAIT_PERIOD) ); REVOKE_COLLECTOR_THAWING_PERIOD = revokeCollectorThawingPeriod; diff --git a/packages/subgraph-service/test/SubgraphBaseTest.t.sol b/packages/subgraph-service/test/SubgraphBaseTest.t.sol index 6ab0c6d24..43065add6 100644 --- a/packages/subgraph-service/test/SubgraphBaseTest.t.sol +++ b/packages/subgraph-service/test/SubgraphBaseTest.t.sol @@ -189,7 +189,7 @@ abstract contract SubgraphBaseTest is Utils, Constants { resetPrank(users.deployer); subgraphService.transferOwnership(users.governor); resetPrank(users.governor); - staking.setMaxThawingPeriod(MAX_THAWING_PERIOD); + staking.setMaxThawingPeriod(MAX_WAIT_PERIOD); epochManager.setEpochLength(EPOCH_LENGTH); subgraphService.setMaxPOIStaleness(maxPOIStaleness); subgraphService.setCurationCut(curationCut); diff --git a/packages/subgraph-service/test/utils/Constants.sol b/packages/subgraph-service/test/utils/Constants.sol index e70ca8b41..eabf5e7b2 100644 --- a/packages/subgraph-service/test/utils/Constants.sol +++ b/packages/subgraph-service/test/utils/Constants.sol @@ -18,7 +18,7 @@ abstract contract Constants { uint256 public constant maxPOIStaleness = 28 days; uint256 public constant curationCut = 10000; // Staking - uint64 internal constant MAX_THAWING_PERIOD = 28 days; + uint64 internal constant MAX_WAIT_PERIOD = 28 days; // GraphEscrow parameters uint256 internal constant withdrawEscrowThawingPeriod = 60; uint256 internal constant revokeCollectorThawingPeriod = 60; From 9503f1dc054c9b4ee80611b7721bc7b9a4a04491 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Fri, 20 Sep 2024 19:29:55 +0100 Subject: [PATCH 12/13] fix: challenger and submitter updated to fisherman. --- .../contracts/disputes/DisputeManager.sol | 30 ++++++++--------- .../contracts/test/unit/disputes/common.ts | 4 +-- .../contracts/DisputeManager.sol | 32 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/packages/contracts/contracts/disputes/DisputeManager.sol b/packages/contracts/contracts/disputes/DisputeManager.sol index 53bf43b1e..fed301de0 100644 --- a/packages/contracts/contracts/disputes/DisputeManager.sol +++ b/packages/contracts/contracts/disputes/DisputeManager.sol @@ -29,7 +29,7 @@ import "./IDisputeManager.sol"; * Indexers present a Proof of Indexing (POI) when they close allocations to prove * they were indexing a subgraph. The Staking contract emits that proof with the format * keccak256(indexer.address, POI). - * Any challenger can dispute the validity of a POI by submitting a dispute to this contract + * Any fisherman can dispute the validity of a POI by submitting a dispute to this contract * along with a deposit. * * Arbitration: @@ -355,8 +355,8 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _deposit Amount of tokens staked as deposit */ function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external override returns (bytes32) { - // Get funds from submitter - _pullSubmitterDeposit(_deposit); + // Get funds from fisherman + _pullFishermanDeposit(_deposit); // Create a dispute return @@ -372,7 +372,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @dev Create query disputes for two conflicting attestations. * A conflicting attestation is a proof presented by two different indexers * where for the same request on a subgraph the response is different. - * For this type of dispute the submitter is not required to present a deposit + * For this type of dispute the fisherman is not required to present a deposit * as one of the attestation is considered to be right. * Two linked disputes will be created and if the arbitrator resolve one, the other * one will be automatically resolved. @@ -470,14 +470,14 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa /** * @dev Create an indexing dispute for the arbitrator to resolve. * The disputes are created in reference to an allocationID - * This function is called by a challenger that will need to `_deposit` at + * This function is called by a fisherman that will need to `_deposit` at * least `minimumDeposit` GRT tokens. * @param _allocationID The allocation to dispute * @param _deposit Amount of tokens staked as deposit */ function createIndexingDispute(address _allocationID, uint256 _deposit) external override returns (bytes32) { - // Get funds from submitter - _pullSubmitterDeposit(_deposit); + // Get funds from fisherman + _pullFishermanDeposit(_deposit); // Create a dispute return _createIndexingDisputeWithAllocation(msg.sender, _deposit, _allocationID); @@ -485,7 +485,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa /** * @dev Create indexing dispute internal function. - * @param _fisherman The challenger creating the dispute + * @param _fisherman The fisherman creating the dispute * @param _deposit Amount of tokens staked as deposit * @param _allocationID Allocation disputed */ @@ -621,10 +621,10 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Pull deposit from submitter account. + * @dev Pull deposit from fisherman account. * @param _deposit Amount of tokens to deposit */ - function _pullSubmitterDeposit(uint256 _deposit) private { + function _pullFishermanDeposit(uint256 _deposit) private { // Ensure that fisherman has staked at least the minimum amount require(_deposit >= minimumDeposit, "Dispute deposit is under minimum required"); @@ -633,17 +633,17 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Make the staking contract slash the indexer and reward the challenger. - * Give the challenger a reward equal to the fishermanRewardPercentage of slashed amount + * @dev Make the staking contract slash the indexer and reward the fisherman. + * Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount * @param _indexer Address of the indexer - * @param _challenger Address of the challenger + * @param _fisherman Address of the fisherman * @param _disputeType Type of dispute * @return slashAmount Dispute slash amount * @return rewardsAmount Dispute rewards amount */ function _slashIndexer( address _indexer, - address _challenger, + address _fisherman, DisputeType _disputeType ) private returns (uint256 slashAmount, uint256 rewardsAmount) { IStaking staking = staking(); @@ -660,7 +660,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // Have staking contract slash the indexer and reward the fisherman // Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount - staking.slash(_indexer, slashAmount, rewardsAmount, _challenger); + staking.slash(_indexer, slashAmount, rewardsAmount, _fisherman); } /** diff --git a/packages/contracts/test/unit/disputes/common.ts b/packages/contracts/test/unit/disputes/common.ts index 37d77fd5a..f72f3c6cf 100644 --- a/packages/contracts/test/unit/disputes/common.ts +++ b/packages/contracts/test/unit/disputes/common.ts @@ -16,7 +16,7 @@ export interface Dispute { export function createQueryDisputeID( attestation: Attestation, indexerAddress: string, - submitterAddress: string, + fishermanAddress: string, ): string { return solidityKeccak256( ['bytes32', 'bytes32', 'bytes32', 'address', 'address'], @@ -25,7 +25,7 @@ export function createQueryDisputeID( attestation.responseCID, attestation.subgraphDeploymentID, indexerAddress, - submitterAddress, + fishermanAddress, ], ) } diff --git a/packages/subgraph-service/contracts/DisputeManager.sol b/packages/subgraph-service/contracts/DisputeManager.sol index f7e6be9ab..d900e6cf1 100644 --- a/packages/subgraph-service/contracts/DisputeManager.sol +++ b/packages/subgraph-service/contracts/DisputeManager.sol @@ -34,7 +34,7 @@ import { AttestationManager } from "./utilities/AttestationManager.sol"; * Indexers present a Proof of Indexing (POI) when they close allocations to prove * they were indexing a subgraph. The Staking contract emits that proof with the format * keccak256(indexer.address, POI). - * Any challenger can dispute the validity of a POI by submitting a dispute to this contract + * Any fisherman can dispute the validity of a POI by submitting a dispute to this contract * along with a deposit. * * Arbitration: @@ -127,18 +127,18 @@ 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 and it will pull `disputeDeposit` GRT tokens. + * This function is called by a fisherman and it will pull `disputeDeposit` GRT tokens. * * Requirements: - * - Challenger must have previously approved this contract to pull `disputeDeposit` amount + * - fisherman 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 */ function createIndexingDispute(address allocationId, bytes32 poi) external override returns (bytes32) { - // Get funds from submitter - _pullSubmitterDeposit(); + // Get funds from fisherman + _pullFishermanDeposit(); // Create a dispute return _createIndexingDisputeWithAllocation(msg.sender, disputeDeposit, allocationId, poi); @@ -146,17 +146,17 @@ contract DisputeManager is /** * @notice Create a query dispute for the arbitrator to resolve. - * This function is called by a challenger and it will pull `disputeDeposit` GRT tokens. + * This function is called by a fisherman and it will pull `disputeDeposit` GRT tokens. * * * Requirements: - * - Challenger must have previously approved this contract to pull `disputeDeposit` amount + * - fisherman must have previously approved this contract to pull `disputeDeposit` amount * of tokens from their balance. * - * @param attestationData Attestation bytes submitted by the challenger + * @param attestationData Attestation bytes submitted by the fisherman */ function createQueryDispute(bytes calldata attestationData) external override returns (bytes32) { - // Get funds from submitter - _pullSubmitterDeposit(); + // Get funds from fisherman + _pullFishermanDeposit(); // Create a dispute return @@ -172,7 +172,7 @@ contract DisputeManager is * @notice Create query disputes for two conflicting attestations. * A conflicting attestation is a proof presented by two different indexers * where for the same request on a subgraph the response is different. - * For this type of dispute the submitter is not required to present a deposit + * For this type of dispute the fisherman is not required to present a deposit * as one of the attestation is considered to be right. * Two linked disputes will be created and if the arbitrator resolve one, the other * one will be automatically resolved. @@ -515,7 +515,7 @@ contract DisputeManager is /** * @notice Create indexing dispute internal function. - * @param _fisherman The challenger creating the dispute + * @param _fisherman The fisherman creating the dispute * @param _deposit Amount of tokens staked as deposit * @param _allocationId Allocation disputed * @param _poi The POI being disputed @@ -590,16 +590,16 @@ contract DisputeManager is } /** - * @notice Pull `disputeDeposit` from submitter account. + * @notice Pull `disputeDeposit` from fisherman account. */ - function _pullSubmitterDeposit() private { + function _pullFishermanDeposit() private { // Transfer tokens to deposit from fisherman to this contract _graphToken().pullTokens(msg.sender, disputeDeposit); } /** - * @notice Make the subgraph service contract slash the indexer and reward the challenger. - * Give the challenger a reward equal to the fishermanRewardPercentage of slashed amount + * @notice Make the subgraph service contract slash the indexer and reward the fisherman. + * Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount * @param _indexer Address of the indexer * @param _tokensSlash Amount of tokens to slash from the indexer * @param _tokensStakeSnapshot Snapshot of the indexer's stake at the time of the dispute creation From e33bf12ae2fdbbac69700dc8dc08a04a5ac3f649 Mon Sep 17 00:00:00 2001 From: MoonBoi9001 Date: Wed, 2 Oct 2024 10:18:36 +0100 Subject: [PATCH 13/13] fix: revert DisputeManager.sol to previous state --- .../contracts/disputes/DisputeManager.sol | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/contracts/contracts/disputes/DisputeManager.sol b/packages/contracts/contracts/disputes/DisputeManager.sol index fed301de0..6700ec341 100644 --- a/packages/contracts/contracts/disputes/DisputeManager.sol +++ b/packages/contracts/contracts/disputes/DisputeManager.sol @@ -29,7 +29,7 @@ import "./IDisputeManager.sol"; * Indexers present a Proof of Indexing (POI) when they close allocations to prove * they were indexing a subgraph. The Staking contract emits that proof with the format * keccak256(indexer.address, POI). - * Any fisherman can dispute the validity of a POI by submitting a dispute to this contract + * Any challenger can dispute the validity of a POI by submitting a dispute to this contract * along with a deposit. * * Arbitration: @@ -355,8 +355,8 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _deposit Amount of tokens staked as deposit */ function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external override returns (bytes32) { - // Get funds from fisherman - _pullFishermanDeposit(_deposit); + // Get funds from submitter + _pullSubmitterDeposit(_deposit); // Create a dispute return @@ -372,7 +372,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @dev Create query disputes for two conflicting attestations. * A conflicting attestation is a proof presented by two different indexers * where for the same request on a subgraph the response is different. - * For this type of dispute the fisherman is not required to present a deposit + * For this type of dispute the submitter is not required to present a deposit * as one of the attestation is considered to be right. * Two linked disputes will be created and if the arbitrator resolve one, the other * one will be automatically resolved. @@ -470,14 +470,14 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa /** * @dev Create an indexing dispute for the arbitrator to resolve. * The disputes are created in reference to an allocationID - * This function is called by a fisherman that will need to `_deposit` at + * This function is called by a challenger that will need to `_deposit` at * least `minimumDeposit` GRT tokens. * @param _allocationID The allocation to dispute * @param _deposit Amount of tokens staked as deposit */ function createIndexingDispute(address _allocationID, uint256 _deposit) external override returns (bytes32) { - // Get funds from fisherman - _pullFishermanDeposit(_deposit); + // Get funds from submitter + _pullSubmitterDeposit(_deposit); // Create a dispute return _createIndexingDisputeWithAllocation(msg.sender, _deposit, _allocationID); @@ -485,7 +485,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa /** * @dev Create indexing dispute internal function. - * @param _fisherman The fisherman creating the dispute + * @param _fisherman The challenger creating the dispute * @param _deposit Amount of tokens staked as deposit * @param _allocationID Allocation disputed */ @@ -606,7 +606,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Draw the conflicting dispute if there is any for the one passed to this function. + * @dev Resolve the conflicting dispute if there is any for the one passed to this function. * @param _dispute Dispute * @return True if resolved */ @@ -621,10 +621,10 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Pull deposit from fisherman account. + * @dev Pull deposit from submitter account. * @param _deposit Amount of tokens to deposit */ - function _pullFishermanDeposit(uint256 _deposit) private { + function _pullSubmitterDeposit(uint256 _deposit) private { // Ensure that fisherman has staked at least the minimum amount require(_deposit >= minimumDeposit, "Dispute deposit is under minimum required"); @@ -633,17 +633,17 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa } /** - * @dev Make the staking contract slash the indexer and reward the fisherman. - * Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount + * @dev Make the staking contract slash the indexer and reward the challenger. + * Give the challenger a reward equal to the fishermanRewardPercentage of slashed amount * @param _indexer Address of the indexer - * @param _fisherman Address of the fisherman + * @param _challenger Address of the challenger * @param _disputeType Type of dispute * @return slashAmount Dispute slash amount * @return rewardsAmount Dispute rewards amount */ function _slashIndexer( address _indexer, - address _fisherman, + address _challenger, DisputeType _disputeType ) private returns (uint256 slashAmount, uint256 rewardsAmount) { IStaking staking = staking(); @@ -660,7 +660,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // Have staking contract slash the indexer and reward the fisherman // Give the fisherman a reward equal to the fishermanRewardPercentage of slashed amount - staking.slash(_indexer, slashAmount, rewardsAmount, _fisherman); + staking.slash(_indexer, slashAmount, rewardsAmount, _challenger); } /**