Indexers get rewards for indexing subgraphs. These rewards are minted whenever an indexer close an allocation with a non-zero POI. A function called distributeRewards() within the Staking contract is used for that purpose. This function calls RewardsManager.takeRewards() that updates the snapshots used for rewards calculations and then mint the tokens. In some cases the snapshot calculation is not called.


When an indexer calls closeAllocation() with a POI=0x0 the function distributeRewards() is not called, as a consequence, takeRewards() is not called and in turn the snapshots are not updated before unallocating tokens. This creates a situation where the rewards manager considers there are a different amount of allocated tokens and distort calculations until it is called next time. Hopefully the distortion self corrects when another action is performed that updates the snapshot.


Update the Staking contract closeAllocation() function to call _updateRewards() when the POI presented is 0x0 before unallocating the tokens.


See @graphprotocol/contracts#459

Backwards Compatibility

The proposal is fully backwards compatible.



The implementation was audited by OpenZeppelin. Full public report: https://blog.openzeppelin.com/thegraph-staking-bugfix-audit-2/


The implementation has not yet been deployed to Testnet.

Copyright and related rights waived via CC0.

Last updated