Skip to content
Open
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ledger-cosmos-go v0.16.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
github.com/google/go-cmp v0.7.0
github.com/google/gofuzz v1.2.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zondax/golem v0.27.0 h1:IbBjGIXF3SoGOZHsILJvIM/F/ylwJzMcHAcggiqniPw=
github.com/zondax/golem v0.27.0/go.mod h1:AmorCgJPt00L8xN1VrMBe13PSifoZksnQ1Ge906bu4A=
Expand Down Expand Up @@ -789,6 +790,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
Expand Down Expand Up @@ -837,6 +839,7 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
Expand Down Expand Up @@ -939,6 +942,7 @@ golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
Expand Down
18 changes: 18 additions & 0 deletions proto/cosmos/dynamicfee/module/v1/module.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";

package cosmos.dynamicfee.module.v1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

So if we change the proto path, which sounds legit, we'll break again the API.
Fortunately it should not be widely used, but there's a pending PR on Hermes that will need to be updated (even though it will never be merged, let's be honest...)


import "cosmos/app/v1alpha1/module.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/dynamicfee/types/module";

// Module is the config object of the builder module.
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import: "github.com/cosmos/cosmos-sdk/x/dynamicfee"
};

// Authority defines the custom module authority. If not set, defaults to the
// governance module.
string authority = 1;
}
47 changes: 47 additions & 0 deletions proto/cosmos/dynamicfee/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
syntax = "proto3";
package cosmos.dynamicfee.v1;

option go_package = "github.com/cosmos/cosmos-sdk/x/dynamicfee/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/dynamicfee/v1/params.proto";

// GenesisState defines the dynamicfee module's genesis state.
message GenesisState {
// Params are the parameters for the dynamicfee module. These parameters
// can be utilized to implement both the base EIP-1559 dynamic fee pricing
// and the AIMD EIP-1559 dynamic fee pricing.
Params params = 1 [(gogoproto.nullable) = false];

// State contains the current state of the AIMD dynamic fee pricer.
State state = 2 [(gogoproto.nullable) = false];
}

// State is utilized to track the current state of the dynamic fee pricer.
// This includes the current base fee, learning rate, and block gas within the
// specified AIMD window.
message State {
// BaseGasPrice is the current base fee. This is denominated in the fee per
// gas unit.
string base_gas_price = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// LearningRate is the current learning rate.
string learning_rate = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Window contains a list of the last blocks' gas values. This is used
// to calculate the next base fee. This stores the number of units of gas
// consumed per block.
repeated uint64 window = 3;

// Index is the index of the current block in the block gas window.
uint64 index = 4;
}
90 changes: 90 additions & 0 deletions proto/cosmos/dynamicfee/v1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
syntax = "proto3";
package cosmos.dynamicfee.v1;

option go_package = "github.com/cosmos/cosmos-sdk/x/dynamicfee/types";

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

// Params contains the required set of parameters for the EIP1559 dynamic fee
// pricing implementation.
message Params {
// Alpha is the amount we additively increase the learning rate
// when it is above or below the target +/- threshold.
//
// Must be > 0.
string alpha = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Beta is the amount we multiplicatively decrease the learning rate
// when it is within the target +/- threshold.
//
// Must be [0, 1].
string beta = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Gamma is the threshold for the learning rate. If the learning rate is
// above or below the target +/- threshold, we additively increase the
// learning rate by Alpha. Otherwise, we multiplicatively decrease the
// learning rate by Beta.
//
// Must be [0, 0.5].
string gamma = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// MinBaseGasPrice determines the initial gas price of the module and the
// global minimum for the network.
string min_base_gas_price = 5 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// TargetBlockUtilization is the target block utilization expressed as a
// decimal value between 0 and 1. It is the target percentage utilization
// of the block in relation to the consensus_params.block.max_gas parameter.
string target_block_utilization = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// DefaultMaxBlockGas is the default max block gas.
// This parameter is used by the dynamicfee module
// in the case consensus_params.block.max_gas returns 0 or -1.
uint64 default_max_block_gas = 7;

// MinLearningRate is the lower bound for the learning rate.
string min_learning_rate = 8 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// MaxLearningRate is the upper bound for the learning rate.
string max_learning_rate = 9 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Window defines the window size for calculating an adaptive learning rate
// over a moving window of blocks.
uint64 window = 10;

// FeeDenom is the denom that will be used for all fee payments.
string fee_denom = 11;

// Enabled is a boolean that determines whether the EIP1559 dynamic fee
// pricing is enabled.
bool enabled = 12;
}
85 changes: 85 additions & 0 deletions proto/cosmos/dynamicfee/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
syntax = "proto3";
package cosmos.dynamicfee.v1;

option go_package = "github.com/cosmos/cosmos-sdk/x/dynamicfee/types";

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";
import "cosmos/dynamicfee/v1/params.proto";
import "cosmos/dynamicfee/v1/genesis.proto";

// Query Service for the dynamicfee module.
service Query {
// Params returns the current dynamicfee module parameters.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http) = {
get: "/cosmos/dynamicfee/v1/params"
};
};

// State returns the current dynamicfee module state.
rpc State(StateRequest) returns (StateResponse) {
option (google.api.http) = {
get: "/cosmos/dynamicfee/v1/state"
};
};

// GasPrice returns the current dynamicfee module gas price
// for specified denom.
rpc GasPrice(GasPriceRequest) returns (GasPriceResponse) {
option (google.api.http) = {
get: "/cosmos/dynamicfee/v1/gas_price/{denom}"
};
};

// GasPrices returns the current dynamicfee module list of gas prices
// in all available denoms.
rpc GasPrices(GasPricesRequest) returns (GasPricesResponse) {
option (google.api.http) = {
get: "/cosmos/dynamicfee/v1/gas_prices"
};
};
}

// ParamsRequest is the request type for the Query/Params RPC method.
message ParamsRequest {}

// ParamsResponse is the response type for the Query/Params RPC method.
message ParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}

// StateRequest is the request type for the Query/State RPC method.
message StateRequest {}

// StateResponse is the response type for the Query/State RPC method.
message StateResponse {
State state = 1 [(gogoproto.nullable) = false];
}

// GasPriceRequest is the request type for the Query/GasPrice RPC method.
message GasPriceRequest {
// denom we are querying gas price in
string denom = 1;
}

// GasPriceResponse is the response type for the Query/GasPrice RPC method.
// Returns a gas price in specified denom.
message GasPriceResponse {
cosmos.base.v1beta1.DecCoin price = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// GasPriceRequest is the request type for the Query/GasPrices RPC method.
message GasPricesRequest {}

// GasPricesResponse is the response type for the Query/GasPrices RPC method.
// Returns a gas price in all available denoms.
message GasPricesResponse {
repeated cosmos.base.v1beta1.DecCoin prices = 1 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
];
}
36 changes: 36 additions & 0 deletions proto/cosmos/dynamicfee/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
syntax = "proto3";
package cosmos.dynamicfee.v1;

import "cosmos/dynamicfee/v1/params.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";
import "amino/amino.proto";

option go_package = "github.com/cosmos/cosmos-sdk/x/dynamicfee/types";

// Message service defines the types of messages supported by the dynamicfee
// module.
service Msg {
option (cosmos.msg.v1.service) = true;

// UpdateParams defines a method for updating the dynamicfee module parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgUpdateParams defines the sdk.Msg/UpdateParams request type. It contains
// the new parameters for the dynamicfee module.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "cosmos/x/dynamicfee/v1/MsgUpdateParams";

// Authority defines the authority that is updating the dynamicfee module
// parameters.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Params defines the new parameters for the dynamicfee module.
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}
2 changes: 2 additions & 0 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ $mockgen_cmd -source=x/genutil/types/expected_keepers.go -package testutil -dest
$mockgen_cmd -source=x/gov/testutil/expected_keepers.go -package testutil -destination x/gov/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/staking/types/expected_keepers.go -package testutil -destination x/staking/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/auth/vesting/types/expected_keepers.go -package testutil -destination x/auth/vesting/testutil/expected_keepers_mocks.go
$mockgen_cmd -source=x/dynamicfee/ante/expected_keepers.go -package ante_test -destination x/dynamicfee/ante/expected_keepers_mocks_test.go
$mockgen_cmd -source=x/dynamicfee/post/expected_keepers.go -package post_test -destination x/dynamicfee/post/expected_keepers_mocks_test.go
11 changes: 11 additions & 0 deletions simapp/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import (
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
distrmodulev1 "github.com/cosmos/cosmos-sdk/x/distribution/types/module"
_ "github.com/cosmos/cosmos-sdk/x/dynamicfee" // import for side-effects
dynamicfeetypes "github.com/cosmos/cosmos-sdk/x/dynamicfee/types"
dynamicfeemodulev1 "github.com/cosmos/cosmos-sdk/x/dynamicfee/types/module"
_ "github.com/cosmos/cosmos-sdk/x/epochs" // import for side-effects
epochstypes "github.com/cosmos/cosmos-sdk/x/epochs/types"
epochsmodulev1 "github.com/cosmos/cosmos-sdk/x/epochs/types/module"
Expand Down Expand Up @@ -73,6 +76,7 @@ var (
{Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}},
{Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}},
{Account: dynamicfeetypes.ModuleName},
}

// blocked account addresses
Expand Down Expand Up @@ -103,6 +107,7 @@ var (
// NOTE: staking module is required if HistoricalEntries param > 0
BeginBlockers: []string{
minttypes.ModuleName,
dynamicfeetypes.ModuleName,
distrtypes.ModuleName,
slashingtypes.ModuleName,
evidencetypes.ModuleName,
Expand All @@ -111,6 +116,7 @@ var (
epochstypes.ModuleName,
},
EndBlockers: []string{
dynamicfeetypes.ModuleName,
govtypes.ModuleName,
stakingtypes.ModuleName,
feegrant.ModuleName,
Expand Down Expand Up @@ -141,6 +147,7 @@ var (
vestingtypes.ModuleName,
circuittypes.ModuleName,
epochstypes.ModuleName,
dynamicfeetypes.ModuleName,
},
// When ExportGenesis is not specified, the export genesis module order
// is equal to the init genesis order
Expand Down Expand Up @@ -236,6 +243,10 @@ var (
Name: epochstypes.ModuleName,
Config: appconfig.WrapAny(&epochsmodulev1.Module{}),
},
{
Name: dynamicfeetypes.ModuleName,
Config: appconfig.WrapAny(&dynamicfeemodulev1.Module{}),
},
},
}),
depinject.Supply(
Expand Down
Loading
Loading