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

implement gas consume on denom creation #4983

Merged
merged 9 commits into from
May 9, 2023

Conversation

larry0x
Copy link
Contributor

@larry0x larry0x commented Apr 22, 2023

What is the purpose of the change

See on-chain proposal: https://www.mintscan.io/osmosis/proposals/489

This PR mirrors the implementation by Juno although implementation detail slightly differs (see createdenom.go). cc @Reecepbcups

Brief Changelog

  • Add a denom_creation_gas_consume to tokenfactory params
  • Consume a amount of gas corresponding to denom_creation_gas_consume when creating a new denom
  • In v16 upgrade, set denom_creation_fee to nil and denom_creation_gas_consume to 10,000,000 gas

Testing and Verifying

This change added tests and can be verified as follows:

  • Added a test for the chain upgrade in v16/upgrades_test.go

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? it adds a new field to tokenfactory's params
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? yes
  • How is the feature or change documented? updated x/tokenfactory/README.md

@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Apr 22, 2023
@larry0x larry0x marked this pull request as draft April 22, 2023 09:42
return err
}
}

// if DenomCreationGasConsume is non-zero, consume the gas
if params.DenomCreationGasConsume != 0 {
Copy link
Contributor

@Reecepbcups Reecepbcups Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case for allowing both DenomCreationFee and DenomCreationGasConsume?

The entire point of DenomCreationGasConsume is to remove the CreationFee token to make contract easier. What am I missing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your implementation the gas is only consumed if the fee is nil. However the variable name does not imply this behavior.

Imagine a developer setting gas consume to a non-zero value but the gas isn't consumed. How confusing would it be! The developer will need to read the comments or dig into the code to find out that they also need to set fee to nil.

In my opinion the logic in my implementation here is simpler and less likely to cause confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha good point. Will update our implementation

return migrations, nil
}
}

func updateTokenFactoryParams(ctx sdk.Context, tokenFactoryKeeper *tokenfactorykeeper.Keeper) {
tokenFactoryKeeper.SetParams(ctx, tokenfactorytypes.NewParams(nil, NewDenomCreationGasConsume))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is purposely setting the fee to nil, but commenting in case the intention was to add gas-consume without modifying the fee.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolaslara Proposal 489 (https://www.mintscan.io/osmosis/proposals/489) states that the fee is to be set "to zero in the UpgradeHandler of the next chain upgrade".

I'm going to add a test for the gas consumption then this PR should be ready.

Copy link
Contributor

@nicolaslara nicolaslara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nicolaslara nicolaslara added the V:state/breaking State machine breaking PR label Apr 24, 2023
@larry0x
Copy link
Contributor Author

larry0x commented Apr 24, 2023

One thing I want to get you guys' opinions on is the specific value for the gas consumption. Due to the very low gas price on Osmosis, the cost for creating a new denom will be significantly lower than the current 10 OSMO. If we set the gas consumption to 10M gas, then under 0.0025uosmo gas price it'd only be 0.025 OSMO per denom. Is this ok?

What is Osmosis' block gas limit?

@Reecepbcups
Copy link
Contributor

Reecepbcups commented Apr 25, 2023

What is Osmosis' block gas limit?

120,000,000

osmosisd q params subspace baseapp BlockParams
key: BlockParams
subspace: baseapp
value: '{"max_bytes":"10485760","max_gas":"120000000"}'

@larry0x larry0x marked this pull request as ready for review April 26, 2023 13:11
@larry0x
Copy link
Contributor Author

larry0x commented Apr 26, 2023

I'm setting the gas consume amount to 40M, which corresponds to 0.1 OSMO per denom created.

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic LGTM, let's merge this after having test cases with the according changes

app/upgrades/v16/upgrades.go Show resolved Hide resolved

// if DenomCreationFee is non-zero, transfer the tokens from the creator
// account to community pool
if params.DenomCreationFee != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to add according unit tests to test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattverse I've added the test, please see: e12c068

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! LGTM

pysel pushed a commit that referenced this pull request Jun 6, 2023
* implement gas consume on denom creation

* apply state changes after running migrations

* update readme

* revert an unintended change

* update changelog

* adjust gas consume amount

* add a test case for gas consumption
@github-actions github-actions bot mentioned this pull request May 1, 2024
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:app-wiring Changes to the app folder C:docs Improvements or additions to documentation C:x/tokenfactory V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants