@@ -93,7 +93,6 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
93
93
* @dev Emitted when `indexer` allocated `tokens` amount to `subgraphDeploymentID`
94
94
* during `epoch`.
95
95
* `allocationID` indexer derived address used to identify the allocation.
96
- * `channelPubKey` is the public key used for routing payments to the indexer channel.
97
96
* `metadata` additional information related to the allocation.
98
97
*/
99
98
event AllocationCreated (
@@ -102,7 +101,6 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
102
101
uint256 epoch ,
103
102
uint256 tokens ,
104
103
address allocationID ,
105
- bytes channelPubKey ,
106
104
bytes32 metadata ,
107
105
address assetHolder
108
106
);
@@ -684,22 +682,22 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
684
682
* @dev Allocate available tokens to a subgraph deployment.
685
683
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
686
684
* @param _tokens Amount of tokens to allocate
687
- * @param _channelPubKey The public key used to route payments
685
+ * @param _allocationID The allocation identifier
688
686
* @param _assetHolder Authorized sender address of collected funds
689
687
* @param _metadata IPFS hash for additional information about the allocation
690
688
*/
691
689
function allocate (
692
690
bytes32 _subgraphDeploymentID ,
693
691
uint256 _tokens ,
694
- bytes calldata _channelPubKey ,
692
+ address _allocationID ,
695
693
address _assetHolder ,
696
694
bytes32 _metadata
697
695
) external override notPaused {
698
696
_allocate (
699
697
msg .sender ,
700
698
_subgraphDeploymentID,
701
699
_tokens,
702
- _channelPubKey ,
700
+ _allocationID ,
703
701
_assetHolder,
704
702
_metadata
705
703
);
@@ -710,26 +708,19 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
710
708
* @param _indexer Indexer address to allocate funds from.
711
709
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
712
710
* @param _tokens Amount of tokens to allocate
713
- * @param _channelPubKey The public key used to route payments
711
+ * @param _allocationID The allocation identifier
714
712
* @param _assetHolder Authorized sender address of collected funds
715
713
* @param _metadata IPFS hash for additional information about the allocation
716
714
*/
717
715
function allocateFrom (
718
716
address _indexer ,
719
717
bytes32 _subgraphDeploymentID ,
720
718
uint256 _tokens ,
721
- bytes calldata _channelPubKey ,
719
+ address _allocationID ,
722
720
address _assetHolder ,
723
721
bytes32 _metadata
724
722
) external override notPaused {
725
- _allocate (
726
- _indexer,
727
- _subgraphDeploymentID,
728
- _tokens,
729
- _channelPubKey,
730
- _assetHolder,
731
- _metadata
732
- );
723
+ _allocate (_indexer, _subgraphDeploymentID, _tokens, _allocationID, _assetHolder, _metadata);
733
724
}
734
725
735
726
/**
@@ -752,7 +743,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
752
743
* @param _indexer Indexer address to allocate funds from.
753
744
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
754
745
* @param _tokens Amount of tokens to allocate
755
- * @param _channelPubKey The public key used to route payments
746
+ * @param _allocationID The allocation identifier
756
747
* @param _assetHolder Authorized sender address of collected funds
757
748
* @param _metadata IPFS hash for additional information about the allocation
758
749
*/
@@ -762,19 +753,12 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
762
753
address _indexer ,
763
754
bytes32 _subgraphDeploymentID ,
764
755
uint256 _tokens ,
765
- bytes calldata _channelPubKey ,
756
+ address _allocationID ,
766
757
address _assetHolder ,
767
758
bytes32 _metadata
768
759
) external override notPaused {
769
760
_closeAllocation (_closingAllocationID, _poi);
770
- _allocate (
771
- _indexer,
772
- _subgraphDeploymentID,
773
- _tokens,
774
- _channelPubKey,
775
- _assetHolder,
776
- _metadata
777
- );
761
+ _allocate (_indexer, _subgraphDeploymentID, _tokens, _allocationID, _assetHolder, _metadata);
778
762
}
779
763
780
764
/**
@@ -901,15 +885,15 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
901
885
* @param _indexer Indexer address to allocate funds from.
902
886
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
903
887
* @param _tokens Amount of tokens to allocate
904
- * @param _channelPubKey The public key used by the indexer to setup the off-chain channel
888
+ * @param _allocationID The allocationID will work to identify collected funds related to this allocation
905
889
* @param _assetHolder Authorized sender address of collected funds
906
890
* @param _metadata Metadata related to the allocation
907
891
*/
908
892
function _allocate (
909
893
address _indexer ,
910
894
bytes32 _subgraphDeploymentID ,
911
895
uint256 _tokens ,
912
- bytes memory _channelPubKey ,
896
+ address _allocationID ,
913
897
address _assetHolder ,
914
898
bytes32 _metadata
915
899
) internal {
@@ -920,23 +904,15 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
920
904
// Only allocations with a non-zero token amount are allowed
921
905
require (_tokens > 0 , "Cannot allocate zero tokens " );
922
906
923
- // Channel public key must be in uncompressed format
924
- require (
925
- uint8 (_channelPubKey[0 ]) == 4 && _channelPubKey.length == 65 ,
926
- "Invalid channel public key "
927
- );
907
+ // Check allocation ID
908
+ require (_allocationID != address (0 ), "Invalid allocationID " );
928
909
929
910
// Needs to have free capacity not used for other purposes to allocate
930
911
require (getIndexerCapacity (_indexer) >= _tokens, "Not enough tokens available to allocate " );
931
912
932
- // A channel public key is derived by the indexer when creating the offchain payment channel.
933
- // Get the Ethereum address from the public key and use as allocation identifier.
934
- // The allocationID will work to identify collected funds related to this allocation.
935
- address allocationID = address (uint256 (keccak256 (_sliceByte (bytes (_channelPubKey)))));
936
-
937
913
// Cannot reuse an allocationID that has already been used in an allocation
938
914
require (
939
- _getAllocationState (allocationID ) == AllocationState.Null,
915
+ _getAllocationState (_allocationID ) == AllocationState.Null,
940
916
"AllocationID already used "
941
917
);
942
918
@@ -954,7 +930,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
954
930
_assetHolder, // Source address for allocation collected funds
955
931
_updateRewards (_subgraphDeploymentID) // Initialize accumulated rewards per stake allocated
956
932
);
957
- allocations[allocationID ] = alloc;
933
+ allocations[_allocationID ] = alloc;
958
934
959
935
// Mark allocated tokens as used
960
936
indexerStake.allocate (alloc.tokens);
@@ -970,8 +946,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
970
946
_subgraphDeploymentID,
971
947
alloc.createdAtEpoch,
972
948
alloc.tokens,
973
- allocationID,
974
- _channelPubKey,
949
+ _allocationID,
975
950
_metadata,
976
951
_assetHolder
977
952
);
@@ -1309,38 +1284,6 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking {
1309
1284
return _tokens.mul ((shouldCap) ? maxAllocationEpochs : _numEpochs);
1310
1285
}
1311
1286
1312
- /**
1313
- * @dev Removes the first byte from a bytes array.
1314
- * @param _bytes Byte array to slice
1315
- * @return New bytes array
1316
- */
1317
- function _sliceByte (bytes memory _bytes ) internal pure returns (bytes memory ) {
1318
- bytes memory tempBytes;
1319
- uint256 length = _bytes.length - 1 ;
1320
-
1321
- assembly {
1322
- tempBytes := mload (0x40 )
1323
-
1324
- let lengthmod := and (length, 31 )
1325
- let mc := add (add (tempBytes, lengthmod), mul (0x20 , iszero (lengthmod)))
1326
- let end := add (mc, length)
1327
-
1328
- for {
1329
- let cc := add (add (add (_bytes, lengthmod), mul (0x20 , iszero (lengthmod))), 1 )
1330
- } lt (mc, end) {
1331
- mc := add (mc, 0x20 )
1332
- cc := add (cc, 0x20 )
1333
- } {
1334
- mstore (mc, mload (cc))
1335
- }
1336
-
1337
- mstore (tempBytes, length)
1338
- mstore (0x40 , and (add (mc, 31 ), not (31 )))
1339
- }
1340
-
1341
- return tempBytes;
1342
- }
1343
-
1344
1287
/**
1345
1288
* @dev Triggers an update of rewards due to a change in allocations.
1346
1289
* @param _subgraphDeploymentID Subgrapy deployment updated
0 commit comments