@@ -344,11 +344,7 @@ contract DisputeManager is
344
344
345
345
/// @inheritdoc IDisputeManager
346
346
function getStakeSnapshot (address indexer ) external view override returns (uint256 ) {
347
- IHorizonStaking.Provision memory provision = _graphStaking ().getProvision (
348
- indexer,
349
- address (_getSubgraphService ())
350
- );
351
- return _getStakeSnapshot (indexer, provision.tokens);
347
+ return _getStakeSnapshot (indexer);
352
348
}
353
349
354
350
/// @inheritdoc IDisputeManager
@@ -398,13 +394,6 @@ contract DisputeManager is
398
394
// Get the indexer that signed the attestation
399
395
address indexer = getAttestationIndexer (_attestation);
400
396
401
- // The indexer is disputable
402
- IHorizonStaking.Provision memory provision = _graphStaking ().getProvision (
403
- indexer,
404
- address (_getSubgraphService ())
405
- );
406
- require (provision.tokens != 0 , DisputeManagerZeroTokens ());
407
-
408
397
// Create a disputeId
409
398
bytes32 disputeId = keccak256 (
410
399
abi.encodePacked (
@@ -419,8 +408,11 @@ contract DisputeManager is
419
408
// Only one dispute at a time
420
409
require (! isDisputeCreated (disputeId), DisputeManagerDisputeAlreadyCreated (disputeId));
421
410
411
+ // The indexer is disputable
412
+ uint256 stakeSnapshot = _getStakeSnapshot (indexer);
413
+ require (stakeSnapshot != 0 , DisputeManagerZeroTokens ());
414
+
422
415
// Store dispute
423
- uint256 stakeSnapshot = _getStakeSnapshot (indexer, provision.tokens);
424
416
uint256 cancellableAt = block .timestamp + disputePeriod;
425
417
disputes[disputeId] = Dispute (
426
418
indexer,
@@ -477,11 +469,10 @@ contract DisputeManager is
477
469
require (indexer != address (0 ), DisputeManagerIndexerNotFound (_allocationId));
478
470
479
471
// The indexer must be disputable
480
- IHorizonStaking.Provision memory provision = _graphStaking (). getProvision ( indexer, address (subgraphService_) );
481
- require (provision.tokens != 0 , DisputeManagerZeroTokens ());
472
+ uint256 stakeSnapshot = _getStakeSnapshot ( indexer);
473
+ require (stakeSnapshot != 0 , DisputeManagerZeroTokens ());
482
474
483
475
// Store dispute
484
- uint256 stakeSnapshot = _getStakeSnapshot (indexer, provision.tokens);
485
476
uint256 cancellableAt = block .timestamp + disputePeriod;
486
477
disputes[disputeId] = Dispute (
487
478
alloc.indexer,
@@ -691,18 +682,19 @@ contract DisputeManager is
691
682
* @dev A few considerations:
692
683
* - We include both indexer and delegators stake.
693
684
* - Thawing stake is not excluded from the snapshot.
694
- * - Delegators stake is capped at the delegation ratio to prevent delegators from inflating the snapshot
695
- * to increase the indexer slash amount.
696
685
*
697
686
* Note that the snapshot can be inflated by delegators front-running the dispute creation with a delegation
698
687
* to the indexer. Given the snapshot is a cap, the dispute outcome is uncertain and considering the cost of capital
699
688
* and slashing risk, this is not a concern.
700
689
* @param _indexer Indexer address
701
- * @param _indexerStake Indexer's stake
702
690
* @return Total stake snapshot
703
691
*/
704
- function _getStakeSnapshot (address _indexer , uint256 _indexerStake ) private view returns (uint256 ) {
705
- uint256 delegatorsStake = _graphStaking ().getDelegationPool (_indexer, address (_getSubgraphService ())).tokens;
706
- return _indexerStake + delegatorsStake;
692
+ function _getStakeSnapshot (address _indexer ) private view returns (uint256 ) {
693
+ address subgraphService = address (_getSubgraphService ());
694
+
695
+ IHorizonStaking.Provision memory provision = _graphStaking ().getProvision (_indexer, subgraphService);
696
+ uint256 delegatorsStake = _graphStaking ().getDelegationPool (_indexer, subgraphService).tokens;
697
+
698
+ return provision.tokens + delegatorsStake;
707
699
}
708
700
}
0 commit comments