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

feat: global fee module #1488

Merged
merged 32 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
64c71bf
remove non-46 packages until go mod tidy runs
okwme May 11, 2022
1ced43c
builds but had to remove IBC and E2E
okwme May 11, 2022
e5b6d6e
fix: undeclared identifier 'kIOMainPortDefault'
May 11, 2022
a431aef
restore E2E
okwme May 11, 2022
b33add8
add back minimal upgrade handler
okwme May 11, 2022
e9949ff
Add local e2e docker
May 11, 2022
c2968aa
fix: keys list
May 12, 2022
2b2fe5f
fix: e2e test
May 13, 2022
4be0ac5
Fix e2e (#1479)
okwme May 14, 2022
96e4484
add global fee module
May 2, 2022
66425ff
add glob fee ante handler
May 13, 2022
cd00f8f
add glob fee to app
May 16, 2022
e6d6819
add proto files
May 18, 2022
8fb7539
add proto script and docs
May 18, 2022
e9b935e
fix tests
May 18, 2022
8ccd349
add globalfee README
May 18, 2022
99c0bd1
Update README.md
yaruwangway May 24, 2022
e026fe7
merge main
Jun 7, 2022
8511127
fix: lint
Jun 7, 2022
b6a4cb9
add: globfee antehandler
Jun 8, 2022
1671c82
Merge branch 'main' into yaru/rho-glob-fee
okwme Jun 21, 2022
49f68d5
Merge branch 'main' into yaru/rho-glob-fee
Jun 22, 2022
ea602bf
Merge branch 'main' into yaru/rho-glob-fee
Jun 23, 2022
6d39e4a
Merge branch 'main' into yaru/rho-glob-fee
okwme Jun 30, 2022
4b2fb82
fix lint
Jun 30, 2022
1161ab2
Merge branch 'main' into yaru/rho-glob-fee
okwme Jul 4, 2022
7d264ee
custom global fee: make global accept fee bypass, define fee denoms (…
yaruwangway Aug 8, 2022
d5bd5e8
test: global fee e2e tests, bypass fee e2e (#1594)
yaruwangway Aug 10, 2022
50367a9
merge main
Aug 11, 2022
2102541
fix: dead link
Aug 11, 2022
ca8dc6d
change disable all link to disable nextline
Aug 11, 2022
442fac6
Update proto/gaia/globalfee/v1beta1/genesis.proto
yaruwangway Aug 11, 2022
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ format:
###############################################################################

start-localnet-ci:
@ignite chain serve --reset-once -v -c ./ignite.ci.yml
@ignite chain serve --mode validator --reset-once -v -c ./ignite.ci.yml
okwme marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: start-localnet-ci

Expand Down
10 changes: 8 additions & 2 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/gaia/v8/x/globalfee"
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
)
Expand All @@ -14,6 +16,7 @@ type HandlerOptions struct {
ante.HandlerOptions
IBCkeeper *ibckeeper.Keeper
BypassMinFeeMsgTypes []string
GlobalFeeSubspace paramtypes.Subspace
}

func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
Expand All @@ -26,10 +29,12 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
if opts.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

if opts.IBCkeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "IBC keeper is required for middlewares")
}
if opts.GlobalFeeSubspace.Name() == "" {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "param store is required for ante builder")
}

var sigGasConsumer = opts.SigGasConsumer
if sigGasConsumer == nil {
Expand All @@ -44,7 +49,8 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
ante.NewValidateMemoDecorator(opts.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, opts.TxFeeChecker),
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
globalfee.NewGlobalMinimumChainFeeDecorator(opts.GlobalFeeSubspace), // after local min fee check
ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(opts.AccountKeeper),
ante.NewSigGasConsumeDecorator(opts.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(opts.AccountKeeper, opts.SignModeHandler),
Expand Down
13 changes: 11 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"os"
"path/filepath"

"github.com/cosmos/gaia/v8/x/globalfee"

"github.com/cosmos/cosmos-sdk/x/auth/ante"

"github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar"
Expand Down Expand Up @@ -169,6 +171,7 @@ var (
liquidity.AppModuleBasic{},
// router.AppModuleBasic{},
ica.AppModuleBasic{},
globalfee.AppModule{},
)

// module account permissions
Expand Down Expand Up @@ -552,6 +555,7 @@ func NewGaiaApp(
transferModule,
icaModule,
// routerModule,
globalfee.NewAppModule(app.GetSubspace(globalfee.ModuleName)),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down Expand Up @@ -583,6 +587,7 @@ func NewGaiaApp(
group.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName,
Expand All @@ -607,6 +612,7 @@ func NewGaiaApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -638,6 +644,7 @@ func NewGaiaApp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
globalfee.ModuleName,
)

// Uncomment if you want to set a custom migration order here.
Expand Down Expand Up @@ -691,8 +698,9 @@ func NewGaiaApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCkeeper: app.IBCKeeper,
BypassMinFeeMsgTypes: cast.ToStringSlice(appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey)),
IBCkeeper: app.IBCKeeper,
// BypassMinFeeMsgTypes: cast.ToStringSlice(appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey)),
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
},
)
if err != nil {
Expand Down Expand Up @@ -936,6 +944,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

// paramsKeeper.Subspace(routertypes.ModuleName).WithKeyTable(routertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(globalfee.ModuleName)

return paramsKeeper
}
38 changes: 38 additions & 0 deletions contrib/scripts/protocgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -eo pipefail

protoc_gen_gocosmos() {
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder."
return 1
fi

go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null
}

protoc_gen_gocosmos

proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
buf protoc \
-I "proto" \
-I "third_party/proto" \
--gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
--grpc-gateway_out=logtostderr=true:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')

done
#
## command to generate docs using protoc-gen-doc
buf protoc \
-I "proto" \
-I "third_party/proto" \
--doc_out=./docs/proto \
--doc_opt=./docs/proto/protodoc-markdown.tmpl,proto-docs.md \
$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')

# move proto files to the right places
cp -r github.com/cosmos/gaia/* ./
rm -rf github.com
139 changes: 139 additions & 0 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<!-- This file is auto-generated. Please do not modify it yourself. -->
# Protobuf Documentation
<a name="top"></a>

## Table of Contents

- [gaia/globalfee/v1beta1/genesis.proto](#gaia/globalfee/v1beta1/genesis.proto)
- [GenesisState](#gaia.globalfee.v1beta1.GenesisState)
- [Params](#gaia.globalfee.v1beta1.Params)

- [gaia/globalfee/v1beta1/query.proto](#gaia/globalfee/v1beta1/query.proto)
- [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest)
- [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse)

- [Query](#gaia.globalfee.v1beta1.Query)

- [Scalar Value Types](#scalar-value-types)



<a name="gaia/globalfee/v1beta1/genesis.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## gaia/globalfee/v1beta1/genesis.proto



<a name="gaia.globalfee.v1beta1.GenesisState"></a>

### GenesisState
GenesisState - initial state of module


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#gaia.globalfee.v1beta1.Params) | | Params of this module |






<a name="gaia.globalfee.v1beta1.Params"></a>

### Params
Params defines the set of module parameters.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/master/modules/auth/01_concepts.html |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="gaia/globalfee/v1beta1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## gaia/globalfee/v1beta1/query.proto



<a name="gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest"></a>

### QueryMinimumGasPricesRequest
QueryMinimumGasPricesRequest is the request type for the
Query/MinimumGasPrices RPC method.






<a name="gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse"></a>

### QueryMinimumGasPricesResponse
QueryMinimumGasPricesResponse is the response type for the
Query/MinimumGasPrices RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="gaia.globalfee.v1beta1.Query"></a>

### Query
Query defines the gRPC querier service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `MinimumGasPrices` | [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest) | [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse) | | GET|/gaia/globalfee/v1beta1/minimum_gas_prices|

<!-- end services -->



## Scalar Value Types

| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby |
| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- |
| <a name="double" /> double | | double | double | float | float64 | double | float | Float |
| <a name="float" /> float | | float | float | float | float32 | float | float | Float |
| <a name="int32" /> int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="int64" /> int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="uint32" /> uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) |
| <a name="uint64" /> uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) |
| <a name="sint32" /> sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="sint64" /> sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="fixed32" /> fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) |
| <a name="fixed64" /> fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum |
| <a name="sfixed32" /> sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) |
| <a name="sfixed64" /> sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum |
| <a name="bool" /> bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass |
| <a name="string" /> string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) |
| <a name="bytes" /> bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) |

Loading