Skip to content
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

Merged
merged 14 commits into from
Sep 11, 2022
Merged

Update mint module #273

merged 14 commits into from
Sep 11, 2022

Conversation

dimiandre
Copy link
Member

@dimiandre dimiandre commented Aug 24, 2022

  • Halving time now is based on the total supply instead of fixed blocks per year param.
  • Better round block provisions during phase changes

--
Need to update tests

* 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

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
x/mint/abci.go Fixed Show fixed Hide fixed
x/mint/abci.go Fixed Show fixed Hide fixed
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

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
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

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
// 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

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@nullmames
Copy link
Member

I have read through and it appears that the intent from Core discussions has been captured. I have no comment on code.

@the-frey
Copy link
Contributor

the-frey commented Aug 25, 2022

Had a quick scan. Approach looks good (will read more closely later). Looks like the linter is right, there's some error handling needed?

@faddat
Copy link
Contributor

faddat commented Aug 25, 2022

@dimiandre do you mind if I work on this branch directly?

@dimiandre
Copy link
Member Author

@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

@faddat
Copy link
Contributor

faddat commented Aug 25, 2022

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

#262

is "base".

We usually go base -> features but I'm good with either direction in this case :).

@faddat
Copy link
Contributor

faddat commented Aug 25, 2022

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.

@dimiandre
Copy link
Member Author

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

#262

is "base".

We usually go base -> features but I'm good with either direction in this case :).

I prefer your approach more as well, I can rebase this branch on that one.

Let me know

@faddat
Copy link
Contributor

faddat commented Aug 25, 2022

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 :)

@faddat faddat changed the title WIP: Update mint module WIP: Update mint module & overclock juno Aug 27, 2022
@dimiandre
Copy link
Member Author

Testing again on V10, and will start working on upgrade handler.

@dimiandre
Copy link
Member Author

All test in my local environment successful.

Need to write more unit test

@faddat
Copy link
Contributor

faddat commented Sep 3, 2022

We've got a team member who does amazing unit tests, I'll see if he has any capacity for this.

@the-frey
Copy link
Contributor

the-frey commented Sep 5, 2022

Need to write upgrade handler to calculate "TargetSupply"

This bit is done now, right?

@dimiandre
Copy link
Member Author

Need to write upgrade handler to calculate "TargetSupply"

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

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@the-frey the-frey requested a review from giansalex September 5, 2022 21:06
@giansalex
Copy link
Member

what will happen if coins are burned? e.g. whale funds.

@the-frey
Copy link
Contributor

the-frey commented Sep 7, 2022

@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.

@nullmames
Copy link
Member

nullmames commented Sep 7, 2022

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.

@the-frey
Copy link
Contributor

the-frey commented Sep 7, 2022

CosmWasm burn, so tokens disappear, removed from circulating supply AFAICR. I will look up the impl later

@giansalex
Copy link
Member

giansalex commented Sep 7, 2022

I guess it will mint more until it hits totalSupply and changes phase?

yes, but technically more tokens will be minted, burned funds will return to token supply in the future via x/mint module.
loses the point of burning tokens, especially in Juno which has a fixed max supply.

@the-frey
Copy link
Contributor

the-frey commented Sep 7, 2022

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...

@dimiandre
Copy link
Member Author

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

  • Target supply
  • Target dates

if we fix supply, we have this burn problem unless we modify the burn function to recalculate the target supply
if we fix dates, we will have a total random supply based on block times

IMO if a burn event happens, we can just do an upgrade and modify annual provisions for that phase

@faddat
Copy link
Contributor

faddat commented Sep 8, 2022

Epochs?

2 options:

  • Osmosis epoch module is now importable. I prefer it to the x/epoching in the sdk
  • Backport x/epoching to 45

Sorry I didn't think of this earlier.

Copy link
Contributor

@faddat faddat left a 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?

@the-frey
Copy link
Contributor

the-frey commented Sep 9, 2022

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.

@the-frey the-frey changed the title WIP: Update mint module & overclock juno Update mint module Sep 9, 2022
@faddat
Copy link
Contributor

faddat commented Sep 11, 2022

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)

@faddat faddat merged commit 9480914 into main Sep 11, 2022
@the-frey the-frey deleted the dimi/inflation branch September 11, 2022 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants