-
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
L2: linear rewards, and minting in L2 #700
Conversation
2ab1048
to
e0e2a88
Compare
f0f91ad
to
31e0a55
Compare
d8d2f74
to
ba07101
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev #700 +/- ##
==========================================
+ Coverage 91.59% 91.66% +0.07%
==========================================
Files 42 41 -1
Lines 1999 2016 +17
Branches 361 365 +4
==========================================
+ Hits 1831 1848 +17
Misses 168 168
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
ba07101
to
8b9efa8
Compare
ae18852
to
5073920
Compare
6d96ff5
to
08617fa
Compare
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.
I've did a first pass on the RewardsManager, haven't checked the tests nor the Gateway yet. Overall, I'm loving how simple it looking
* @param _block Block at which allowance will be computed | ||
* @return The accumulated GRT amount that can be minted from L2 at the specified block | ||
*/ | ||
function accumulatedL2MintAllowanceAtBlock(uint256 _block) public view returns (uint256) { |
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.
What do you think if we use _blockNum
to make it consistent with the _updateBlockNum
in updateL2MintAllowance()
?
@@ -209,28 +202,18 @@ contract RewardsManager is RewardsManagerV3Storage, GraphUpgradeable, IRewardsMa | |||
return 0; | |||
} | |||
|
|||
// Zero issuance under a rate of 1.0 |
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 an observation: we could still keep this check to avoid the CALL to graphToken() and curation() contract if issuance rate is zero. However, as we are deploying it in L2 initially, it will be cheaper and don't have a big effect.
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 point, adding it back
|
||
// New issuance of tokens during time steps | ||
uint256 x = a.sub(p); | ||
uint256 x = issuancePerBlock.mul(t); |
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.
I love how simple this is
using SafeMath for uint256; | ||
|
||
uint256 private constant TOKEN_DECIMALS = 1e18; | ||
uint256 private constant MIN_ISSUANCE_RATE = 1e18; | ||
uint256 private constant FIXED_POINT_SCALING_FACTOR = 1e18; |
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.
This name is more precise
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.
Yeah, the auditors had commented TOKEN_DECIMALS could be confusing in #571 so I used this name there as well
* Called from the Curation contract on mint() and burn() | ||
* @return Accumulated rewards per signal | ||
*/ | ||
function updateAccRewardsPerSignal() public override returns (uint256) { | ||
accRewardsPerSignal = getAccRewardsPerSignal(); | ||
accRewardsPerSignalLastBlockUpdated = block.number; | ||
tokenSupplySnapshot = graphToken().totalSupply(); |
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.
And we could get rid of this 👍
@@ -8,7 +8,7 @@ import "../governance/Managed.sol"; | |||
contract RewardsManagerV1Storage is Managed { | |||
// -- State -- | |||
|
|||
uint256 public issuanceRate; | |||
uint256 public issuanceRateDeprecated; |
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.
Small optimization: we can make this variable private to avoid including a getter in the bytecode
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 some small comments
await expect( | ||
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()), | ||
).to.eq(issuancePerBlock.mul(3)) | ||
await expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(0) |
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.
We can remove the outer await as the internal one returns the promised value
.emit(l1GraphTokenGateway, 'L2MintAllowanceUpdated') | ||
.withArgs(snapshotValue, issuancePerBlock, issuanceUpdatedAtBlock) | ||
// Now the mint allowance should be 10 + issuancePerBlock * 3 | ||
await expect( |
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.
no-op await
toBN('0'), | ||
encodedCalldata, | ||
) | ||
await expect(tx) |
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.
You should be able to combine this like:
await expect(tx)
.emit(l1GraphTokenGateway, 'WithdrawalFinalized')
.withArgs(grt.address, l2Receiver.address, tokenSender.address, toBN('0'), toGRT('18'))
.emit(l1GraphTokenGateway, 'TokensMintedFromL2')
.withArgs(toGRT('8'))
8c8f6aa
to
3f6c55e
Compare
7a8f68b
to
d8d009b
Compare
d8d009b
to
0f9bca8
Compare
0f9bca8
to
263355d
Compare
Conflicts fixed for: - contracts/gateway/L1GraphTokenGateway.sol - test/gateway/l1GraphTokenGateway.test.ts - test/rewards/rewards.test.ts
…e-dev-2 linear rewards: merge dev and fix goerli config
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.
⚡️
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.
🚀
No description provided.