Skip to content

Commit dd2694c

Browse files
authored
admin: operators for channel allocation actions (#247)
Provide a way for an indexer to add operator keys for actions that could be done automatically and the key exposed in an external service/server.
1 parent 114725b commit dd2694c

File tree

6 files changed

+391
-167
lines changed

6 files changed

+391
-167
lines changed

.soliumignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ contracts/ens
66
contracts/erc1056
77
contracts/openzeppelin
88

9-
contracts/staking/Staking.sol
109
contracts/token/IGraphToken.sol
1110
contracts/upgrades/GraphProxy.sol
1211

contracts/EpochManager.sol

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ contract EpochManager is Governed {
2929
event EpochLengthUpdate(uint256 indexed epoch, uint256 epochLength);
3030

3131
/**
32-
* @dev Contract Constructor
32+
* @dev Contract Constructor.
3333
* @param _epochLength Epoch length in blocks
3434
*/
3535
constructor(uint256 _epochLength) public {
@@ -43,7 +43,7 @@ contract EpochManager is Governed {
4343
}
4444

4545
/**
46-
* @dev Set the epoch length
46+
* @dev Set the epoch length.
4747
* @notice Set epoch length to `_epochLength` blocks
4848
* @param _epochLength Epoch length in blocks
4949
*/
@@ -59,7 +59,7 @@ contract EpochManager is Governed {
5959
}
6060

6161
/**
62-
* @dev Run a new epoch, should be called once at the start of any epoch
62+
* @dev Run a new epoch, should be called once at the start of any epoch.
6363
* @notice Perform state changes for the current epoch
6464
*/
6565
function runEpoch() external {
@@ -74,23 +74,23 @@ contract EpochManager is Governed {
7474
}
7575

7676
/**
77-
* @dev Return true if the current epoch has already run
77+
* @dev Return true if the current epoch has already run.
7878
* @return Return true if epoch has run
7979
*/
8080
function isCurrentEpochRun() public view returns (bool) {
8181
return lastRunEpoch == currentEpoch();
8282
}
8383

8484
/**
85-
* @dev Return current block number
85+
* @dev Return current block number.
8686
* @return Block number
8787
*/
8888
function blockNum() public view returns (uint256) {
8989
return block.number;
9090
}
9191

9292
/**
93-
* @dev Return blockhash for a block
93+
* @dev Return blockhash for a block.
9494
* @return BlockHash for `_block` number
9595
*/
9696
function blockHash(uint256 _block) public view returns (bytes32) {
@@ -106,41 +106,41 @@ contract EpochManager is Governed {
106106
}
107107

108108
/**
109-
* @dev Return the current epoch, it may have not been run yet
109+
* @dev Return the current epoch, it may have not been run yet.
110110
* @return The current epoch based on epoch length
111111
*/
112112
function currentEpoch() public view returns (uint256) {
113113
return lastLengthUpdateEpoch.add(epochsSinceUpdate());
114114
}
115115

116116
/**
117-
* @dev Return block where the current epoch started
117+
* @dev Return block where the current epoch started.
118118
* @return The block number when the current epoch started
119119
*/
120120
function currentEpochBlock() public view returns (uint256) {
121121
return lastLengthUpdateBlock.add(epochsSinceUpdate().mul(epochLength));
122122
}
123123

124124
/**
125-
* @dev Return the number of blocks that passed since current epoch started
125+
* @dev Return the number of blocks that passed since current epoch started.
126126
* @return Blocks that passed since start of epoch
127127
*/
128128
function currentEpochBlockSinceStart() public view returns (uint256) {
129129
return blockNum() - currentEpochBlock();
130130
}
131131

132132
/**
133-
* @dev Return the number of epoch that passed since another epoch
133+
* @dev Return the number of epoch that passed since another epoch.
134134
* @param _epoch Epoch to use as since epoch value
135135
* @return Number of epochs and current epoch
136136
*/
137-
function epochsSince(uint256 _epoch) public view returns (uint256, uint256) {
137+
function epochsSince(uint256 _epoch) public view returns (uint256) {
138138
uint256 epoch = currentEpoch();
139-
return (_epoch < epoch ? epoch.sub(_epoch) : 0, epoch);
139+
return _epoch < epoch ? epoch.sub(_epoch) : 0;
140140
}
141141

142142
/**
143-
* @dev Return number of epochs passed since last epoch length update
143+
* @dev Return number of epochs passed since last epoch length update.
144144
* @return The number of epoch that passed since last epoch length update
145145
*/
146146
function epochsSinceUpdate() public view returns (uint256) {

contracts/staking/IStaking.sol

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ interface IStaking {
3333
// -- Delegation Data --
3434

3535
struct DelegationPool {
36-
uint256 cooldownBlocks;
37-
uint256 indexingRewardCut; // in PPM
38-
uint256 queryFeeCut; // in PPM
36+
uint32 cooldownBlocks;
37+
uint32 indexingRewardCut; // in PPM
38+
uint32 queryFeeCut; // in PPM
3939
uint256 updatedAtBlock;
4040
uint256 tokens;
4141
uint256 shares;
@@ -54,20 +54,24 @@ interface IStaking {
5454

5555
function setMaxAllocationEpochs(uint256 _maxAllocationEpochs) external;
5656

57-
function setDelegationParametersCooldown(uint256 _blocks) external;
57+
function setDelegationParametersCooldown(uint32 _blocks) external;
5858

59-
function setDelegationCapacity(uint256 _delegationCapacity) external;
59+
function setDelegationCapacity(uint32 _delegationCapacity) external;
6060

6161
function setDelegationParameters(
62-
uint256 _indexingRewardCut,
63-
uint256 _queryFeeCut,
64-
uint256 _cooldownBlocks
62+
uint32 _indexingRewardCut,
63+
uint32 _queryFeeCut,
64+
uint32 _cooldownBlocks
6565
) external;
6666

6767
function setSlasher(address _slasher, bool _allowed) external;
6868

6969
function setThawingPeriod(uint256 _thawingPeriod) external;
7070

71+
// -- Operation --
72+
73+
function setOperator(address _operator, bool _allowed) external;
74+
7175
// -- Staking --
7276

7377
function stake(uint256 _tokens) external;
@@ -105,6 +109,15 @@ interface IStaking {
105109
uint256 _price
106110
) external;
107111

112+
function allocateFrom(
113+
address _indexer,
114+
bytes32 _subgraphDeploymentID,
115+
uint256 _tokens,
116+
bytes calldata _channelPubKey,
117+
address _channelProxy,
118+
uint256 _price
119+
) external;
120+
108121
function settle(address _channelID) external;
109122

110123
function collect(uint256 _tokens, address _channelID) external;

0 commit comments

Comments
 (0)