diff --git a/proto/buf.lock b/proto/buf.lock index 5e30ec3..6fcd5cd 100755 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -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 diff --git a/proto/osmosis/tokenfactory/v1beta1/params.proto b/proto/osmosis/tokenfactory/v1beta1/params.proto index 0a9f5ff..dc75b26 100755 --- a/proto/osmosis/tokenfactory/v1beta1/params.proto +++ b/proto/osmosis/tokenfactory/v1beta1/params.proto @@ -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 + ]; } \ No newline at end of file diff --git a/scripts/test_node.sh b/scripts/test_node.sh index c56b347..275e73a 100755 --- a/scripts/test_node.sh +++ b/scripts/test_node.sh @@ -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"]' diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 6ea5ec5..6516c3d 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -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 } diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 229f299..7a65231 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -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 diff --git a/x/tokenfactory/types/params.go b/x/tokenfactory/types/params.go index 9519c71..69eca99 100644 --- a/x/tokenfactory/types/params.go +++ b/x/tokenfactory/types/params.go @@ -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, } } diff --git a/x/tokenfactory/types/params.pb.go b/x/tokenfactory/types/params.pb.go index 6ec0236..e696ca2 100644 --- a/x/tokenfactory/types/params.pb.go +++ b/x/tokenfactory/types/params.pb.go @@ -29,6 +29,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the tokenfactory module. type Params struct { DenomCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=denom_creation_fee,json=denomCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"denom_creation_fee" yaml:"denom_creation_fee"` + // 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 + DenomCreationGasConsume uint64 `protobuf:"varint,2,opt,name=denom_creation_gas_consume,json=denomCreationGasConsume,proto3" json:"denom_creation_gas_consume,omitempty" yaml:"denom_creation_gas_consume"` } func (m *Params) Reset() { *m = Params{} } @@ -71,6 +75,13 @@ func (m *Params) GetDenomCreationFee() github_com_cosmos_cosmos_sdk_types.Coins return nil } +func (m *Params) GetDenomCreationGasConsume() uint64 { + if m != nil { + return m.DenomCreationGasConsume + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "osmosis.tokenfactory.v1beta1.Params") } @@ -80,27 +91,30 @@ func init() { } var fileDescriptor_cc8299d306f3ff47 = []byte{ - // 309 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xcc, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc9, 0xcf, 0x4e, 0xcd, 0x4b, 0x4b, 0x4c, 0x2e, 0xc9, 0x2f, 0xaa, - 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, - 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0x2a, 0xd5, 0x43, 0x56, 0xaa, 0x07, 0x55, 0x2a, - 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, 0x99, 0xe0, 0x35, - 0x3e, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0xd2, 0x37, 0xb5, 0x24, 0x31, 0x25, 0xb1, - 0x24, 0x11, 0xaa, 0x4b, 0x32, 0x19, 0xac, 0x2d, 0x1e, 0x62, 0x1c, 0x84, 0x03, 0x95, 0x92, 0x83, - 0xf0, 0xf4, 0x93, 0x12, 0x8b, 0x53, 0xe1, 0xe6, 0x24, 0xe7, 0x67, 0xe6, 0x41, 0xe4, 0x95, 0x16, - 0x32, 0x72, 0xb1, 0x05, 0x80, 0x5d, 0x2d, 0x34, 0x8d, 0x91, 0x4b, 0x28, 0x25, 0x35, 0x2f, 0x3f, - 0x37, 0x3e, 0xb9, 0x28, 0x35, 0xb1, 0x24, 0x33, 0x3f, 0x2f, 0x3e, 0x2d, 0x35, 0x55, 0x82, 0x51, - 0x81, 0x59, 0x83, 0xdb, 0x48, 0x52, 0x0f, 0x6a, 0x2c, 0xc8, 0x20, 0x98, 0x27, 0xf4, 0x9c, 0xf3, - 0x33, 0xf3, 0x9c, 0x7c, 0x4f, 0xdc, 0x93, 0x67, 0xf8, 0x74, 0x4f, 0x5e, 0xb2, 0x32, 0x31, 0x37, - 0xc7, 0x4a, 0x09, 0xd3, 0x08, 0xa5, 0x55, 0xf7, 0xe5, 0x35, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, - 0xf4, 0x92, 0xf3, 0x73, 0xa1, 0x0e, 0x84, 0x52, 0xba, 0xc5, 0x29, 0xd9, 0xfa, 0x25, 0x95, 0x05, - 0xa9, 0xc5, 0x60, 0xd3, 0x8a, 0x83, 0x04, 0xc0, 0x06, 0x38, 0x43, 0xf5, 0xbb, 0xa5, 0xa6, 0x3a, - 0x05, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, - 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x19, 0x92, 0xa9, 0xce, - 0xf9, 0xc5, 0xb9, 0xe1, 0x89, 0xc5, 0xb9, 0x90, 0xa0, 0xd3, 0x85, 0x85, 0x5d, 0x05, 0x6a, 0x50, - 0x82, 0x6d, 0x4a, 0x62, 0x03, 0x7b, 0xde, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xad, 0x69, 0xdf, - 0x1c, 0xce, 0x01, 0x00, 0x00, + // 356 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xc1, 0x4e, 0xea, 0x40, + 0x14, 0x86, 0x5b, 0xee, 0x0d, 0x8b, 0xde, 0xcd, 0x4d, 0x73, 0x93, 0x0b, 0xc4, 0x4c, 0xb1, 0x2b, + 0x58, 0xd0, 0x06, 0x35, 0x2e, 0x5c, 0xd2, 0x44, 0x57, 0x24, 0x84, 0x8d, 0x89, 0x9b, 0xe6, 0xb4, + 0x0c, 0xa5, 0xc1, 0xe9, 0x21, 0x9d, 0xc1, 0xd8, 0x47, 0x70, 0xe7, 0xca, 0x87, 0xf0, 0x49, 0x58, + 0xb2, 0x74, 0x55, 0x0d, 0xbc, 0x01, 0x4f, 0x60, 0x98, 0x19, 0x0c, 0xa8, 0x71, 0x35, 0x73, 0x72, + 0xfe, 0xff, 0x9b, 0xff, 0xcc, 0xb1, 0xda, 0xc8, 0x19, 0xf2, 0x94, 0xfb, 0x02, 0xa7, 0x34, 0x1b, + 0x43, 0x2c, 0x30, 0x2f, 0xfc, 0xbb, 0x6e, 0x44, 0x05, 0x74, 0xfd, 0x19, 0xe4, 0xc0, 0xb8, 0x37, + 0xcb, 0x51, 0xa0, 0x7d, 0xa4, 0xa5, 0xde, 0xbe, 0xd4, 0xd3, 0xd2, 0xc6, 0xbf, 0x04, 0x13, 0x94, + 0x42, 0x7f, 0x7b, 0x53, 0x9e, 0xc6, 0xd9, 0x8f, 0x78, 0x98, 0x8b, 0x09, 0xe6, 0xa9, 0x28, 0xfa, + 0x54, 0xc0, 0x08, 0x04, 0x68, 0x57, 0x3d, 0x96, 0xb6, 0x50, 0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0x13, 0x45, 0x55, 0xf9, 0xc9, 0xa7, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xd2, 0x08, 0xb7, + 0x36, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -123,6 +137,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.DenomCreationGasConsume != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DenomCreationGasConsume)) + i-- + dAtA[i] = 0x10 + } if len(m.DenomCreationFee) > 0 { for iNdEx := len(m.DenomCreationFee) - 1; iNdEx >= 0; iNdEx-- { { @@ -163,6 +182,9 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + if m.DenomCreationGasConsume != 0 { + n += 1 + sovParams(uint64(m.DenomCreationGasConsume)) + } return n } @@ -235,6 +257,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomCreationGasConsume", wireType) + } + m.DenomCreationGasConsume = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DenomCreationGasConsume |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:])