-
Notifications
You must be signed in to change notification settings - Fork 174
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
Update mint module #273
Update mint module #273
Conversation
* Halving time now is based on the total supply instead of fixed blocks per year param. * Better round block provisions during phase changes
|
||
// fetch current total supply | ||
totalSupply := k.TokenSupply(ctx, params.MintDenom) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
minter.Inflation = newInflation | ||
minter.Phase = nextPhase | ||
minter.StartPhaseBlock = currentBlock | ||
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalSupply) | ||
minter.TargetSupply = totalSupply.Add(minter.AnnualProvisions.TruncateInt()) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
minter.Inflation = newInflation | ||
minter.Phase = nextPhase | ||
minter.StartPhaseBlock = currentBlock | ||
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalSupply) | ||
minter.TargetSupply = totalSupply.Add(minter.AnnualProvisions.TruncateInt()) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
// inflation phase end | ||
if minter.Inflation.Equal(sdk.ZeroDec()) { | ||
return | ||
} | ||
} | ||
|
||
// mint coins, update supply | ||
mintedCoin := minter.BlockProvision(params) | ||
mintedCoin := minter.BlockProvision(params, totalSupply) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
I have read through and it appears that the intent from Core discussions has been captured. I have no comment on code. |
Had a quick scan. Approach looks good (will read more closely later). Looks like the linter is right, there's some error handling needed? |
@dimiandre do you mind if I work on this branch directly? |
I think it's fine! We can then merge and base the other things we have to push on this |
I think I'd start with the other things first, since they're larger changes, but either way-- Here's a small piece of how we (notional) think of blockchain development-- this PR here is a feature, a deviation from the "base" while is "base". We usually go base -> features but I'm good with either direction in this case :). |
regarding the codeql findings-- basically, the only other way to handle these, is to use a blank import, but the effect is the same: it is a dangerous area of the code. |
I prefer your approach more as well, I can rebase this branch on that one. Let me know |
Ok, if you'd like to go that way, basically first step is that we'd get #262 merged, and then we should get an "update branch" option here and shouldn't require any additional lifting beyond that :) |
Testing again on V10, and will start working on upgrade handler. |
All test in my local environment successful. Need to write more unit test |
We've got a team member who does amazing unit tests, I'll see if he has any capacity for this. |
This bit is done now, right? |
yep! |
totalSupply := k.TokenSupply(ctx, params.MintDenom) | ||
|
||
// check if we need to change phase | ||
nextPhase := minter.NextPhase(params, totalSupply) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
what will happen if coins are burned? e.g. whale funds. |
@giansalex I guess it will mint more until it hits totalSupply and changes phase? Or is that not right @dimiandre because totalSupply isn't total all-time supply, but instead total supply in this phase, in which case it will just continue as it would have done, and the total all-time supply of Juno will decrease. |
I guess it depends on if the burn actually removes tokens from bank. Is our version of a burn sending to a non existing account or are they actually removed from the bank module? This issue was actually raised on the weekend on a twitter spaces too. |
CosmWasm burn, so tokens disappear, removed from circulating supply AFAICR. I will look up the impl later |
yes, but technically more tokens will be minted, burned funds will return to token supply in the future via x/mint module. |
Right, so actually you're saying we should calculate the checkpoints ahead of time and stick to them rather than having it function statelessly? Otherwise a burn never actually affects supply in the way intended... |
How do you calculate ahead of time? The only checkpoints we can fix are
if we fix supply, we have this burn problem unless we modify the burn function to recalculate the target supply IMO if a burn event happens, we can just do an upgrade and modify annual provisions for that phase |
Epochs? 2 options:
Sorry I didn't think of this earlier. |
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.
Approved, as I think we should deploy a testnet with this. I also think that we may wish to consider epochs.
Should we have a call about this today/monday?
I'm now leaning into the opinion that the fact it will make itself back to the correct amount, releasing the difference to stakers is actually... kind of fine? If that changes, we can add additional logic or an upgrade in future to alter. |
Kind of fine, is imo exactly what we are shooting for here. I basically won't trust this code until it's been on a testnet, so, lgtm! <3 (NB: I don't think there's anything wrong with it. I just want to observe it in its natural habitat some more) |
--
Need to update tests