Skip to content

Commit

Permalink
Require more gas compute for create denom instead of a cost (#14)
Browse files Browse the repository at this point in the history
* Charge extra gas for createdenom instead

* Adds DenomCreationGasConsume Param

* Bump to 2mil defai;t

* lint

* remove duplicate test
  • Loading branch information
Reecepbcups authored Mar 31, 2023
1 parent 28b4a48 commit a25effd
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 25 deletions.
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.

0 comments on commit a25effd

Please sign in to comment.