@@ -344,11 +344,7 @@ contract DisputeManager is
344344
345345 /// @inheritdoc IDisputeManager
346346 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);
352348 }
353349
354350 /// @inheritdoc IDisputeManager
@@ -398,13 +394,6 @@ contract DisputeManager is
398394 // Get the indexer that signed the attestation
399395 address indexer = getAttestationIndexer (_attestation);
400396
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-
408397 // Create a disputeId
409398 bytes32 disputeId = keccak256 (
410399 abi.encodePacked (
@@ -419,8 +408,11 @@ contract DisputeManager is
419408 // Only one dispute at a time
420409 require (! isDisputeCreated (disputeId), DisputeManagerDisputeAlreadyCreated (disputeId));
421410
411+ // The indexer is disputable
412+ uint256 stakeSnapshot = _getStakeSnapshot (indexer);
413+ require (stakeSnapshot != 0 , DisputeManagerZeroTokens ());
414+
422415 // Store dispute
423- uint256 stakeSnapshot = _getStakeSnapshot (indexer, provision.tokens);
424416 uint256 cancellableAt = block .timestamp + disputePeriod;
425417 disputes[disputeId] = Dispute (
426418 indexer,
@@ -477,11 +469,10 @@ contract DisputeManager is
477469 require (indexer != address (0 ), DisputeManagerIndexerNotFound (_allocationId));
478470
479471 // 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 ());
482474
483475 // Store dispute
484- uint256 stakeSnapshot = _getStakeSnapshot (indexer, provision.tokens);
485476 uint256 cancellableAt = block .timestamp + disputePeriod;
486477 disputes[disputeId] = Dispute (
487478 alloc.indexer,
@@ -691,18 +682,19 @@ contract DisputeManager is
691682 * @dev A few considerations:
692683 * - We include both indexer and delegators stake.
693684 * - 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.
696685 *
697686 * Note that the snapshot can be inflated by delegators front-running the dispute creation with a delegation
698687 * to the indexer. Given the snapshot is a cap, the dispute outcome is uncertain and considering the cost of capital
699688 * and slashing risk, this is not a concern.
700689 * @param _indexer Indexer address
701- * @param _indexerStake Indexer's stake
702690 * @return Total stake snapshot
703691 */
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;
707699 }
708700}
0 commit comments