-
Notifications
You must be signed in to change notification settings - Fork 149
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
Create altruistic allocations and close stale allocations #549
Conversation
…ch as allocation state
Codecov Report
@@ Coverage Diff @@
## dev #549 +/- ##
==========================================
- Coverage 90.58% 90.29% -0.29%
==========================================
Files 37 35 -2
Lines 1795 1752 -43
Branches 293 293
==========================================
- Hits 1626 1582 -44
- Misses 169 170 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
contracts/staking/Staking.sol
Outdated
} else { | ||
// Allocating zero-tokens still needs to have stake | ||
// Minimum indexer stake is managed by stake/unstake | ||
require(stakes[_indexer].tokensSecureStake() > 0, "!stake"); |
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.
require(stakes[_indexer].tokensSecureStake() > 0, "!stake"); | |
require(stakes[_indexer].tokensSecureStake() > minimumIndexerStake, "!stake"); |
Why not use minimumIndexerStake
? It's probably a stretch but there is an edge case where having this check rely on stake/unstake could result in the check passing when it shouldn't.
If an indexer stakes minimumIndexerStake
and then the minimum is raised by governance then they would still pass this require check but they wouldn't really have the actual minimum amount minimumIndexerStake
as it has been increased.
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.
Good catch, I was looking into the same thing. Only additional change I'd do to that proposal is to use >=
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.
Left a comment and a very tiny nit
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.
Just a few details for now, but otherwise I think it looks good (still taking a closer look)
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.
LGTM
- feat: add support to deploy protocol to goerli network (#615) - chore: add hardhat task to verify all contracts with etherscan (#626) - chore: add hardhat task to verify all contracts with sourcify (#625) - chore: add confirmation step to a few more commands - Create altruistic allocations and close stale allocations (#549)
Supersedes: #543
Goal
Provide a mechanism so that indexers can opt-out of rewards by allocating zero tokens to a subgraph. In addition, this implementation allows anyone to close stale allocations after the max allocation period, however, nobody can close an altruistic allocation.
Motivation
Highlight
maxAllocationEpoch
by the public, only by indexer or operator.maxAllocationEpoch
.Gas Efficiency
Altruistic allocations are roughly 50% more gas efficient because the contract doesn't need to recalculate rewards snapshots.
Standard Allocation
Zero Allocation
Reference
Forum: https://forum.thegraph.com/t/rewarded-force-close-mechanism-to-eliminate-stale-allocations/2951/8