@@ -97,7 +97,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
97
97
/**
98
98
* @dev Emitted when `indexer` allocated `tokens` amount to `subgraphDeploymentID`
99
99
* during `epoch`.
100
- * `channelID` is the address of the indexer in the channel multisig .
100
+ * `allocationID` indexer derived address used to identify the allocation .
101
101
* `channelPubKey` is the public key used for routing payments to the indexer channel.
102
102
* `price` price the `indexer` will charge for serving queries of the `subgraphDeploymentID`.
103
103
*/
@@ -106,14 +106,14 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
106
106
bytes32 indexed subgraphDeploymentID ,
107
107
uint256 epoch ,
108
108
uint256 tokens ,
109
- address channelID ,
109
+ address allocationID ,
110
110
bytes channelPubKey ,
111
111
uint256 price ,
112
112
address proxy
113
113
);
114
114
115
115
/**
116
- * @dev Emitted when `indexer` withdrew `tokens` amount in `epoch` from `channelID ` channel.
116
+ * @dev Emitted when `indexer` withdrew `tokens` amount in `epoch` from `allocationID ` channel.
117
117
* The funds are related to `subgraphDeploymentID`.
118
118
* `from` attribute records the the multisig contract from where it was settled.
119
119
*/
@@ -122,14 +122,14 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
122
122
bytes32 indexed subgraphDeploymentID ,
123
123
uint256 epoch ,
124
124
uint256 tokens ,
125
- address channelID ,
125
+ address allocationID ,
126
126
address from ,
127
127
uint256 curationFees ,
128
128
uint256 rebateFees
129
129
);
130
130
131
131
/**
132
- * @dev Emitted when `indexer` settled an allocation in `epoch` for `channelID ` channel.
132
+ * @dev Emitted when `indexer` settled an allocation in `epoch` for `allocationID ` channel.
133
133
* The `tokens` getting unallocated from `subgraphDeploymentID`.
134
134
* The `effectiveAllocation` are the tokens allocated from creation to settlement.
135
135
*/
@@ -138,7 +138,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
138
138
bytes32 indexed subgraphDeploymentID ,
139
139
uint256 epoch ,
140
140
uint256 tokens ,
141
- address channelID ,
141
+ address allocationID ,
142
142
uint256 effectiveAllocation ,
143
143
address sender
144
144
);
@@ -152,7 +152,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
152
152
event RebateClaimed (
153
153
address indexed indexer ,
154
154
bytes32 indexed subgraphDeploymentID ,
155
- address channelID ,
155
+ address allocationID ,
156
156
uint256 epoch ,
157
157
uint256 forEpoch ,
158
158
uint256 tokens ,
@@ -265,7 +265,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
265
265
}
266
266
267
267
/**
268
- * @dev Set the max allocation time allowed for indexers stake on channels .
268
+ * @dev Set the max time allowed for indexers stake on allocations .
269
269
* @param _maxAllocationEpochs Allocation duration limit in epochs
270
270
*/
271
271
function setMaxAllocationEpochs (uint32 _maxAllocationEpochs ) external override onlyGovernor {
@@ -375,12 +375,12 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
375
375
}
376
376
377
377
/**
378
- * @dev Return if channelID (address) was used as a channel in any allocation .
379
- * @param _channelID Address used as signer for indexer in channel
380
- * @return True if channelID already used
378
+ * @dev Return if allocationID is used.
379
+ * @param _allocationID Address used as signer by the indexer for an allocation
380
+ * @return True if allocationID already used
381
381
*/
382
- function isChannel (address _channelID ) external override view returns (bool ) {
383
- return _getAllocationState (_channelID ) != AllocationState.Null;
382
+ function isChannel (address _allocationID ) external override view returns (bool ) {
383
+ return _getAllocationState (_allocationID ) != AllocationState.Null;
384
384
}
385
385
386
386
/**
@@ -393,26 +393,31 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
393
393
}
394
394
395
395
/**
396
- * @dev Return the allocation for a particular channel identifier .
397
- * @param _channelID Address used as channel identifier where stake has been allocated
396
+ * @dev Return the allocation by ID .
397
+ * @param _allocationID Address used as allocation identifier
398
398
* @return Allocation data
399
399
*/
400
- function getAllocation (address _channelID ) external override view returns (Allocation memory ) {
401
- return allocations[_channelID];
400
+ function getAllocation (address _allocationID )
401
+ external
402
+ override
403
+ view
404
+ returns (Allocation memory )
405
+ {
406
+ return allocations[_allocationID];
402
407
}
403
408
404
409
/**
405
410
* @dev Return the current state of an allocation.
406
- * @param _channelID Address used as the allocation channel identifier
411
+ * @param _allocationID Address used as the allocation identifier
407
412
* @return AllocationState
408
413
*/
409
- function getAllocationState (address _channelID )
414
+ function getAllocationState (address _allocationID )
410
415
external
411
416
override
412
417
view
413
418
returns (AllocationState)
414
419
{
415
- return _getAllocationState (_channelID );
420
+ return _getAllocationState (_allocationID );
416
421
}
417
422
418
423
/**
@@ -748,16 +753,16 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
748
753
}
749
754
750
755
/**
751
- * @dev Settle a channel and unallocate the staked tokens.
752
- * @param _channelID The channel identifier for the allocation
756
+ * @dev Settle an allocation and free the staked tokens.
757
+ * @param _allocationID The allocation identifier
753
758
*/
754
- function settle (address _channelID ) external override {
755
- // Get allocation related to the channel identifier
756
- Allocation storage alloc = allocations[_channelID ];
757
- AllocationState allocState = _getAllocationState (_channelID );
759
+ function settle (address _allocationID ) external override {
760
+ // Get allocation
761
+ Allocation storage alloc = allocations[_allocationID ];
762
+ AllocationState allocState = _getAllocationState (_allocationID );
758
763
759
764
// Channel must exist and be allocated
760
- require (allocState == AllocationState.Active, "Settle: channel must be active " );
765
+ require (allocState == AllocationState.Active, "Settle: allocation must be active " );
761
766
762
767
// Get indexer stakes
763
768
Stakes.Indexer storage indexerStake = stakes[alloc.indexer];
@@ -779,7 +784,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
779
784
}
780
785
781
786
// Settle the allocation and start counting a period to finalize any other
782
- // withdrawal from the related channel .
787
+ // withdrawal for the allocation .
783
788
alloc.settledAtEpoch = currentEpoch;
784
789
alloc.effectiveAllocation = _getEffectiveAllocation (alloc.tokens, epochs);
785
790
@@ -795,28 +800,27 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
795
800
alloc.subgraphDeploymentID,
796
801
alloc.settledAtEpoch,
797
802
alloc.tokens,
798
- _channelID ,
803
+ _allocationID ,
799
804
alloc.effectiveAllocation,
800
805
msg .sender
801
806
);
802
807
}
803
808
804
809
/**
805
- * @dev Collect query fees from a channel .
806
- * Funds received are only accepted from a channel multisig proxy contract .
810
+ * @dev Collect query fees for an allocation .
811
+ * Funds received are only accepted from a valid source .
807
812
* @param _tokens Amount of tokens to collect
808
813
*/
809
- function collect (uint256 _tokens , address _channelID ) external override {
810
- Allocation memory alloc = allocations[_channelID ];
814
+ function collect (uint256 _tokens , address _allocationID ) external override {
815
+ Allocation memory alloc = allocations[_allocationID ];
811
816
812
- // Channel identifier validation
813
- require (_channelID != address (0 ), "Collect: invalid channel " );
817
+ // Allocation identifier validation
818
+ require (_allocationID != address (0 ), "Collect: invalid allocation " );
814
819
815
820
// The contract caller must be a channel proxy registered during allocation
816
- // The channelID must be related to the caller address
817
821
require (
818
822
alloc.channelProxy == msg .sender ,
819
- "Collect: caller is not related to the channel allocation "
823
+ "Collect: caller is not related to the allocation "
820
824
);
821
825
822
826
// Transfer tokens to collect from multisig to this contract
@@ -825,26 +829,26 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
825
829
"Collect: cannot transfer tokens to settle "
826
830
);
827
831
828
- _collect (_channelID , msg .sender , _tokens);
832
+ _collect (_allocationID , msg .sender , _tokens);
829
833
}
830
834
831
835
/**
832
836
* @dev Claim tokens from the rebate pool.
833
- * @param _channelID Identifier of the channel we are claiming funds from
837
+ * @param _allocationID Allocation from where we are claiming tokens
834
838
* @param _restake True if restake fees instead of transfer to indexer
835
839
*/
836
- function claim (address _channelID , bool _restake ) external override {
837
- // Get allocation related to the channel identifier
838
- Allocation storage alloc = allocations[_channelID ];
839
- AllocationState allocState = _getAllocationState (_channelID );
840
+ function claim (address _allocationID , bool _restake ) external override {
841
+ // Get allocation
842
+ Allocation storage alloc = allocations[_allocationID ];
843
+ AllocationState allocState = _getAllocationState (_allocationID );
840
844
841
845
// Validate ownership
842
846
require (_onlyAuthOrDelegator (alloc.indexer), "Rebate: caller must be authorized " );
843
847
844
848
// Funds can only be claimed after a period of time passed since settlement
845
849
require (
846
850
allocState == AllocationState.Finalized,
847
- "Rebate: channel must be in finalized state "
851
+ "Rebate: allocation must be in finalized state "
848
852
);
849
853
850
854
// Find a rebate pool for the settled epoch
@@ -862,8 +866,8 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
862
866
uint256 delegationFees = _collectDelegationFees (alloc.indexer, tokensToClaim);
863
867
tokensToClaim = tokensToClaim.sub (delegationFees);
864
868
865
- // Purgue allocation data except for:
866
- // - indexer: used in disputes and to avoid reusing a channelID
869
+ // Purge allocation data except for:
870
+ // - indexer: used in disputes and to avoid reusing an allocationID
867
871
// - subgraphDeploymentID: used in disputes
868
872
uint256 settledAtEpoch = alloc.settledAtEpoch;
869
873
alloc.tokens = 0 ; // This avoid collect(), settle() and claim() to be called
@@ -891,7 +895,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
891
895
emit RebateClaimed (
892
896
alloc.indexer,
893
897
alloc.subgraphDeploymentID,
894
- _channelID ,
898
+ _allocationID ,
895
899
epochManager.currentEpoch (),
896
900
settledAtEpoch,
897
901
tokensToClaim,
@@ -959,27 +963,27 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
959
963
// Get the Ethereum address from the public key and use as channel identifier.
960
964
// The channel identifier is the address of the indexer signing party of a multisig that
961
965
// will hold the funds received when the channel is settled.
962
- address channelID = address (uint256 (keccak256 (_sliceByte (bytes (_channelPubKey)))));
966
+ address allocationID = address (uint256 (keccak256 (_sliceByte (bytes (_channelPubKey)))));
963
967
964
- // Cannot reuse a channelID that has already been used in an allocation
968
+ // Cannot reuse an allocationID that has already been used in an allocation
965
969
require (
966
- _getAllocationState (channelID ) == AllocationState.Null,
967
- "Allocation: channel ID already used "
970
+ _getAllocationState (allocationID ) == AllocationState.Null,
971
+ "Allocation: allocation ID already used "
968
972
);
969
973
970
- // Create allocation linked to the channel identifier
971
- // Channel identifiers are not reused
974
+ // Creates an allocation
975
+ // Allocation identifiers are not reused
972
976
// The channel proxy address is the contract that will send tokens to be collected to
973
977
// this contract
974
- allocations[channelID ] = Allocation (
978
+ allocations[allocationID ] = Allocation (
975
979
_indexer,
976
980
_subgraphDeploymentID,
977
981
_tokens, // Tokens allocated
978
982
epochManager.currentEpoch (), // createdAtEpoch
979
983
0 , // settledAtEpoch
980
984
0 , // Initialize with zero collected fees
981
985
0 , // Initialize effective allocation
982
- _channelProxy // Source address of channel funds
986
+ _channelProxy // Source address of allocation collected funds
983
987
);
984
988
985
989
// Mark allocated tokens as used
@@ -988,36 +992,36 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
988
992
emit AllocationCreated (
989
993
_indexer,
990
994
_subgraphDeploymentID,
991
- allocations[channelID ].createdAtEpoch,
992
- allocations[channelID ].tokens,
993
- channelID ,
995
+ allocations[allocationID ].createdAtEpoch,
996
+ allocations[allocationID ].tokens,
997
+ allocationID ,
994
998
_channelPubKey,
995
999
_price,
996
1000
_channelProxy
997
1001
);
998
1002
}
999
1003
1000
1004
/**
1001
- * @dev Withdraw and collect funds from the channel .
1002
- * @param _channelID ChannelID address of the indexer in the channel
1003
- * @param _from Multisig channel address that triggered withdrawal
1005
+ * @dev Withdraw and collect funds for an allocation .
1006
+ * @param _allocationID Allocation that is receiving collected funds
1007
+ * @param _from Source of collected funds for the allocation
1004
1008
* @param _tokens Amount of tokens to withdraw
1005
1009
*/
1006
1010
function _collect (
1007
- address _channelID ,
1011
+ address _allocationID ,
1008
1012
address _from ,
1009
1013
uint256 _tokens
1010
1014
) private {
1011
1015
uint256 rebateFees = _tokens;
1012
1016
1013
- // Get allocation related to the channel identifier
1014
- Allocation storage alloc = allocations[_channelID ];
1015
- AllocationState allocState = _getAllocationState (_channelID );
1017
+ // Get allocation
1018
+ Allocation storage alloc = allocations[_allocationID ];
1019
+ AllocationState allocState = _getAllocationState (_allocationID );
1016
1020
1017
- // The channel must be active or settled
1021
+ // The allocation must be active or settled
1018
1022
require (
1019
1023
allocState == AllocationState.Active || allocState == AllocationState.Settled,
1020
- "Collect: channel must be active or settled "
1024
+ "Collect: allocation must be active or settled "
1021
1025
);
1022
1026
1023
1027
// Collect protocol fees to be burned
@@ -1028,10 +1032,10 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
1028
1032
uint256 curationFees = _collectCurationFees (alloc.subgraphDeploymentID, rebateFees);
1029
1033
rebateFees = rebateFees.sub (curationFees);
1030
1034
1031
- // Collect funds in the allocated channel
1035
+ // Collect funds for the allocation
1032
1036
alloc.collectedFees = alloc.collectedFees.add (rebateFees);
1033
1037
1034
- // When channel allocation is settled redirect funds to the rebate pool
1038
+ // When allocation is settled redirect funds to the rebate pool
1035
1039
if (allocState == AllocationState.Settled) {
1036
1040
Rebates.Pool storage rebatePool = rebates[alloc.settledAtEpoch];
1037
1041
rebatePool.fees = rebatePool.fees.add (rebateFees);
@@ -1053,7 +1057,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
1053
1057
alloc.subgraphDeploymentID,
1054
1058
epochManager.currentEpoch (),
1055
1059
_tokens,
1056
- _channelID ,
1060
+ _allocationID ,
1057
1061
_from,
1058
1062
curationFees,
1059
1063
rebateFees
@@ -1195,11 +1199,11 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
1195
1199
1196
1200
/**
1197
1201
* @dev Return the current state of an allocation
1198
- * @param _channelID Address used as the allocation channel identifier
1202
+ * @param _allocationID Allocation identifier
1199
1203
* @return AllocationState
1200
1204
*/
1201
- function _getAllocationState (address _channelID ) private view returns (AllocationState) {
1202
- Allocation memory alloc = allocations[_channelID ];
1205
+ function _getAllocationState (address _allocationID ) private view returns (AllocationState) {
1206
+ Allocation memory alloc = allocations[_allocationID ];
1203
1207
1204
1208
if (alloc.indexer == address (0 )) {
1205
1209
return AllocationState.Null;
0 commit comments