@@ -109,13 +109,13 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
109
109
address allocationID ,
110
110
bytes channelPubKey ,
111
111
uint256 price ,
112
- address proxy
112
+ address authSender
113
113
);
114
114
115
115
/**
116
- * @dev Emitted when `indexer` withdrew `tokens` amount in `epoch` from `allocationID` channel .
117
- * The funds are related to `subgraphDeploymentID`.
118
- * `from` attribute records the the multisig contract from where it was settled .
116
+ * @dev Emitted when `indexer` collected `tokens` amount in `epoch` for `allocationID`.
117
+ * These funds are related to `subgraphDeploymentID`.
118
+ * The `from` value is the sender of the collected funds .
119
119
*/
120
120
event AllocationCollected (
121
121
address indexed indexer ,
@@ -129,8 +129,8 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
129
129
);
130
130
131
131
/**
132
- * @dev Emitted when `indexer` settled an allocation in `epoch` for `allocationID` channel .
133
- * The `tokens` getting unallocated from `subgraphDeploymentID`.
132
+ * @dev Emitted when `indexer` settled an allocation in `epoch` for `allocationID`.
133
+ * An amount of `tokens` get unallocated from `subgraphDeploymentID`.
134
134
* The `effectiveAllocation` are the tokens allocated from creation to settlement.
135
135
*/
136
136
event AllocationSettled (
@@ -707,49 +707,42 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
707
707
* @dev Allocate available tokens to a subgraph deployment.
708
708
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
709
709
* @param _tokens Amount of tokens to allocate
710
- * @param _channelPubKey The public key used by the indexer to setup the off-chain channel
711
- * @param _channelProxy Address of the multisig proxy used to hold channel funds
710
+ * @param _channelPubKey The public key used to route payments
711
+ * @param _authSender Authorized sender address of collected funds
712
712
* @param _price Price the `indexer` will charge for serving queries of the `subgraphDeploymentID`
713
713
*/
714
714
function allocate (
715
715
bytes32 _subgraphDeploymentID ,
716
716
uint256 _tokens ,
717
717
bytes calldata _channelPubKey ,
718
- address _channelProxy ,
718
+ address _authSender ,
719
719
uint256 _price
720
720
) external override {
721
721
require (_onlyAuth (msg .sender ), "Allocation: caller must be authorized " );
722
722
723
- _allocate (
724
- msg .sender ,
725
- _subgraphDeploymentID,
726
- _tokens,
727
- _channelPubKey,
728
- _channelProxy,
729
- _price
730
- );
723
+ _allocate (msg .sender , _subgraphDeploymentID, _tokens, _channelPubKey, _authSender, _price);
731
724
}
732
725
733
726
/**
734
727
* @dev Allocate available tokens to a subgraph deployment.
735
728
* @param _indexer Indexer address to allocate funds from.
736
729
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
737
730
* @param _tokens Amount of tokens to allocate
738
- * @param _channelPubKey The public key used by the indexer to setup the off-chain channel
739
- * @param _channelProxy Address of the multisig proxy used to hold channel funds
731
+ * @param _channelPubKey The public key used to route payments
732
+ * @param _authSender Authorized sender address of collected funds
740
733
* @param _price Price the `indexer` will charge for serving queries of the `subgraphDeploymentID`
741
734
*/
742
735
function allocateFrom (
743
736
address _indexer ,
744
737
bytes32 _subgraphDeploymentID ,
745
738
uint256 _tokens ,
746
739
bytes calldata _channelPubKey ,
747
- address _channelProxy ,
740
+ address _authSender ,
748
741
uint256 _price
749
742
) external override {
750
743
require (_onlyAuth (_indexer), "Allocation: caller must be authorized " );
751
744
752
- _allocate (_indexer, _subgraphDeploymentID, _tokens, _channelPubKey, _channelProxy , _price);
745
+ _allocate (_indexer, _subgraphDeploymentID, _tokens, _channelPubKey, _authSender , _price);
753
746
}
754
747
755
748
/**
@@ -817,16 +810,13 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
817
810
// Allocation identifier validation
818
811
require (_allocationID != address (0 ), "Collect: invalid allocation " );
819
812
820
- // The contract caller must be a channel proxy registered during allocation
821
- require (
822
- alloc.channelProxy == msg .sender ,
823
- "Collect: caller is not related to the allocation "
824
- );
813
+ // The contract caller must be an authorized sender registered on allocate()
814
+ require (alloc.authSender == msg .sender , "Collect: caller is not authorized " );
825
815
826
- // Transfer tokens to collect from multisig to this contract
816
+ // Transfer tokens to collect from the authorized sender
827
817
require (
828
818
token.transferFrom (msg .sender , address (this ), _tokens),
829
- "Collect: cannot transfer tokens to settle "
819
+ "Collect: cannot transfer tokens to collect "
830
820
);
831
821
832
822
_collect (_allocationID, msg .sender , _tokens);
@@ -875,7 +865,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
875
865
alloc.settledAtEpoch = 0 ;
876
866
alloc.collectedFees = 0 ;
877
867
alloc.effectiveAllocation = 0 ;
878
- alloc.channelProxy = address (0 ); // This avoid collect() to be called
868
+ alloc.authSender = address (0 ); // This avoid collect() to be called
879
869
880
870
// When there are tokens to claim from the rebate pool, transfer or restake
881
871
if (tokensToClaim > 0 ) {
@@ -931,15 +921,15 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
931
921
* @param _subgraphDeploymentID ID of the SubgraphDeployment where tokens will be allocated
932
922
* @param _tokens Amount of tokens to allocate
933
923
* @param _channelPubKey The public key used by the indexer to setup the off-chain channel
934
- * @param _channelProxy Address of the multisig proxy used to hold channel funds
924
+ * @param _authSender Authorized sender address of collected funds
935
925
* @param _price Price the `indexer` will charge for serving queries of the `subgraphDeploymentID`
936
926
*/
937
927
function _allocate (
938
928
address _indexer ,
939
929
bytes32 _subgraphDeploymentID ,
940
930
uint256 _tokens ,
941
931
bytes memory _channelPubKey ,
942
- address _channelProxy ,
932
+ address _authSender ,
943
933
uint256 _price
944
934
) private {
945
935
Stakes.Indexer storage indexerStake = stakes[_indexer];
@@ -960,9 +950,8 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
960
950
);
961
951
962
952
// A channel public key is derived by the indexer when creating the offchain payment channel.
963
- // Get the Ethereum address from the public key and use as channel identifier.
964
- // The channel identifier is the address of the indexer signing party of a multisig that
965
- // will hold the funds received when the channel is settled.
953
+ // Get the Ethereum address from the public key and use as allocation identifier.
954
+ // The allocationID will work to identify collected funds related to this allocation.
966
955
address allocationID = address (uint256 (keccak256 (_sliceByte (bytes (_channelPubKey)))));
967
956
968
957
// Cannot reuse an allocationID that has already been used in an allocation
@@ -973,17 +962,16 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
973
962
974
963
// Creates an allocation
975
964
// Allocation identifiers are not reused
976
- // The channel proxy address is the contract that will send tokens to be collected to
977
- // this contract
965
+ // The authorized sender address can send collected funds to the allocation
978
966
allocations[allocationID] = Allocation (
979
967
_indexer,
980
968
_subgraphDeploymentID,
981
969
_tokens, // Tokens allocated
982
970
epochManager.currentEpoch (), // createdAtEpoch
983
971
0 , // settledAtEpoch
984
- 0 , // Initialize with zero collected fees
972
+ 0 , // Initialize collected fees
985
973
0 , // Initialize effective allocation
986
- _channelProxy // Source address of allocation collected funds
974
+ _authSender // Source address for allocation collected funds
987
975
);
988
976
989
977
// Mark allocated tokens as used
@@ -997,7 +985,7 @@ contract Staking is StakingV1Storage, GraphUpgradeable, IStaking, Governed {
997
985
allocationID,
998
986
_channelPubKey,
999
987
_price,
1000
- _channelProxy
988
+ _authSender
1001
989
);
1002
990
}
1003
991
0 commit comments