Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions packages/contracts/contracts/disputes/DisputeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -470,22 +470,22 @@ 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);
}

/**
* @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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -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");

Expand All @@ -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();
Expand All @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/contracts/contracts/governance/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts/contracts/governance/Pausable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -31,15 +31,15 @@ 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;
lastPartialPauseTime = block.timestamp;
}
emit PartialPauseChanged(_partialPaused);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/unit/disputes/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -25,7 +25,7 @@ export function createQueryDisputeID(
attestation.responseCID,
attestation.subgraphDeploymentID,
indexerAddress,
submitterAddress,
fishermanAddress,
],
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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;
Expand All @@ -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)));
Expand All @@ -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);
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -79,16 +79,16 @@ 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}.
*
* 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.
*/
function acceptProvision(address serviceProvider, bytes calldata data) external;
function acceptProvisionPendingParameters(address serviceProvider, bytes calldata data) external;

/**
* @notice Service provider starts providing the service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
);

/**
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/horizon/contracts/interfaces/IPaymentsEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/horizon/contracts/payments/PaymentsEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions packages/horizon/contracts/staking/HorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading
Loading