-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: remove asset holder allowlist (with latest main) #855
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bcf31e9
feat: remove asset holder allowlist
pcarranzav 2e8c499
fix: remove setAssetHolder call from config files
tmigone 36308c3
fix: a few details for asset holder deprecation
pcarranzav b56af5d
fix: improvements from Trust audit (TRST-L-1 and recommendations)
pcarranzav 225be78
test: fix the case when collecting zero fees
pcarranzav c2fdebb
Merge pull request #791 from graphprotocol/pcv/asset-holder-trust-fixes
pcarranzav 765d43f
chore: add Trust audit report
pcarranzav 194fb4f
Merge branch 'dev' into pcv/remove-asset-holder-check
pcarranzav 04a42bc
fix: remove assetHolders getter
pcarranzav 4b334cb
test: remove a leftover setAssetHolder call
pcarranzav d3b626c
fix: use a bracket scope to avoid stack too deep
pcarranzav c090c63
fix: typo
pcarranzav abe55a1
test: fix a case where it still expected an event
pcarranzav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,17 +220,6 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M | |
); | ||
} | ||
|
||
/** | ||
* @notice Set an address as allowed asset holder. | ||
* @param _assetHolder Address of allowed source for state channel funds | ||
* @param _allowed True if asset holder is allowed | ||
*/ | ||
function setAssetHolder(address _assetHolder, bool _allowed) external override onlyGovernor { | ||
require(_assetHolder != address(0), "!assetHolder"); | ||
__assetHolders[_assetHolder] = _allowed; | ||
emit AssetHolderUpdate(msg.sender, _assetHolder, _allowed); | ||
} | ||
|
||
/** | ||
* @notice Authorize or unauthorize an address to be an operator for the caller. | ||
* @param _operator Address to authorize or unauthorize | ||
|
@@ -354,7 +343,6 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M | |
|
||
/** | ||
* @dev Collect and rebate query fees from state channels to the indexer | ||
* Funds received are only accepted from a valid sender. | ||
* To avoid reverting on the withdrawal from channel flow this function will accept calls with zero tokens. | ||
* We use an exponential rebate formula to calculate the amount of tokens to rebate to the indexer. | ||
* This implementation allows collecting multiple times on the same allocation, keeping track of the | ||
|
@@ -366,13 +354,17 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M | |
// Allocation identifier validation | ||
require(_allocationID != address(0), "!alloc"); | ||
|
||
// The contract caller must be an authorized asset holder | ||
require(__assetHolders[msg.sender] == true, "!assetHolder"); | ||
|
||
// Allocation must exist | ||
AllocationState allocState = _getAllocationState(_allocationID); | ||
require(allocState != AllocationState.Null, "!collect"); | ||
|
||
// If the query fees are zero, we don't want to revert | ||
// but we also don't need to do anything, so just return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This slightly changes the behavior of the function as we now are not emitting the |
||
if (_tokens == 0) { | ||
return; | ||
} | ||
|
||
// Get allocation | ||
Allocation storage alloc = __allocations[_allocationID]; | ||
bytes32 subgraphDeploymentID = alloc.subgraphDeploymentID; | ||
|
||
|
@@ -382,9 +374,8 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M | |
uint256 queryRebates = 0; // Tokens to distribute to indexer | ||
uint256 delegationRewards = 0; // Tokens to distribute to delegators | ||
|
||
// Process query fees only if non-zero amount | ||
if (queryFees > 0) { | ||
// -- Pull tokens from the authorized sender -- | ||
{ | ||
// -- Pull tokens from the sender -- | ||
IGraphToken graphToken = graphToken(); | ||
TokenUtils.pullTokens(graphToken, msg.sender, queryFees); | ||
|
||
|
@@ -789,7 +780,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M | |
|
||
// Creates an allocation | ||
// Allocation identifiers are not reused | ||
// The assetHolder address can send collected funds to the allocation | ||
// Anyone can send collected funds to the allocation using collect() | ||
Allocation memory alloc = Allocation( | ||
_indexer, | ||
_subgraphDeploymentID, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(GitHub won't let me comment on the correct LOC as you did not modify it but...)
The event
RebateCollected
usesassetHolder
name for the query fees provider. We probably want to change that name for clarity, something likerebateProvider
orprovider
,sender
, wdyt?