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

Require more gas compute for create denom instead of a cost #14

Merged
merged 6 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deps:
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: 4e1072d2e34943e79c5699c02aad7066
commit: 172f6ce4e9054eb4af8b96e8131da354
- remote: buf.build
owner: cosmos
repository: gogo-proto
Expand Down
7 changes: 7 additions & 0 deletions proto/osmosis/tokenfactory/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ message Params {
(gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
(gogoproto.nullable) = false
];
// if denom_creation_fee is an empty array, then this field is used to add more gas consumption
// to the base cost.
// https://github.com/CosmWasm/token-factory/issues/11
uint64 denom_creation_gas_consume = 2 [
(gogoproto.moretags) = "yaml:\"denom_creation_gas_consume\"",
(gogoproto.nullable) = true
];
}
3 changes: 2 additions & 1 deletion scripts/test_node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ from_scratch () {
update_test_genesis '.app_state["gov"]["deposit_params"]["min_deposit"]=[{"denom": "ujuno","amount": "1000000"}]'
update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom": "ujuno","amount": "1000"}'

update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[{"denom":"ujuno","amount":"100"}]'
# removed fee, so it will be nil
update_test_genesis '.app_state["tokenfactory"]["params"]["denom_creation_fee"]=[]'

update_test_genesis '.app_state["feeshare"]["params"]["allowed_denoms"]=["ujuno"]'

Expand Down
3 changes: 3 additions & 0 deletions x/tokenfactory/keeper/createdenom.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func (k Keeper) chargeForCreateDenom(ctx sdk.Context, creatorAddr string, _ stri
if err := k.communityPoolKeeper.FundCommunityPool(ctx, creationFee, accAddr); err != nil {
return err
}
} else {
gasIncrease := k.GetParams(ctx).DenomCreationGasConsume
ctx.GasMeter().ConsumeGas(gasIncrease, "consume denom creation gas")
}
return nil
}
1 change: 0 additions & 1 deletion x/tokenfactory/keeper/createdenom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (suite *KeeperTestSuite) TestCreateDenom() {

suite.Require().NoError(err)
suite.Require().Equal(suite.TestAccs[0].String(), queryRes.AuthorityMetadata.Admin)

} else {
suite.Require().Error(err)
// Ensure we don't charge if we expect an error
Expand Down
3 changes: 2 additions & 1 deletion x/tokenfactory/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func DefaultParams() Params {
return Params{
// this was from osmosis
// DenomCreationFee: sdk.NewCoins(sdk.NewInt64Coin(appparams.BaseCoinUnit, 10_000_000)), // 10 OSMO
DenomCreationFee: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 10_000_000)), // 10 OSMO
DenomCreationFee: sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 10_000_000)), // 10 OSMO
DenomCreationGasConsume: 2_000_000,
}
}

Expand Down
83 changes: 62 additions & 21 deletions x/tokenfactory/types/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.