diff --git a/api/feemarket/feemarket/v1/genesis.pulsar.go b/api/feemarket/feemarket/v1/genesis.pulsar.go index 4a13c4b..f4295da 100644 --- a/api/feemarket/feemarket/v1/genesis.pulsar.go +++ b/api/feemarket/feemarket/v1/genesis.pulsar.go @@ -1048,7 +1048,7 @@ func (x *fastReflection_State) ProtoMethods() *protoiface.Methods { switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BaseGasPrice", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { diff --git a/api/feemarket/feemarket/v1/params.pulsar.go b/api/feemarket/feemarket/v1/params.pulsar.go index 8aba756..8910064 100644 --- a/api/feemarket/feemarket/v1/params.pulsar.go +++ b/api/feemarket/feemarket/v1/params.pulsar.go @@ -842,7 +842,7 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { iNdEx = postIndex case 5: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinBaseFee", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MinBaseGasPrice", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { diff --git a/api/feemarket/feemarket/v1/query.pulsar.go b/api/feemarket/feemarket/v1/query.pulsar.go index f7d1058..39ddc0c 100644 --- a/api/feemarket/feemarket/v1/query.pulsar.go +++ b/api/feemarket/feemarket/v1/query.pulsar.go @@ -2587,7 +2587,7 @@ func (x *StateResponse) GetState() *State { return nil } -// BaseFeeRequest is the request type for the Query/BaseFee RPC method. +// BaseFeeRequest is the request type for the Query/BaseGasPrice RPC method. type BaseFeeRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2614,7 +2614,7 @@ func (*BaseFeeRequest) Descriptor() ([]byte, []int) { return file_feemarket_feemarket_v1_query_proto_rawDescGZIP(), []int{4} } -// StateResponse is the response type for the Query/BaseFee RPC method. +// StateResponse is the response type for the Query/BaseGasPrice RPC method. type BaseFeeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2759,10 +2759,10 @@ var file_feemarket_feemarket_v1_query_proto_depIdxs = []int32{ 8, // 2: feemarket.feemarket.v1.BaseFeeResponse.fee:type_name -> cosmos.base.v1beta1.Coin 0, // 3: feemarket.feemarket.v1.Query.Params:input_type -> feemarket.feemarket.v1.ParamsRequest 2, // 4: feemarket.feemarket.v1.Query.State:input_type -> feemarket.feemarket.v1.StateRequest - 4, // 5: feemarket.feemarket.v1.Query.BaseFee:input_type -> feemarket.feemarket.v1.BaseFeeRequest + 4, // 5: feemarket.feemarket.v1.Query.BaseGasPrice:input_type -> feemarket.feemarket.v1.BaseFeeRequest 1, // 6: feemarket.feemarket.v1.Query.Params:output_type -> feemarket.feemarket.v1.ParamsResponse 3, // 7: feemarket.feemarket.v1.Query.State:output_type -> feemarket.feemarket.v1.StateResponse - 5, // 8: feemarket.feemarket.v1.Query.BaseFee:output_type -> feemarket.feemarket.v1.BaseFeeResponse + 5, // 8: feemarket.feemarket.v1.Query.BaseGasPrice:output_type -> feemarket.feemarket.v1.BaseFeeResponse 6, // [6:9] is the sub-list for method output_type 3, // [3:6] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name diff --git a/api/feemarket/feemarket/v1/query_grpc.pb.go b/api/feemarket/feemarket/v1/query_grpc.pb.go index d100642..c18d6da 100644 --- a/api/feemarket/feemarket/v1/query_grpc.pb.go +++ b/api/feemarket/feemarket/v1/query_grpc.pb.go @@ -21,7 +21,7 @@ const _ = grpc.SupportPackageIsVersion7 const ( Query_Params_FullMethodName = "/feemarket.feemarket.v1.Query/Params" Query_State_FullMethodName = "/feemarket.feemarket.v1.Query/State" - Query_BaseFee_FullMethodName = "/feemarket.feemarket.v1.Query/BaseFee" + Query_BaseFee_FullMethodName = "/feemarket.feemarket.v1.Query/BaseGasPrice" ) // QueryClient is the client API for Query service. @@ -95,7 +95,7 @@ func (UnimplementedQueryServer) State(context.Context, *StateRequest) (*StateRes return nil, status.Errorf(codes.Unimplemented, "method State not implemented") } func (UnimplementedQueryServer) BaseFee(context.Context, *BaseFeeRequest) (*BaseFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BaseFee not implemented") + return nil, status.Errorf(codes.Unimplemented, "method BaseGasPrice not implemented") } func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} @@ -180,7 +180,7 @@ var Query_ServiceDesc = grpc.ServiceDesc{ Handler: _Query_State_Handler, }, { - MethodName: "BaseFee", + MethodName: "BaseGasPrice", Handler: _Query_BaseFee_Handler, }, }, diff --git a/proto/feemarket/feemarket/v1/genesis.proto b/proto/feemarket/feemarket/v1/genesis.proto index b274aa5..6133558 100644 --- a/proto/feemarket/feemarket/v1/genesis.proto +++ b/proto/feemarket/feemarket/v1/genesis.proto @@ -22,9 +22,9 @@ message GenesisState { // the current base fee, learning rate, and block utilization within the // specified AIMD window. message State { - // BaseFee is the current base fee. This is denominated in the fee per gas + // BaseGasPrice is the current base fee. This is denominated in the fee per gas // unit. - string base_fee = 1 [ + string base_gas_price = 1 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false diff --git a/proto/feemarket/feemarket/v1/params.proto b/proto/feemarket/feemarket/v1/params.proto index 9b7612b..13f74cf 100644 --- a/proto/feemarket/feemarket/v1/params.proto +++ b/proto/feemarket/feemarket/v1/params.proto @@ -44,9 +44,9 @@ message Params { (gogoproto.nullable) = false ]; - // MinBaseFee determines the initial base fee of the module and the global - // minimum for the network. This is denominated in fee per gas unit. - string min_base_fee = 5 [ + // 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 diff --git a/proto/feemarket/feemarket/v1/query.proto b/proto/feemarket/feemarket/v1/query.proto index 0c52aba..aefa5ad 100644 --- a/proto/feemarket/feemarket/v1/query.proto +++ b/proto/feemarket/feemarket/v1/query.proto @@ -26,10 +26,19 @@ service Query { }; }; - // BaseFee returns the current feemarket module base fee. - rpc BaseFee(BaseFeeRequest) returns (BaseFeeResponse) { + // GasPrice returns the current feemarket module gas price + // for specified denom. + rpc GasPrice(GasPriceRequest) returns (GasPriceResponse) { option (google.api.http) = { - get : "/feemarket/v1/base_fee" + get : "/feemarket/v1/gas_price/{denom}" + }; + }; + + // GasPrices returns the current feemarket module list of gas prices + // in all available denoms. + rpc GasPrices(GasPricesRequest) returns (GasPricesResponse) { + option (google.api.http) = { + get : "/feemarket/v1/gas_prices" }; }; } @@ -46,14 +55,31 @@ message StateRequest {} // StateResponse is the response type for the Query/State RPC method. message StateResponse { State state = 1 [ (gogoproto.nullable) = false ]; } -// BaseFeeRequest is the request type for the Query/BaseFee RPC method. -message BaseFeeRequest {} +// 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 + ]; +} -// StateResponse is the response type for the Query/BaseFee RPC method. -message BaseFeeResponse { - repeated cosmos.base.v1beta1.DecCoin fees = 1 [ +// 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" ]; -} +} \ No newline at end of file diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 76bdac7..aeb6adf 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -17,8 +17,8 @@ import ( ) var ( - minBaseFee = sdkmath.LegacyNewDec(10) - baseFee = sdkmath.LegacyNewDec(1000000) + minBaseGasPrice = sdkmath.LegacyNewDec(10) + baseGasPrice = sdkmath.LegacyNewDec(1000000) // config params numValidators = 3 @@ -42,7 +42,7 @@ var ( Beta: feemarkettypes.DefaultBeta, Theta: feemarkettypes.DefaultTheta, Delta: feemarkettypes.DefaultDelta, - MinBaseFee: minBaseFee, + MinBaseGasPrice: minBaseGasPrice, MinLearningRate: feemarkettypes.DefaultMinLearningRate, MaxLearningRate: feemarkettypes.DefaultMaxLearningRate, TargetBlockUtilization: feemarkettypes.DefaultTargetBlockUtilization / 4, @@ -56,7 +56,7 @@ var ( { Key: "app_state.feemarket.state", Value: feemarkettypes.State{ - BaseFee: baseFee, + BaseGasPrice: baseGasPrice, LearningRate: feemarkettypes.DefaultMaxLearningRate, Window: make([]uint64, feemarkettypes.DefaultWindow), Index: 0, diff --git a/tests/e2e/setup.go b/tests/e2e/setup.go index 1c148f0..30c0389 100644 --- a/tests/e2e/setup.go +++ b/tests/e2e/setup.go @@ -149,7 +149,7 @@ func (s *TestSuite) QueryState() types.State { return resp.State } -func (s *TestSuite) QueryBaseFee() sdk.DecCoins { +func (s *TestSuite) QueryDefaultGasPrice() sdk.DecCoin { s.T().Helper() // get grpc address @@ -162,10 +162,12 @@ func (s *TestSuite) QueryBaseFee() sdk.DecCoins { // create the oracle client c := types.NewQueryClient(cc) - resp, err := c.BaseFee(context.Background(), &types.BaseFeeRequest{}) + resp, err := c.GasPrice(context.Background(), &types.GasPriceRequest{ + Denom: sdk.DefaultBondDenom, + }) s.Require().NoError(err) - return resp.Fees + return resp.GetPrice() } // QueryValidators queries for all the network's validators diff --git a/tests/e2e/suite.go b/tests/e2e/suite.go index 88eebb2..d780dc6 100644 --- a/tests/e2e/suite.go +++ b/tests/e2e/suite.go @@ -5,8 +5,6 @@ import ( "math/rand" "sync" - feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" - "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" @@ -123,8 +121,8 @@ func (s *TestSuite) SetupSubTest() { state := s.QueryState() s.T().Log("state at block height", height+1, ":", state.String()) - fee := s.QueryBaseFee() - s.T().Log("fee at block height", height+1, ":", fee.String()) + gasPrice := s.QueryDefaultGasPrice() + s.T().Log("gas price at block height", height+1, ":", gasPrice.String()) } func (s *TestSuite) TestQueryParams() { @@ -147,17 +145,17 @@ func (s *TestSuite) TestQueryState() { }) } -func (s *TestSuite) TestQueryBaseFee() { - s.Run("query base fee", func() { - // query base fee - fees := s.QueryBaseFee() +func (s *TestSuite) TestQueryGasPrice() { + s.Run("query gas price", func() { + // query gas price + gasPrice := s.QueryDefaultGasPrice() // expect validate to pass - require.NoError(s.T(), fees.Validate(), fees) + require.NoError(s.T(), gasPrice.Validate(), gasPrice) }) } -// TestSendTxDecrease tests that the feemarket will decrease until it hits the min base fee +// TestSendTxDecrease tests that the feemarket will decrease until it hits the min gas price // when gas utilization is below the target block utilization. func (s *TestSuite) TestSendTxDecrease() { // cast chain to cosmos-chain @@ -169,16 +167,16 @@ func (s *TestSuite) TestSendTxDecrease() { params := s.QueryParams() - baseFee := s.QueryBaseFee() + defaultGasPrice := s.QueryDefaultGasPrice() gas := int64(200000) - minBaseFee := baseFee.MulDec(math.LegacyNewDec(gas))[0] + minBaseFee := sdk.NewDecCoinFromDec(defaultGasPrice.Denom, defaultGasPrice.Amount.Mul(math.LegacyNewDec(gas))) minBaseFeeCoins := sdk.NewCoins(sdk.NewCoin(minBaseFee.Denom, minBaseFee.Amount.TruncateInt())) sendAmt := int64(100000) s.Run("expect fee market state to decrease", func() { s.T().Log("performing sends...") for { - // send with the exact expected fee + // send with the exact expected defaultGasPrice wg := sync.WaitGroup{} wg.Add(3) @@ -232,10 +230,10 @@ func (s *TestSuite) TestSendTxDecrease() { }() wg.Wait() - fee := s.QueryBaseFee() - s.T().Log("base fee", fee.String()) + gasPrice := s.QueryDefaultGasPrice() + s.T().Log("base defaultGasPrice", gasPrice.String()) - if fee.AmountOf(feemarkettypes.DefaultFeeDenom).Equal(params.MinBaseFee) { + if gasPrice.Amount.Equal(params.MinBaseGasPrice) { break } } @@ -246,8 +244,8 @@ func (s *TestSuite) TestSendTxDecrease() { s.Require().NoError(err) s.WaitForHeight(s.chain.(*cosmos.CosmosChain), height+5) - fee := s.QueryBaseFee() - s.T().Log("base fee", fee.String()) + gasPrice := s.QueryDefaultGasPrice() + s.T().Log("gas price", gasPrice.String()) amt, err := s.chain.GetBalance(context.Background(), s.user1.FormattedAddress(), minBaseFee.Denom) s.Require().NoError(err) @@ -266,16 +264,16 @@ func (s *TestSuite) TestSendTxIncrease() { nodes := cosmosChain.Nodes() s.Require().True(len(nodes) > 0) - baseFee := s.QueryBaseFee() + baseGasPrice := s.QueryDefaultGasPrice() gas := int64(20000100) sendAmt := int64(100) - s.Run("expect fee market fee to increase", func() { + s.Run("expect fee market gas price to increase", func() { s.T().Log("performing sends...") for { - // send with the exact expected fee - baseFee = s.QueryBaseFee() - minBaseFee := baseFee.MulDec(math.LegacyNewDec(gas))[0] + // send with the exact expected baseGasPrice + baseGasPrice = s.QueryDefaultGasPrice() + minBaseFee := sdk.NewDecCoinFromDec(baseGasPrice.Denom, baseGasPrice.Amount.Mul(math.LegacyNewDec(gas))) // add headroom minBaseFeeCoins := sdk.NewCoins(sdk.NewCoin(minBaseFee.Denom, minBaseFee.Amount.Add(math.LegacyNewDec(10)).TruncateInt())) @@ -331,10 +329,10 @@ func (s *TestSuite) TestSendTxIncrease() { }() wg.Wait() - baseFee = s.QueryBaseFee() - s.T().Log("base fee", baseFee.String()) + baseGasPrice = s.QueryDefaultGasPrice() + s.T().Log("gas price", baseGasPrice.String()) - if baseFee.AmountOf(feemarkettypes.DefaultFeeDenom).GT(math.LegacyNewDec(1000000)) { + if baseGasPrice.Amount.GT(math.LegacyNewDec(1000000)) { break } } @@ -345,10 +343,10 @@ func (s *TestSuite) TestSendTxIncrease() { s.Require().NoError(err) s.WaitForHeight(s.chain.(*cosmos.CosmosChain), height+5) - fee := s.QueryBaseFee() - s.T().Log("base fee", fee.String()) + gasPrice := s.QueryDefaultGasPrice() + s.T().Log("gas price", gasPrice.String()) - amt, err := s.chain.GetBalance(context.Background(), s.user1.FormattedAddress(), baseFee[0].Denom) + amt, err := s.chain.GetBalance(context.Background(), s.user1.FormattedAddress(), gasPrice.Denom) s.Require().NoError(err) s.Require().True(amt.LT(math.NewInt(initBalance)), amt) s.T().Log("balance:", amt.String()) diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 1ebe9d1..b7edd80 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -86,7 +86,7 @@ func (s *IntegrationTestSuite) TestParams() { Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), - MinBaseFee: math.LegacyNewDec(10), + MinBaseGasPrice: math.LegacyNewDec(10), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, diff --git a/x/feemarket/ante/expected_keepers.go b/x/feemarket/ante/expected_keepers.go index d8b377b..c1c1d9f 100644 --- a/x/feemarket/ante/expected_keepers.go +++ b/x/feemarket/ante/expected_keepers.go @@ -46,7 +46,7 @@ type BankKeeper interface { //go:generate mockery --name FeeMarketKeeper --filename mock_feemarket_keeper.go type FeeMarketKeeper interface { GetState(ctx sdk.Context) (feemarkettypes.State, error) - GetMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) + GetMinGasPrice(ctx sdk.Context, denom string) (sdk.DecCoin, error) GetParams(ctx sdk.Context) (feemarkettypes.Params, error) SetState(ctx sdk.Context, state feemarkettypes.State) error SetParams(ctx sdk.Context, params feemarkettypes.Params) error diff --git a/x/feemarket/ante/fee.go b/x/feemarket/ante/fee.go index 838f7f6..cd84452 100644 --- a/x/feemarket/ante/fee.go +++ b/x/feemarket/ante/fee.go @@ -43,12 +43,15 @@ func (dfd FeeMarketCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, sdkerrors.ErrInvalidGasLimit.Wrapf("must provide positive gas") } - minGasPrices, err := dfd.feemarketKeeper.GetMinGasPrices(ctx) + params, err := dfd.feemarketKeeper.GetParams(ctx) if err != nil { - return ctx, errorsmod.Wrapf(err, "unable to get fee market state") + return ctx, errorsmod.Wrapf(err, "unable to get fee market params") } - minFee := minGasPrices[0] + // return if disabled + if !params.Enabled { + return next(ctx, tx, simulate) + } feeCoins := feeTx.GetFee() gas := feeTx.GetGas() // use provided gas limit @@ -60,48 +63,40 @@ func (dfd FeeMarketCheckDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, errorsmod.Wrapf(feemarkettypes.ErrTooManyFeeCoins, "got length %d", len(feeCoins)) } + feeCoin := feeCoins[0] + feeGas := int64(feeTx.GetGas()) + + minGasPrice, err := dfd.feemarketKeeper.GetMinGasPrice(ctx, feeCoin.GetDenom()) + if err != nil { + return ctx, errorsmod.Wrapf(err, "unable to get min gas price for denom %s", feeCoin.GetDenom()) + } + ctx.Logger().Info("fee deduct ante handle", - "min gas prices", minFee, + "min gas prices", minGasPrice, "fee", feeCoins, "gas limit", gas, ) + ctx = ctx.WithMinGasPrices(sdk.NewDecCoins(minGasPrice)) + if !simulate { - fee, _, err := CheckTxFee(ctx, minFee, feeTx, true, dfd.feemarketKeeper.GetDenomResolver()) + fee, _, err := CheckTxFee(ctx, minGasPrice, feeCoin, feeGas, true) if err != nil { return ctx, errorsmod.Wrapf(err, "error checking fee") } - priorityCtx := ctx.WithPriority(getTxPriority(fee, int64(gas))).WithMinGasPrices(minGasPrices) - return next(priorityCtx, tx, simulate) + ctx = ctx.WithPriority(getTxPriority(fee, int64(gas))) + return next(ctx, tx, simulate) } - - ctx = ctx.WithMinGasPrices(minGasPrices) return next(ctx, tx, simulate) } // CheckTxFee implements the logic for the fee market to check if a Tx has provided sufficient // fees given the current state of the fee market. Returns an error if insufficient fees. -func CheckTxFee(ctx sdk.Context, minFeesDecCoin sdk.DecCoin, feeTx sdk.FeeTx, isCheck bool, resolver feemarkettypes.DenomResolver) (payCoin sdk.Coin, tip sdk.Coin, err error) { - if len(feeTx.GetFee()) != 1 { - if len(feeTx.GetFee()) == 0 { - return sdk.Coin{}, sdk.Coin{}, errorsmod.Wrapf(feemarkettypes.ErrNoFeeCoins, "got length %d", len(feeTx.GetFee())) - } - return sdk.Coin{}, sdk.Coin{}, errorsmod.Wrapf(feemarkettypes.ErrTooManyFeeCoins, "got length %d", len(feeTx.GetFee())) - } - - feeDenom := minFeesDecCoin.Denom - feeCoin := feeTx.GetFee()[0] - - coinWithBaseDenom := feeCoin - if feeCoin.Denom != feeDenom { - coinWithBaseDenom, err = resolver.ConvertToDenom(ctx, feeCoin, feeDenom) - if err != nil { - return sdk.Coin{}, sdk.Coin{}, err - } - } +func CheckTxFee(ctx sdk.Context, minGasPrice sdk.DecCoin, feeCoin sdk.Coin, feeGas int64, isCheck bool) (payCoin sdk.Coin, tip sdk.Coin, err error) { + payCoin = feeCoin // Ensure that the provided fees meet the minimum - if !minFeesDecCoin.IsZero() { + if !minGasPrice.IsZero() { var ( requiredFee sdk.Coin consumedFee sdk.Coin @@ -111,50 +106,35 @@ func CheckTxFee(ctx sdk.Context, minFeesDecCoin sdk.DecCoin, feeTx sdk.FeeTx, is // price by the gas, where fee = ceil(minGasPrice * gas). gasConsumed := int64(ctx.GasMeter().GasConsumed()) gcDec := sdkmath.LegacyNewDec(gasConsumed) - glDec := sdkmath.LegacyNewDec(int64(feeTx.GetGas())) + glDec := sdkmath.LegacyNewDec(feeGas) - consumedFeeAmount := minFeesDecCoin.Amount.Mul(gcDec) - limitFee := minFeesDecCoin.Amount.Mul(glDec) - consumedFee = sdk.NewCoin(minFeesDecCoin.Denom, consumedFeeAmount.Ceil().RoundInt()) - requiredFee = sdk.NewCoin(minFeesDecCoin.Denom, limitFee.Ceil().RoundInt()) + consumedFeeAmount := minGasPrice.Amount.Mul(gcDec) + limitFee := minGasPrice.Amount.Mul(glDec) + consumedFee = sdk.NewCoin(minGasPrice.Denom, consumedFeeAmount.Ceil().RoundInt()) + requiredFee = sdk.NewCoin(minGasPrice.Denom, limitFee.Ceil().RoundInt()) - if coinWithBaseDenom.Denom != requiredFee.Denom || !coinWithBaseDenom.IsGTE(requiredFee) { + if !payCoin.IsGTE(requiredFee) { return sdk.Coin{}, sdk.Coin{}, sdkerrors.ErrInsufficientFee.Wrapf( "got: %s required: %s, minGasPrice: %s, gas: %d", - coinWithBaseDenom, + payCoin, requiredFee, - minFeesDecCoin, + minGasPrice, gasConsumed, ) } - // convert back to given denom is not base denom - if feeCoin.Denom != requiredFee.Denom { - requiredFee, err = resolver.ConvertToDenom(ctx, requiredFee, feeCoin.Denom) - if err != nil { - return sdk.Coin{}, sdk.Coin{}, err - } - - if !isCheck { - consumedFee, err = resolver.ConvertToDenom(ctx, consumedFee, feeCoin.Denom) - if err != nil { - return sdk.Coin{}, sdk.Coin{}, err - } - } - } - if isCheck { // set fee coins to be required amount if checking - feeCoin = requiredFee + payCoin = requiredFee } else { - // tip is the difference between feeCoin and the required fee - tip = feeCoin.Sub(requiredFee) + // tip is the difference between payCoin and the required fee + tip = payCoin.Sub(requiredFee) // set fee coin to be ONLY the consumed amount if we are calculated consumed fee to deduct - feeCoin = consumedFee + payCoin = consumedFee } } - return feeCoin, tip, nil + return payCoin, tip, nil } // getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price diff --git a/x/feemarket/ante/fee_test.go b/x/feemarket/ante/fee_test.go index 5a66206..86aa4d7 100644 --- a/x/feemarket/ante/fee_test.go +++ b/x/feemarket/ante/fee_test.go @@ -19,7 +19,7 @@ func TestAnteHandle(t *testing.T) { // Same data for every test case gasLimit := antesuite.NewTestGasLimit() - validFeeAmount := types.DefaultMinBaseFee.MulInt64(int64(gasLimit)) + validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit)) validFee := sdk.NewCoins(sdk.NewCoin("stake", validFeeAmount.TruncateInt())) validFeeDifferentDenom := sdk.NewCoins(sdk.NewCoin("atom", math.Int(validFeeAmount))) diff --git a/x/feemarket/client/cli/query.go b/x/feemarket/client/cli/query.go index 2bbd0ed..5c320e8 100644 --- a/x/feemarket/client/cli/query.go +++ b/x/feemarket/client/cli/query.go @@ -25,7 +25,8 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand( GetParamsCmd(), GetStateCmd(), - GetBaseFeeCmd(), + GetGasPriceCmd(), + GetGasPricesCmd(), ) return cmd @@ -85,11 +86,40 @@ func GetStateCmd() *cobra.Command { return cmd } -// GetBaseFeeCmd returns the cli-command that queries the current feemarket base fee. -func GetBaseFeeCmd() *cobra.Command { +// GetGasPriceCmd returns the cli-command that queries the current feemarket gas price. +func GetGasPriceCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "base-fee", - Short: "Query for the current feemarket base fee", + Use: "gas-price", + Short: "Query for the current feemarket gas price", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + resp, err := queryClient.GasPrice(cmd.Context(), &types.GasPriceRequest{ + Denom: args[0], + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(resp) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetGasPricesCmd returns the cli-command that queries all current feemarket gas prices. +func GetGasPricesCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "gas-prices", + Short: "Query for all current feemarket gas prices", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -98,12 +128,12 @@ func GetBaseFeeCmd() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - resp, err := queryClient.BaseFee(cmd.Context(), &types.BaseFeeRequest{}) + resp, err := queryClient.GasPrices(cmd.Context(), &types.GasPricesRequest{}) if err != nil { return err } - return clientCtx.PrintString(resp.Fees.String()) + return clientCtx.PrintProto(resp) }, } diff --git a/x/feemarket/fuzz/aimd_eip1559_test.go b/x/feemarket/fuzz/aimd_eip1559_test.go index 70cee8f..eec6d9d 100644 --- a/x/feemarket/fuzz/aimd_eip1559_test.go +++ b/x/feemarket/fuzz/aimd_eip1559_test.go @@ -78,7 +78,7 @@ func TestAIMDBaseFee(t *testing.T) { // Update the fee market. for i := uint64(0); i < numBlocks; i++ { blockUtilization := gasGen.Draw(t, "gas") - prevBaseFee := state.BaseFee + prevBaseGasPrice := state.BaseGasPrice if err := state.Update(blockUtilization, params); err != nil { t.Fatalf("block update errors: %v", err) @@ -86,28 +86,28 @@ func TestAIMDBaseFee(t *testing.T) { // Update the learning rate. state.UpdateLearningRate(params) - // Update the base fee. - state.UpdateBaseFee(params) + // Update the base gas price. + state.UpdateBaseGasPrice(params) // Ensure that the minimum base fee is always less than the base fee. - require.True(t, params.MinBaseFee.LTE(state.BaseFee)) + require.True(t, params.MinBaseGasPrice.LTE(state.BaseGasPrice)) switch { case blockUtilization > params.TargetBlockUtilization: - require.True(t, state.BaseFee.GTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.GTE(prevBaseGasPrice)) case blockUtilization < params.TargetBlockUtilization: - require.True(t, state.BaseFee.LTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.LTE(prevBaseGasPrice)) default: // Account for the delta adjustment. net := state.GetNetUtilization(params) switch { case net.GT(math.ZeroInt()): - require.True(t, state.BaseFee.GTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.GTE(prevBaseGasPrice)) case net.LT(math.ZeroInt()): - require.True(t, state.BaseFee.LTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.LTE(prevBaseGasPrice)) default: - require.True(t, state.BaseFee.Equal(prevBaseFee)) + require.True(t, state.BaseGasPrice.Equal(prevBaseGasPrice)) } } diff --git a/x/feemarket/fuzz/eip1559_test.go b/x/feemarket/fuzz/eip1559_test.go index 059aaa9..e886629 100644 --- a/x/feemarket/fuzz/eip1559_test.go +++ b/x/feemarket/fuzz/eip1559_test.go @@ -43,8 +43,8 @@ func TestBaseFee(t *testing.T) { params := CreateRandomParams(t) // Update the current base fee to be 10% higher than the minimum base fee. - prevBaseFee := state.BaseFee.Mul(math.LegacyNewDec(11)).Quo(math.LegacyNewDec(10)) - state.BaseFee = prevBaseFee + prevBaseFee := state.BaseGasPrice.Mul(math.LegacyNewDec(11)).Quo(math.LegacyNewDec(10)) + state.BaseGasPrice = prevBaseFee // Randomly generate the block utilization. blockUtilization := rapid.Uint64Range(0, params.MaxBlockUtilization).Draw(t, "gas") @@ -57,18 +57,18 @@ func TestBaseFee(t *testing.T) { // Update the learning rate. state.UpdateLearningRate(params) // Update the base fee. - state.UpdateBaseFee(params) + state.UpdateBaseGasPrice(params) // Ensure that the minimum base fee is always less than the base fee. - require.True(t, params.MinBaseFee.LTE(state.BaseFee)) + require.True(t, params.MinBaseGasPrice.LTE(state.BaseGasPrice)) switch { case blockUtilization > params.TargetBlockUtilization: - require.True(t, state.BaseFee.GTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.GTE(prevBaseFee)) case blockUtilization < params.TargetBlockUtilization: - require.True(t, state.BaseFee.LTE(prevBaseFee)) + require.True(t, state.BaseGasPrice.LTE(prevBaseFee)) default: - require.Equal(t, state.BaseFee, prevBaseFee) + require.Equal(t, state.BaseGasPrice, prevBaseFee) } }) } diff --git a/x/feemarket/keeper/feemarket.go b/x/feemarket/keeper/feemarket.go index 46eaefe..2c27614 100644 --- a/x/feemarket/keeper/feemarket.go +++ b/x/feemarket/keeper/feemarket.go @@ -36,13 +36,13 @@ func (k *Keeper) UpdateFeeMarket(ctx sdk.Context) error { params, ) - // Update the base fee based with the new learning rate and delta adjustment. - newBaseFee := state.UpdateBaseFee(params) + // Update the base gas price based with the new learning rate and delta adjustment. + newBaseGasPrice := state.UpdateBaseGasPrice(params) k.Logger(ctx).Info( "updated the fee market", "height", ctx.BlockHeight(), - "new_base_fee", newBaseFee, + "new_base_gas_price", newBaseGasPrice, "new_learning_rate", newLR, "average_block_utilization", state.GetAverageUtilization(params), "net_block_utilization", state.GetNetUtilization(params), @@ -53,14 +53,14 @@ func (k *Keeper) UpdateFeeMarket(ctx sdk.Context) error { return k.SetState(ctx, state) } -// GetBaseFee returns the base fee from the fee market state. -func (k *Keeper) GetBaseFee(ctx sdk.Context) (math.LegacyDec, error) { +// GetBaseGasPrice returns the base fee from the fee market state. +func (k *Keeper) GetBaseGasPrice(ctx sdk.Context) (math.LegacyDec, error) { state, err := k.GetState(ctx) if err != nil { return math.LegacyDec{}, err } - return state.BaseFee, nil + return state.BaseGasPrice, nil } // GetLearningRate returns the learning rate from the fee market state. @@ -73,9 +73,35 @@ func (k *Keeper) GetLearningRate(ctx sdk.Context) (math.LegacyDec, error) { return state.LearningRate, nil } -// GetMinGasPrices returns the mininum gas prices as sdk.Coins from the fee market state. +// GetMinGasPrice returns the mininum gas prices for given denom as sdk.DecCoins from the fee market state. +func (k *Keeper) GetMinGasPrice(ctx sdk.Context, denom string) (sdk.DecCoin, error) { + baseGasPrice, err := k.GetBaseGasPrice(ctx) + if err != nil { + return sdk.DecCoin{}, err + } + + params, err := k.GetParams(ctx) + if err != nil { + return sdk.DecCoin{}, err + } + + var gasPrice sdk.DecCoin + + if params.FeeDenom == denom { + gasPrice = sdk.NewDecCoinFromDec(params.FeeDenom, baseGasPrice) + } else { + gasPrice, err = k.GetDenomResolver().ConvertToDenom(ctx, sdk.NewDecCoinFromDec(params.FeeDenom, baseGasPrice), denom) + if err != nil { + return sdk.DecCoin{}, err + } + } + + return gasPrice, nil +} + +// GetMinGasPrices returns the mininum gas prices as sdk.DecCoins from the fee market state. func (k *Keeper) GetMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) { - baseFee, err := k.GetBaseFee(ctx) + baseGasPrice, err := k.GetBaseGasPrice(ctx) if err != nil { return sdk.NewDecCoins(), err } @@ -85,8 +111,26 @@ func (k *Keeper) GetMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) { return sdk.NewDecCoins(), err } - fee := sdk.NewDecCoinFromDec(params.FeeDenom, baseFee) - minGasPrices := sdk.NewDecCoins(fee) + minGasPrice := sdk.NewDecCoinFromDec(params.FeeDenom, baseGasPrice) + minGasPrices := sdk.NewDecCoins(minGasPrice) + + extraDenoms, err := k.resolver.ExtraDenoms(ctx) + if err != nil { + return sdk.NewDecCoins(), err + } + + for _, denom := range extraDenoms { + gasPrice, err := k.GetDenomResolver().ConvertToDenom(ctx, minGasPrice, denom) + if err != nil { + k.Logger(ctx).Info( + "failed to convert gas price", + "min gas price", minGasPrice, + "denom", denom, + ) + continue + } + minGasPrices.Add(gasPrice) + } return minGasPrices, nil } diff --git a/x/feemarket/keeper/feemarket_test.go b/x/feemarket/keeper/feemarket_test.go index 0ca81dd..1cc366a 100644 --- a/x/feemarket/keeper/feemarket_test.go +++ b/x/feemarket/keeper/feemarket_test.go @@ -15,9 +15,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -26,18 +26,18 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("empty block with default eip1559 with preset base fee", func() { state := types.DefaultState() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) params := types.DefaultParams() s.setGenesisState(params, state) s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to decrease by 1/8th. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("0.875") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -48,16 +48,16 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("empty block with default eip1559 with preset base fee < 1", func() { state := types.DefaultState() // this value should be ignored -> 0.5 should be used instead - state.BaseFee = math.LegacyMustNewDecFromStr("0.25") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("0.25") - // change MinBaseFee value < 1 + // change MinBaseGasPrice value < 1 params := types.DefaultParams() - params.MinBaseFee = math.LegacyMustNewDecFromStr("0.5") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("0.5") s.setGenesisState(params, state) s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) s.Require().Equal(fee, math.LegacyMustNewDecFromStr("0.5")) @@ -72,8 +72,8 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { // should default to the minimum base fee. state := types.DefaultState() factor := math.LegacyMustNewDecFromStr("0.125") - change := state.BaseFee.Mul(factor) - state.BaseFee = types.DefaultMinBaseFee.Sub(change) + change := state.BaseGasPrice.Mul(factor) + state.BaseGasPrice = types.DefaultMinBaseGasPrice.Sub(change) params := types.DefaultParams() s.setGenesisState(params, state) @@ -81,9 +81,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to decrease by 1/8th. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -104,9 +104,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to remain the same. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -117,7 +117,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state := types.DefaultState() params := types.DefaultParams() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) // Reaching the target block size means that we expect this to not // increase. err := state.Update(params.TargetBlockUtilization, params) @@ -128,9 +128,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to remain the same. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(state.BaseFee, fee) + s.Require().Equal(state.BaseGasPrice, fee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -151,11 +151,11 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to increase by 1/8th. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("1.125") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -167,7 +167,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state := types.DefaultState() params := types.DefaultParams() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) // Reaching the target block size means that we expect this to not // increase. err := state.Update(params.MaxBlockUtilization, params) @@ -178,11 +178,11 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to increase by 1/8th. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("1.125") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -204,9 +204,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to remain the same since it is at min base fee. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -215,7 +215,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("in-between min and target block with default eip1559 at preset base fee", func() { state := types.DefaultState() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) params := types.DefaultParams() params.MaxBlockUtilization = 100 @@ -229,11 +229,11 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to decrease by 1/8th * 1/2. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("0.9375") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -255,11 +255,11 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to increase by 1/8th * 1/2. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("1.0625") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -269,7 +269,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("in-between target and max block with default eip1559 at preset base fee", func() { state := types.DefaultState() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) params := types.DefaultParams() params.MaxBlockUtilization = 100 params.TargetBlockUtilization = 50 @@ -282,11 +282,11 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) // We expect the base fee to increase by 1/8th * 1/2. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyMustNewDecFromStr("1.0625") - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) @@ -301,9 +301,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(s.feeMarketKeeper.UpdateFeeMarket(s.ctx)) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) lr, err := s.feeMarketKeeper.GetLearningRate(s.ctx) s.Require().NoError(err) @@ -313,7 +313,7 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Run("empty blocks with aimd eip1559 with preset base fee", func() { state := types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) params := types.DefaultAIMDParams() s.setGenesisState(params, state) @@ -326,10 +326,10 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { expectedLR := state.LearningRate.Add(params.Alpha) s.Require().Equal(expectedLR, lr) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) factor := math.LegacyOneDec().Add(math.LegacyMustNewDecFromStr("-1.0").Mul(lr)) - expectedFee := state.BaseFee.Mul(factor) + expectedFee := state.BaseGasPrice.Mul(factor) s.Require().Equal(fee, expectedFee) }) @@ -338,9 +338,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { state := types.DefaultAIMDState() lr := math.LegacyMustNewDecFromStr("0.125") - increase := state.BaseFee.Mul(lr).TruncateInt() + increase := state.BaseGasPrice.Mul(lr).TruncateInt() - state.BaseFee = types.DefaultMinBaseFee.Add(math.LegacyNewDecFromInt(increase)).Sub(math.LegacyNewDec(1)) + state.BaseGasPrice = types.DefaultMinBaseGasPrice.Add(math.LegacyNewDecFromInt(increase)).Sub(math.LegacyNewDec(1)) state.LearningRate = lr s.setGenesisState(params, state) @@ -354,9 +354,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { // We expect the base fee to decrease by 1/8th and the learning rate to // increase by alpha. - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, params.MinBaseFee) + s.Require().Equal(fee, params.MinBaseGasPrice) }) s.Run("target block with aimd eip1559 at min base fee + LR", func() { @@ -379,14 +379,14 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { s.Require().NoError(err) s.Require().Equal(params.MinLearningRate, lr) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(state.BaseFee, fee) + s.Require().Equal(state.BaseGasPrice, fee) }) s.Run("target block with aimd eip1559 at preset base fee + LR", func() { state := types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyNewDec(2)) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyNewDec(2)) state.LearningRate = math.LegacyMustNewDecFromStr("0.125") params := types.DefaultAIMDParams() @@ -407,9 +407,9 @@ func (s *KeeperTestSuite) TestUpdateFeeMarket() { expectedLR := state.LearningRate.Mul(params.Beta) s.Require().Equal(expectedLR, lr) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(state.BaseFee, fee) + s.Require().Equal(state.BaseGasPrice, fee) }) } @@ -418,18 +418,18 @@ func (s *KeeperTestSuite) TestGetBaseFee() { gs := types.DefaultGenesisState() s.feeMarketKeeper.InitGenesis(s.ctx, *gs) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, gs.State.BaseFee) + s.Require().Equal(fee, gs.State.BaseGasPrice) }) s.Run("can retrieve base fee with aimd eip-1559", func() { gs := types.DefaultAIMDGenesisState() s.feeMarketKeeper.InitGenesis(s.ctx, *gs) - fee, err := s.feeMarketKeeper.GetBaseFee(s.ctx) + fee, err := s.feeMarketKeeper.GetBaseGasPrice(s.ctx) s.Require().NoError(err) - s.Require().Equal(fee, gs.State.BaseFee) + s.Require().Equal(fee, gs.State.BaseGasPrice) }) } @@ -458,7 +458,7 @@ func (s *KeeperTestSuite) TestGetMinGasPrices() { gs := types.DefaultGenesisState() s.feeMarketKeeper.InitGenesis(s.ctx, *gs) - expected := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, gs.State.BaseFee)) + expected := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, gs.State.BaseGasPrice)) mgp, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx) s.Require().NoError(err) @@ -469,7 +469,7 @@ func (s *KeeperTestSuite) TestGetMinGasPrices() { gs := types.DefaultAIMDGenesisState() s.feeMarketKeeper.InitGenesis(s.ctx, *gs) - expected := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, gs.State.BaseFee)) + expected := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, gs.State.BaseGasPrice)) mgp, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx) s.Require().NoError(err) diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index eb64cfa..7022ed3 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -57,9 +57,9 @@ func (k *Keeper) GetAuthority() string { } // ResolveToBaseDenom converts the given coin to the given denomination. -func (k *Keeper) ResolveToBaseDenom(ctx sdk.Context, coin sdk.Coin, denom string) (sdk.Coin, error) { +func (k *Keeper) ResolveToBaseDenom(ctx sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) { if k.resolver == nil { - return sdk.Coin{}, types.ErrResolverNotSet + return sdk.DecCoin{}, types.ErrResolverNotSet } return k.resolver.ConvertToDenom(ctx, coin, denom) diff --git a/x/feemarket/keeper/keeper_test.go b/x/feemarket/keeper/keeper_test.go index 6abb27a..00f6b25 100644 --- a/x/feemarket/keeper/keeper_test.go +++ b/x/feemarket/keeper/keeper_test.go @@ -102,7 +102,7 @@ func (s *KeeperTestSuite) TestParams() { Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), - MinBaseFee: math.LegacyNewDec(10), + MinBaseGasPrice: math.LegacyNewDec(10), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, diff --git a/x/feemarket/keeper/msg_server.go b/x/feemarket/keeper/msg_server.go index 4403249..f1ce181 100644 --- a/x/feemarket/keeper/msg_server.go +++ b/x/feemarket/keeper/msg_server.go @@ -35,7 +35,7 @@ func (ms MsgServer) Params(goCtx context.Context, msg *types.MsgParams) (*types. return nil, fmt.Errorf("error setting params: %w", err) } - newState := types.NewState(params.Window, params.MinBaseFee, params.MinLearningRate) + newState := types.NewState(params.Window, params.MinBaseGasPrice, params.MinLearningRate) if err := ms.k.SetState(ctx, newState); err != nil { return nil, fmt.Errorf("error setting state: %w", err) } diff --git a/x/feemarket/keeper/query_server.go b/x/feemarket/keeper/query_server.go index 5c4b203..98b35e5 100644 --- a/x/feemarket/keeper/query_server.go +++ b/x/feemarket/keeper/query_server.go @@ -36,10 +36,18 @@ func (q QueryServer) State(goCtx context.Context, _ *types.StateRequest) (*types return &types.StateResponse{State: state}, err } -// BaseFee defines a method that returns the current feemarket base fee. -func (q QueryServer) BaseFee(goCtx context.Context, _ *types.BaseFeeRequest) (*types.BaseFeeResponse, error) { +// GasPrice defines a method that returns the current feemarket base gas price. +func (q QueryServer) GasPrice(goCtx context.Context, req *types.GasPriceRequest) (*types.GasPriceResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - fee, err := q.k.GetMinGasPrices(ctx) - return &types.BaseFeeResponse{Fees: fee}, err + gasPrice, err := q.k.GetMinGasPrice(ctx, req.GetDenom()) + return &types.GasPriceResponse{Price: gasPrice}, err +} + +// GasPrices defines a method that returns the current feemarket list of gas prices. +func (q QueryServer) GasPrices(goCtx context.Context, _ *types.GasPricesRequest) (*types.GasPricesResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + gasPrices, err := q.k.GetMinGasPrices(ctx) + return &types.GasPricesResponse{Prices: gasPrices}, err } diff --git a/x/feemarket/keeper/query_server_test.go b/x/feemarket/keeper/query_server_test.go index ae08b6f..c4101f9 100644 --- a/x/feemarket/keeper/query_server_test.go +++ b/x/feemarket/keeper/query_server_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "cosmossdk.io/math" - "github.com/skip-mev/feemarket/x/feemarket/types" ) @@ -27,7 +26,7 @@ func (s *KeeperTestSuite) TestParamsRequest() { Beta: math.LegacyMustNewDecFromStr("0.1"), Theta: math.LegacyMustNewDecFromStr("0.1"), Delta: math.LegacyMustNewDecFromStr("0.1"), - MinBaseFee: math.LegacyNewDec(10), + MinBaseGasPrice: math.LegacyNewDec(10), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 5, @@ -69,7 +68,7 @@ func (s *KeeperTestSuite) TestStateRequest() { s.Run("can get updated state", func() { state := types.State{ - BaseFee: math.LegacyOneDec(), + BaseGasPrice: math.LegacyOneDec(), LearningRate: math.LegacyOneDec(), Window: []uint64{1}, Index: 0, @@ -92,21 +91,23 @@ func (s *KeeperTestSuite) TestStateRequest() { } func (s *KeeperTestSuite) TestBaseFeeRequest() { - s.Run("can get default base fee", func() { - req := &types.BaseFeeRequest{} - resp, err := s.queryServer.BaseFee(s.ctx, req) + s.Run("can get gas price", func() { + req := &types.GasPriceRequest{ + Denom: "stake", + } + resp, err := s.queryServer.GasPrice(s.ctx, req) s.Require().NoError(err) s.Require().NotNil(resp) - fee, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx) + gasPrice, err := s.feeMarketKeeper.GetMinGasPrice(s.ctx, req.GetDenom()) s.Require().NoError(err) - s.Require().Equal(resp.Fees, fee) + s.Require().Equal(resp.GetPrice(), gasPrice) }) - s.Run("can get updated base fee", func() { + s.Run("can get updated gas price", func() { state := types.State{ - BaseFee: math.LegacyOneDec(), + BaseGasPrice: math.LegacyOneDec(), } err := s.feeMarketKeeper.SetState(s.ctx, state) s.Require().NoError(err) @@ -117,20 +118,22 @@ func (s *KeeperTestSuite) TestBaseFeeRequest() { err = s.feeMarketKeeper.SetParams(s.ctx, params) s.Require().NoError(err) - req := &types.BaseFeeRequest{} - resp, err := s.queryServer.BaseFee(s.ctx, req) + req := &types.GasPriceRequest{ + Denom: "stake", + } + resp, err := s.queryServer.GasPrice(s.ctx, req) s.Require().NoError(err) s.Require().NotNil(resp) - fees, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx) + gasPrice, err := s.feeMarketKeeper.GetMinGasPrice(s.ctx, req.GetDenom()) s.Require().NoError(err) - s.Require().Equal(resp.Fees, fees) + s.Require().Equal(resp.GetPrice(), gasPrice) }) - s.Run("can get updated base fee < 1", func() { + s.Run("can get updated gas price < 1", func() { state := types.State{ - BaseFee: math.LegacyMustNewDecFromStr("0.005"), + BaseGasPrice: math.LegacyMustNewDecFromStr("0.005"), } err := s.feeMarketKeeper.SetState(s.ctx, state) s.Require().NoError(err) @@ -141,14 +144,16 @@ func (s *KeeperTestSuite) TestBaseFeeRequest() { err = s.feeMarketKeeper.SetParams(s.ctx, params) s.Require().NoError(err) - req := &types.BaseFeeRequest{} - resp, err := s.queryServer.BaseFee(s.ctx, req) + req := &types.GasPriceRequest{ + Denom: "stake", + } + resp, err := s.queryServer.GasPrice(s.ctx, req) s.Require().NoError(err) s.Require().NotNil(resp) - fee, err := s.feeMarketKeeper.GetMinGasPrices(s.ctx) + fee, err := s.feeMarketKeeper.GetMinGasPrice(s.ctx, req.GetDenom()) s.Require().NoError(err) - s.Require().Equal(resp.Fees, fee) + s.Require().Equal(resp.GetPrice(), fee) }) } diff --git a/x/feemarket/post/expected_keeper.go b/x/feemarket/post/expected_keeper.go index 7a2d355..e131393 100644 --- a/x/feemarket/post/expected_keeper.go +++ b/x/feemarket/post/expected_keeper.go @@ -47,5 +47,5 @@ type FeeMarketKeeper interface { SetParams(ctx sdk.Context, params feemarkettypes.Params) error SetState(ctx sdk.Context, state feemarkettypes.State) error GetDenomResolver() feemarkettypes.DenomResolver - GetMinGasPrices(ctx sdk.Context) (sdk.DecCoins, error) + GetMinGasPrice(ctx sdk.Context, denom string) (sdk.DecCoin, error) } diff --git a/x/feemarket/post/fee.go b/x/feemarket/post/fee.go index be8aee0..0cb84e2 100644 --- a/x/feemarket/post/fee.go +++ b/x/feemarket/post/fee.go @@ -56,7 +56,7 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul var ( tip sdk.Coin - feeCoin sdk.Coin + payCoin sdk.Coin ) // update fee market params @@ -76,9 +76,6 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul return ctx, errorsmod.Wrapf(err, "unable to get fee market state") } - baseFee := sdk.NewDecCoinFromDec(params.FeeDenom, state.BaseFee) - minGasPrices := sdk.NewDecCoins(baseFee) - feeCoins := feeTx.GetFee() gas := ctx.GasMeter().GasConsumed() // use context gas consumed @@ -89,13 +86,21 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul return ctx, errorsmod.Wrapf(feemarkettypes.ErrTooManyFeeCoins, "got length %d", len(feeCoins)) } + feeCoin := feeCoins[0] + feeGas := int64(feeTx.GetGas()) + + minGasPrice, err := dfd.feemarketKeeper.GetMinGasPrice(ctx, feeCoin.GetDenom()) + if err != nil { + return ctx, errorsmod.Wrapf(err, "unable to get min gas price for denom %s", feeCoins[0].GetDenom()) + } + ctx.Logger().Info("fee deduct post handle", - "min gas prices", baseFee, + "min gas prices", minGasPrice, "gas consumed", gas, ) if !simulate { - feeCoin, tip, err = ante.CheckTxFee(ctx, minGasPrices[0], feeTx, false, dfd.feemarketKeeper.GetDenomResolver()) + payCoin, tip, err = ante.CheckTxFee(ctx, minGasPrice, feeCoin, feeGas, false) if err != nil { return ctx, err } @@ -106,7 +111,7 @@ func (dfd FeeMarketDeductDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simul "tip", tip, ) - if err := dfd.DeductFeeAndTip(ctx, tx, feeCoin, tip); err != nil { + if err := dfd.DeductFeeAndTip(ctx, tx, payCoin, tip); err != nil { return ctx, err } diff --git a/x/feemarket/post/fee_test.go b/x/feemarket/post/fee_test.go index eb6beed..4e89573 100644 --- a/x/feemarket/post/fee_test.go +++ b/x/feemarket/post/fee_test.go @@ -155,7 +155,7 @@ func TestPostHandle(t *testing.T) { ) gasLimit := antesuite.NewTestGasLimit() - validFeeAmount := types.DefaultMinBaseFee.MulInt64(int64(gasLimit)) + validFeeAmount := types.DefaultMinBaseGasPrice.MulInt64(int64(gasLimit)) validFeeAmountWithTip := validFeeAmount.Add(math.LegacyNewDec(100)) validFee := sdk.NewCoins(sdk.NewCoin(baseDenom, validFeeAmount.TruncateInt())) validFeeWithTip := sdk.NewCoins(sdk.NewCoin(baseDenom, validFeeAmountWithTip.TruncateInt())) diff --git a/x/feemarket/types/eip1559.go b/x/feemarket/types/eip1559.go index 5bd6abe..7247613 100644 --- a/x/feemarket/types/eip1559.go +++ b/x/feemarket/types/eip1559.go @@ -35,10 +35,10 @@ var ( // on Ethereum. This denominated in units of gas consumed in a block. DefaultMaxBlockUtilization uint64 = 30_000_000 - // DefaultMinBaseFee is the default minimum base fee. This is the default + // DefaultMinBaseGasPrice is the default minimum base fee. This is the default // on Ethereum. Note that Ethereum is denominated in 1e18 wei. Cosmos chains will // likely want to change this to 1e6. - DefaultMinBaseFee = math.LegacyMustNewDecFromStr("1") + DefaultMinBaseGasPrice = math.LegacyMustNewDecFromStr("1") // DefaultMinLearningRate is not used in the base EIP-1559 implementation. DefaultMinLearningRate = math.LegacyMustNewDecFromStr("0.125") @@ -62,7 +62,7 @@ func DefaultParams() Params { DefaultDelta, DefaultTargetBlockUtilization, DefaultMaxBlockUtilization, - DefaultMinBaseFee, + DefaultMinBaseGasPrice, DefaultMinLearningRate, DefaultMaxLearningRate, DefaultFeeDenom, @@ -75,7 +75,7 @@ func DefaultParams() Params { func DefaultState() State { return NewState( DefaultWindow, - DefaultMinBaseFee, + DefaultMinBaseGasPrice, DefaultMinLearningRate, ) } diff --git a/x/feemarket/types/genesis.pb.go b/x/feemarket/types/genesis.pb.go index 6e8c292..a16420f 100644 --- a/x/feemarket/types/genesis.pb.go +++ b/x/feemarket/types/genesis.pb.go @@ -86,9 +86,9 @@ func (m *GenesisState) GetState() State { // the current base fee, learning rate, and block utilization within the // specified AIMD window. type State struct { - // BaseFee is the current base fee. This is denominated in the fee per gas + // BaseGasPrice is the current base fee. This is denominated in the fee per gas // unit. - BaseFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=base_fee,json=baseFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"base_fee"` + BaseGasPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=base_gas_price,json=baseGasPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"base_gas_price"` // LearningRate is the current learning rate. LearningRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=learning_rate,json=learningRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"learning_rate"` // Window contains a list of the last blocks' utilization values. This is used @@ -156,30 +156,30 @@ func init() { } var fileDescriptor_2180652c84279298 = []byte{ - // 357 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0xcd, 0x4e, 0xea, 0x40, - 0x14, 0xee, 0x5c, 0x0a, 0xf7, 0xde, 0x11, 0x37, 0x0d, 0x21, 0x15, 0x63, 0x21, 0xe8, 0x82, 0x0d, - 0xd3, 0xa0, 0x2b, 0x13, 0x57, 0x84, 0x68, 0x4c, 0x58, 0x98, 0x9a, 0xb8, 0x70, 0x43, 0x86, 0x72, - 0x28, 0x13, 0x6c, 0xa7, 0xe9, 0x8c, 0xfc, 0x3c, 0x81, 0x5b, 0x1f, 0xc6, 0x87, 0x60, 0x49, 0x5c, - 0x19, 0x4d, 0x88, 0x81, 0x17, 0x31, 0xed, 0x14, 0x61, 0x21, 0x1b, 0x77, 0xdf, 0xc9, 0xf9, 0xfe, - 0x4e, 0x0e, 0x3e, 0xe9, 0x03, 0xf8, 0x34, 0x1a, 0x82, 0xb4, 0x37, 0x68, 0xd4, 0xb0, 0x3d, 0x08, - 0x40, 0x30, 0x41, 0xc2, 0x88, 0x4b, 0x6e, 0x14, 0xbf, 0x77, 0x64, 0x83, 0x46, 0x8d, 0x52, 0xc1, - 0xe3, 0x1e, 0x4f, 0x28, 0x76, 0x8c, 0x14, 0xbb, 0x74, 0xe0, 0x72, 0xe1, 0x73, 0xd1, 0x51, 0x0b, - 0x35, 0xa4, 0xab, 0xe3, 0x1d, 0x71, 0x21, 0x8d, 0xa8, 0x9f, 0x92, 0xaa, 0x4f, 0x08, 0xe7, 0xaf, - 0x54, 0xfe, 0xad, 0xa4, 0x12, 0x8c, 0x0b, 0x9c, 0x53, 0x04, 0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0x10, 0x44, 0x37, 0x97, 0x7c, 0xee, 0xec, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x61, 0xc1, - 0xa4, 0x4f, 0x02, 0x00, 0x00, + // 364 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0x4d, 0x4b, 0x3a, 0x41, + 0x18, 0xdf, 0xf9, 0xbb, 0x0a, 0xff, 0xc9, 0x3a, 0x2c, 0x22, 0x9b, 0xd1, 0x2a, 0xd6, 0xc1, 0x8b, + 0xbb, 0x58, 0xa7, 0xa0, 0x93, 0x08, 0x12, 0x74, 0x90, 0x0d, 0x0a, 0xba, 0xc8, 0xb8, 0x3e, 0xad, + 0x83, 0xed, 0xce, 0xb2, 0x33, 0xf9, 0xf2, 0x09, 0xba, 0xf6, 0x61, 0xfa, 0x10, 0x1e, 0xa5, 0x53, + 0x74, 0x90, 0x50, 0xe8, 0x73, 0xc4, 0xec, 0xac, 0xe9, 0x21, 0x2f, 0xdd, 0x7e, 0x0f, 0xcf, 0xef, + 0x6d, 0xe6, 0xc1, 0xa7, 0x0f, 0x00, 0x01, 0x89, 0x87, 0x20, 0x9c, 0x0d, 0x1a, 0x35, 0x1c, 0x1f, + 0x42, 0xe0, 0x94, 0xdb, 0x51, 0xcc, 0x04, 0x33, 0x8a, 0x3f, 0x3b, 0x7b, 0x83, 0x46, 0x8d, 0x52, + 0xc1, 0x67, 0x3e, 0x4b, 0x28, 0x8e, 0x44, 0x8a, 0x5d, 0x3a, 0xf4, 0x18, 0x0f, 0x18, 0xef, 0xaa, + 0x85, 0x1a, 0xd2, 0xd5, 0xc9, 0x8e, 0xb8, 0x88, 0xc4, 0x24, 0x48, 0x49, 0xd5, 0x67, 0x84, 0xf3, + 0x6d, 0x95, 0x7f, 0x23, 0x88, 0x00, 0xe3, 0x12, 0xe7, 0x14, 0xc1, 0x44, 0x15, 0x54, 0xdb, 0x3b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x2d, 0x2c, 0xa6, 0x11, 0xf0, 0x5e, 0x2e, 0x39, 0xe2, 0xf9, 0x77, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xd7, 0xb3, 0xeb, 0x34, 0x5a, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -279,9 +279,9 @@ func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - size := m.BaseFee.Size() + size := m.BaseGasPrice.Size() i -= size - if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.BaseGasPrice.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintGenesis(dAtA, i, uint64(size)) @@ -321,7 +321,7 @@ func (m *State) Size() (n int) { } var l int _ = l - l = m.BaseFee.Size() + l = m.BaseGasPrice.Size() n += 1 + l + sovGenesis(uint64(l)) l = m.LearningRate.Size() n += 1 + l + sovGenesis(uint64(l)) @@ -491,7 +491,7 @@ func (m *State) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BaseGasPrice", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -519,7 +519,7 @@ func (m *State) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BaseGasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/feemarket/types/params.go b/x/feemarket/types/params.go index 3df8f48..ee3f5fb 100644 --- a/x/feemarket/types/params.go +++ b/x/feemarket/types/params.go @@ -21,7 +21,7 @@ func NewParams( delta math.LegacyDec, targetBlockSize uint64, maxBlockSize uint64, - minBaseFee math.LegacyDec, + minBaseGasPrice math.LegacyDec, minLearingRate math.LegacyDec, maxLearningRate math.LegacyDec, feeDenom string, @@ -32,7 +32,7 @@ func NewParams( Beta: beta, Theta: theta, Delta: delta, - MinBaseFee: minBaseFee, + MinBaseGasPrice: minBaseGasPrice, MinLearningRate: minLearingRate, MaxLearningRate: maxLearningRate, TargetBlockUtilization: targetBlockSize, @@ -77,8 +77,8 @@ func (p *Params) ValidateBasic() error { return fmt.Errorf("max block size cannot be greater than target block size times %d", MaxBlockUtilizationRatio) } - if p.MinBaseFee.IsNil() || !p.MinBaseFee.GTE(math.LegacyZeroDec()) { - return fmt.Errorf("min base fee cannot be nil and must be greater than or equal to zero") + if p.MinBaseGasPrice.IsNil() || !p.MinBaseGasPrice.GTE(math.LegacyZeroDec()) { + return fmt.Errorf("min base gas price cannot be nil and must be greater than or equal to zero") } if p.MaxLearningRate.IsNil() || p.MinLearningRate.IsNegative() { diff --git a/x/feemarket/types/params.pb.go b/x/feemarket/types/params.pb.go index 5cfe346..e199601 100644 --- a/x/feemarket/types/params.pb.go +++ b/x/feemarket/types/params.pb.go @@ -43,9 +43,9 @@ type Params struct { // net block utilization difference in the window is above/below the target // utilization. Delta cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=delta,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"delta"` - // MinBaseFee determines the initial base fee of the module and the global - // minimum for the network. This is denominated in fee per gas unit. - MinBaseFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=min_base_fee,json=minBaseFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_base_fee"` + // MinBaseGasPrice determines the initial gas price of the module and the global + // minimum for the network. + MinBaseGasPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=min_base_gas_price,json=minBaseGasPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_base_gas_price"` // MinLearningRate is the lower bound for the learning rate. MinLearningRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=min_learning_rate,json=minLearningRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_learning_rate"` // MaxLearningRate is the upper bound for the learning rate. @@ -151,36 +151,36 @@ func init() { } var fileDescriptor_3907de4df2e1c66e = []byte{ - // 458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4d, 0x6e, 0xd3, 0x40, - 0x14, 0x80, 0x63, 0x48, 0xdd, 0x64, 0x28, 0x54, 0x18, 0x88, 0x86, 0x56, 0x72, 0x23, 0x58, 0x90, - 0x4d, 0x6d, 0x05, 0x36, 0xac, 0xa3, 0x50, 0x84, 0xd4, 0x05, 0x32, 0x62, 0x83, 0x84, 0xac, 0x67, - 0xfb, 0xc5, 0x19, 0xc5, 0x33, 0x63, 0x79, 0x26, 0x69, 0xca, 0x29, 0xb8, 0x03, 0x57, 0xe0, 0x10, - 0x5d, 0x56, 0xac, 0x10, 0x8b, 0x0a, 0x25, 0x17, 0x41, 0x33, 0x0e, 0xa4, 0xb4, 0x3b, 0xef, 0xde, - 0xdf, 0xf7, 0xf9, 0x59, 0xa3, 0x47, 0x9e, 0x4f, 0x10, 0x39, 0x54, 0x33, 0xd4, 0xe1, 0x36, 0x5a, - 0x0c, 0xc3, 0x12, 0x2a, 0xe0, 0x2a, 0x28, 0x2b, 0xa9, 0xa5, 0xd7, 0xfb, 0xd7, 0x0a, 0xb6, 0xd1, - 0x62, 0x78, 0xf0, 0x34, 0x95, 0x8a, 0x4b, 0x15, 0xdb, 0xa9, 0xb0, 0x4e, 0x6a, 0xe4, 0xe0, 0x71, - 0x2e, 0x73, 0x59, 0xd7, 0x4d, 0x54, 0x57, 0x9f, 0x7d, 0x73, 0x89, 0xfb, 0xde, 0x9a, 0xbd, 0xb7, - 0x64, 0x07, 0x8a, 0x72, 0x0a, 0xd4, 0xe9, 0x3b, 0x83, 0xee, 0x68, 0x78, 0x71, 0x75, 0xd4, 0xfa, - 0x75, 0x75, 0x74, 0x58, 0x5b, 0x54, 0x36, 0x0b, 0x98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- 0x88, 0x63, 0x93, 0x7b, 0x94, 0xec, 0xa2, 0x80, 0xa4, 0xc0, 0x8c, 0xee, 0xf5, 0x9d, 0x41, 0x27, - 0xfa, 0x9b, 0x7a, 0x2f, 0xc8, 0x7e, 0xc6, 0x94, 0xae, 0x58, 0x32, 0xd7, 0xf6, 0x45, 0x15, 0xbd, - 0x6f, 0x27, 0x1e, 0x6c, 0xcb, 0x27, 0x88, 0x6a, 0xf4, 0xee, 0x62, 0xe5, 0x3b, 0x97, 0x2b, 0xdf, - 0xf9, 0xbd, 0xf2, 0x9d, 0xaf, 0x6b, 0xbf, 0x75, 0xb9, 0xf6, 0x5b, 0x3f, 0xd7, 0x7e, 0xeb, 0x53, - 0x98, 0x33, 0x3d, 0x9d, 0x27, 0x41, 0x2a, 0x79, 0xa8, 0x66, 0xac, 0x3c, 0xe6, 0xb8, 0xb8, 0x76, - 0xb7, 0xcb, 0x6b, 0xb1, 0x3e, 0x2f, 0x51, 0x25, 0xae, 0xbd, 0xbb, 0x57, 0x7f, 0x02, 0x00, 0x00, - 0xff, 0xff, 0xce, 0x79, 0xc4, 0x81, 0xe7, 0x03, 0x00, 0x00, + // 462 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x93, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x80, 0x63, 0x48, 0xdd, 0x64, 0xf9, 0xa9, 0x58, 0x20, 0x5a, 0x5a, 0xc9, 0x8d, 0xe0, 0x40, + 0x2e, 0xb5, 0x15, 0xb8, 0x70, 0x8e, 0x02, 0x15, 0x52, 0x0f, 0x95, 0x25, 0x2e, 0x48, 0x60, 0x8d, + 0xed, 0x89, 0xb3, 0x8a, 0xd7, 0x6b, 0x79, 0x37, 0x69, 0xca, 0x53, 0xf0, 0x24, 0x9c, 0x78, 0x88, + 0x1e, 0x2b, 0x4e, 0x88, 0x43, 0x85, 0x92, 0x17, 0x41, 0xb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x2f, 0xaf, 0xc5, 0xfa, 0xbc, 0x44, 0x15, 0xbb, 0xf6, 0x04, 0x5f, + 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x71, 0xd9, 0x7a, 0x84, 0xf2, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -266,9 +266,9 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 { - size := m.MinBaseFee.Size() + size := m.MinBaseGasPrice.Size() i -= size - if _, err := m.MinBaseFee.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.MinBaseGasPrice.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintParams(dAtA, i, uint64(size)) @@ -343,7 +343,7 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) l = m.Delta.Size() n += 1 + l + sovParams(uint64(l)) - l = m.MinBaseFee.Size() + l = m.MinBaseGasPrice.Size() n += 1 + l + sovParams(uint64(l)) l = m.MinLearningRate.Size() n += 1 + l + sovParams(uint64(l)) @@ -544,7 +544,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinBaseFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinBaseGasPrice", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -572,7 +572,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MinBaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinBaseGasPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/feemarket/types/params_test.go b/x/feemarket/types/params_test.go index a33ca1b..111a9ab 100644 --- a/x/feemarket/types/params_test.go +++ b/x/feemarket/types/params_test.go @@ -185,7 +185,7 @@ func TestParams(t *testing.T) { expectedErr: true, }, { - name: "min base fee is nil", + name: "min base gas price is nil", p: types.Params{ Window: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), @@ -199,7 +199,7 @@ func TestParams(t *testing.T) { expectedErr: true, }, { - name: "min base fee is negative", + name: "min base has price is negative", p: types.Params{ Window: 1, Alpha: math.LegacyMustNewDecFromStr("0.1"), @@ -208,7 +208,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("-1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("-1.0"), FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, @@ -223,7 +223,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), FeeDenom: types.DefaultFeeDenom, }, expectedErr: true, @@ -238,7 +238,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), MinLearningRate: math.LegacyMustNewDecFromStr("-0.1"), FeeDenom: types.DefaultFeeDenom, }, @@ -254,7 +254,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), FeeDenom: types.DefaultFeeDenom, }, @@ -270,7 +270,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("-0.1"), FeeDenom: types.DefaultFeeDenom, @@ -287,7 +287,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), MinLearningRate: math.LegacyMustNewDecFromStr("0.1"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.05"), FeeDenom: types.DefaultFeeDenom, @@ -304,7 +304,7 @@ func TestParams(t *testing.T) { Delta: math.LegacyMustNewDecFromStr("0.1"), TargetBlockUtilization: 2, MaxBlockUtilization: 3, - MinBaseFee: math.LegacyMustNewDecFromStr("1.0"), + MinBaseGasPrice: math.LegacyMustNewDecFromStr("1.0"), MinLearningRate: math.LegacyMustNewDecFromStr("0.01"), MaxLearningRate: math.LegacyMustNewDecFromStr("0.05"), }, diff --git a/x/feemarket/types/query.pb.go b/x/feemarket/types/query.pb.go index b23e965..d3e81f6 100644 --- a/x/feemarket/types/query.pb.go +++ b/x/feemarket/types/query.pb.go @@ -196,22 +196,24 @@ func (m *StateResponse) GetState() State { return State{} } -// BaseFeeRequest is the request type for the Query/BaseFee RPC method. -type BaseFeeRequest struct { +// GasPriceRequest is the request type for the Query/GasPrice RPC method. +type GasPriceRequest struct { + // denom we are querying gas price in + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` } -func (m *BaseFeeRequest) Reset() { *m = BaseFeeRequest{} } -func (m *BaseFeeRequest) String() string { return proto.CompactTextString(m) } -func (*BaseFeeRequest) ProtoMessage() {} -func (*BaseFeeRequest) Descriptor() ([]byte, []int) { +func (m *GasPriceRequest) Reset() { *m = GasPriceRequest{} } +func (m *GasPriceRequest) String() string { return proto.CompactTextString(m) } +func (*GasPriceRequest) ProtoMessage() {} +func (*GasPriceRequest) Descriptor() ([]byte, []int) { return fileDescriptor_d683b3b0d8494138, []int{4} } -func (m *BaseFeeRequest) XXX_Unmarshal(b []byte) error { +func (m *GasPriceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BaseFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *GasPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BaseFeeRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_GasPriceRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -221,35 +223,43 @@ func (m *BaseFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *BaseFeeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_BaseFeeRequest.Merge(m, src) +func (m *GasPriceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GasPriceRequest.Merge(m, src) } -func (m *BaseFeeRequest) XXX_Size() int { +func (m *GasPriceRequest) XXX_Size() int { return m.Size() } -func (m *BaseFeeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_BaseFeeRequest.DiscardUnknown(m) +func (m *GasPriceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GasPriceRequest.DiscardUnknown(m) } -var xxx_messageInfo_BaseFeeRequest proto.InternalMessageInfo +var xxx_messageInfo_GasPriceRequest proto.InternalMessageInfo -// StateResponse is the response type for the Query/BaseFee RPC method. -type BaseFeeResponse struct { - Fees github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=fees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"fees"` +func (m *GasPriceRequest) GetDenom() string { + if m != nil { + return m.Denom + } + return "" } -func (m *BaseFeeResponse) Reset() { *m = BaseFeeResponse{} } -func (m *BaseFeeResponse) String() string { return proto.CompactTextString(m) } -func (*BaseFeeResponse) ProtoMessage() {} -func (*BaseFeeResponse) Descriptor() ([]byte, []int) { +// GasPriceResponse is the response type for the Query/GasPrice RPC method. +// Returns a gas price in specified denom. +type GasPriceResponse struct { + Price types.DecCoin `protobuf:"bytes,1,opt,name=price,proto3" json:"price"` +} + +func (m *GasPriceResponse) Reset() { *m = GasPriceResponse{} } +func (m *GasPriceResponse) String() string { return proto.CompactTextString(m) } +func (*GasPriceResponse) ProtoMessage() {} +func (*GasPriceResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d683b3b0d8494138, []int{5} } -func (m *BaseFeeResponse) XXX_Unmarshal(b []byte) error { +func (m *GasPriceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BaseFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *GasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BaseFeeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_GasPriceResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -259,21 +269,104 @@ func (m *BaseFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *BaseFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BaseFeeResponse.Merge(m, src) +func (m *GasPriceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GasPriceResponse.Merge(m, src) } -func (m *BaseFeeResponse) XXX_Size() int { +func (m *GasPriceResponse) XXX_Size() int { return m.Size() } -func (m *BaseFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BaseFeeResponse.DiscardUnknown(m) +func (m *GasPriceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GasPriceResponse.DiscardUnknown(m) } -var xxx_messageInfo_BaseFeeResponse proto.InternalMessageInfo +var xxx_messageInfo_GasPriceResponse proto.InternalMessageInfo -func (m *BaseFeeResponse) GetFees() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *GasPriceResponse) GetPrice() types.DecCoin { if m != nil { - return m.Fees + return m.Price + } + return types.DecCoin{} +} + +// GasPriceRequest is the request type for the Query/GasPrices RPC method. +type GasPricesRequest struct { +} + +func (m *GasPricesRequest) Reset() { *m = GasPricesRequest{} } +func (m *GasPricesRequest) String() string { return proto.CompactTextString(m) } +func (*GasPricesRequest) ProtoMessage() {} +func (*GasPricesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d683b3b0d8494138, []int{6} +} +func (m *GasPricesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GasPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GasPricesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GasPricesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GasPricesRequest.Merge(m, src) +} +func (m *GasPricesRequest) XXX_Size() int { + return m.Size() +} +func (m *GasPricesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GasPricesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GasPricesRequest proto.InternalMessageInfo + +// GasPricesResponse is the response type for the Query/GasPrices RPC method. +// Returns a gas price in all available denoms. +type GasPricesResponse struct { + Prices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=prices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"prices"` +} + +func (m *GasPricesResponse) Reset() { *m = GasPricesResponse{} } +func (m *GasPricesResponse) String() string { return proto.CompactTextString(m) } +func (*GasPricesResponse) ProtoMessage() {} +func (*GasPricesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d683b3b0d8494138, []int{7} +} +func (m *GasPricesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GasPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GasPricesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GasPricesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GasPricesResponse.Merge(m, src) +} +func (m *GasPricesResponse) XXX_Size() int { + return m.Size() +} +func (m *GasPricesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GasPricesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GasPricesResponse proto.InternalMessageInfo + +func (m *GasPricesResponse) GetPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Prices } return nil } @@ -283,8 +376,10 @@ func init() { proto.RegisterType((*ParamsResponse)(nil), "feemarket.feemarket.v1.ParamsResponse") proto.RegisterType((*StateRequest)(nil), "feemarket.feemarket.v1.StateRequest") proto.RegisterType((*StateResponse)(nil), "feemarket.feemarket.v1.StateResponse") - proto.RegisterType((*BaseFeeRequest)(nil), "feemarket.feemarket.v1.BaseFeeRequest") - proto.RegisterType((*BaseFeeResponse)(nil), "feemarket.feemarket.v1.BaseFeeResponse") + proto.RegisterType((*GasPriceRequest)(nil), "feemarket.feemarket.v1.GasPriceRequest") + proto.RegisterType((*GasPriceResponse)(nil), "feemarket.feemarket.v1.GasPriceResponse") + proto.RegisterType((*GasPricesRequest)(nil), "feemarket.feemarket.v1.GasPricesRequest") + proto.RegisterType((*GasPricesResponse)(nil), "feemarket.feemarket.v1.GasPricesResponse") } func init() { @@ -292,38 +387,43 @@ func init() { } var fileDescriptor_d683b3b0d8494138 = []byte{ - // 492 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0xd6, 0x26, 0xc2, 0xd4, 0xa6, 0x3a, 0xd6, 0x50, 0x62, 0x9c, 0xca, 0xda, 0x6a, 0x51, - 0x3a, 0x43, 0xe2, 0x45, 0xc1, 0x53, 0x14, 0x41, 0x0f, 0xa2, 0xf1, 0xe6, 0x45, 0x26, 0xf1, 0x65, - 0x5d, 0xe3, 0xce, 0x6c, 0x32, 0x93, 0x60, 0x05, 0x2f, 0xfe, 0x02, 0xc1, 0x3f, 0x21, 0x9e, 0xfc, - 0x19, 0x3d, 0x16, 0xbc, 0x78, 0x52, 0x49, 0x04, 0x4f, 0xfe, 0x07, 0xd9, 0x99, 0xb7, 0x69, 0x02, - 0x4d, 0x73, 0x49, 0xde, 0xbe, 0xf9, 0xde, 0xf7, 0xcd, 0xfb, 0xbe, 0x5d, 0x12, 0x76, 0x01, 0x12, - 0x39, 0xe8, 0x81, 0x15, 0xc7, 0xd5, 0xa8, 0x2e, 0xfa, 0x43, 0x18, 0x1c, 0xf0, 0x74, 0xa0, 0xad, - 0xa6, 0x95, 0xe9, 0x09, 0x3f, 0xae, 0x46, 0xf5, 0xea, 0x66, 0xa4, 0x23, 0xed, 0x20, 0x22, 0xab, - 0x3c, 0xba, 0x5a, 0x8b, 0xb4, 0x8e, 0xde, 0x82, 0x90, 0x69, 0x2c, 0xa4, 0x52, 0xda, 0x4a, 0x1b, - 0x6b, 0x65, 0xf0, 0x94, 0x75, 0xb4, 0x49, 0xb4, 0x11, 0x6d, 0x69, 0x40, 0x8c, 0xea, 0x6d, 0xb0, - 0xb2, 0x2e, 0x3a, 0x3a, 0x56, 0x78, 0x7e, 0x41, 0x26, 0xb1, 0xd2, 0xc2, 0xfd, 0x62, 0xeb, 0xda, - 0x82, 0x2b, 0xa6, 0x72, 0x20, 0x93, 0x9c, 0x77, 0x67, 0x01, 0x28, 0x02, 0x05, 0x26, 0x46, 0x54, - 0xb8, 0x41, 0xd6, 0x9f, 0xba, 0xa9, 0x16, 0xf4, 0x87, 0x60, 0x6c, 0xf8, 0x84, 0x94, 0xf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e, 0xb5, 0x31, 0x17, 0xdd, 0x5d, 0x82, 0x42, 0xcd, 0xcb, 0x4e, 0xf3, - 0x12, 0xbd, 0x38, 0xaf, 0xe9, 0x42, 0xa0, 0xef, 0xc9, 0x59, 0xb4, 0x9c, 0x2e, 0xdc, 0x61, 0x3e, - 0xa5, 0xea, 0x8d, 0xa5, 0x38, 0x14, 0x66, 0x4e, 0x78, 0x8b, 0x56, 0xe6, 0x85, 0xb3, 0xec, 0x5e, - 0x76, 0x01, 0x9a, 0x8f, 0x0e, 0xc7, 0x2c, 0x38, 0x1a, 0xb3, 0xe0, 0xf7, 0x98, 0x05, 0x9f, 0x26, - 0xac, 0x70, 0x34, 0x61, 0x85, 0x1f, 0x13, 0x56, 0x78, 0x21, 0x66, 0x12, 0x34, 0xbd, 0x38, 0xdd, - 0x4f, 0x60, 0x34, 0x43, 0xf2, 0x6e, 0xa6, 0x76, 0x71, 0xb6, 0x4b, 0xee, 0x7b, 0xb8, 0xfd, 0x3f, - 0x00, 0x00, 0xff, 0xff, 0x27, 0x96, 0xad, 0x7c, 0xff, 0x03, 0x00, 0x00, + // 565 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x6e, 0x18, 0xad, 0xa8, 0x61, 0x1b, 0x33, 0x65, 0x9a, 0x42, 0x49, 0x47, 0xd8, 0xe8, 0x00, + 0x2d, 0x56, 0xc7, 0x05, 0x24, 0xb8, 0x14, 0x24, 0x04, 0x07, 0xb4, 0x95, 0x1b, 0x17, 0xe4, 0x66, + 0x26, 0x44, 0x25, 0x76, 0x1a, 0xbb, 0x15, 0x13, 0xe2, 0x32, 0x24, 0xce, 0x48, 0xfc, 0x09, 0xc4, + 0x89, 0x9f, 0xb1, 0xe3, 0x24, 0x2e, 0x9c, 0x00, 0xb5, 0x48, 0xfc, 0x0c, 0x50, 0xec, 0x97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x7f, 0x35, 0xb5, 0x13, 0xf0, 0x7b, + 0x0b, 0x9d, 0xc9, 0x26, 0x8f, 0x9b, 0x79, 0x84, 0x47, 0xcc, 0x62, 0x6f, 0x14, 0x03, 0x41, 0xbc, + 0xa9, 0xc5, 0xaf, 0xe0, 0xc6, 0x91, 0xdf, 0x12, 0x95, 0xcf, 0xf5, 0xd4, 0xc9, 0x1b, 0x6d, 0xb4, + 0xb7, 0x78, 0xdf, 0x42, 0xd5, 0x89, 0x05, 0x70, 0xa1, 0xc0, 0x64, 0xf2, 0xd7, 0xff, 0x03, 0x09, + 0xbd, 0xac, 0xea, 0x5e, 0x6c, 0xbc, 0x92, 0xd3, 0x8b, 0x6c, 0x3f, 0x3a, 0x18, 0x39, 0xd6, 0xe1, + 0xc8, 0xb1, 0x7e, 0x8e, 0x1c, 0xeb, 0xc3, 0xd8, 0x29, 0x1d, 0x8e, 0x9d, 0xd2, 0xb7, 0xb1, 0x53, + 0x7a, 0x46, 0x66, 0x5c, 0x25, 0x7b, 0x61, 0xbc, 0x19, 0xb1, 0xe1, 0x0c, 0xcd, 0xeb, 0x99, 0x58, + 0x5b, 0xac, 0x5b, 0xd1, 0x7f, 0x13, 0xb7, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x87, 0x38, + 0x2d, 0x16, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -342,8 +442,12 @@ type QueryClient interface { Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) // State returns the current feemarket module state. State(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateResponse, error) - // BaseFee returns the current feemarket module base fee. - BaseFee(ctx context.Context, in *BaseFeeRequest, opts ...grpc.CallOption) (*BaseFeeResponse, error) + // GasPrice returns the current feemarket module gas price + // for specified denom. + GasPrice(ctx context.Context, in *GasPriceRequest, opts ...grpc.CallOption) (*GasPriceResponse, error) + // GasPrices returns the current feemarket module list of gas prices + // in all available denoms. + GasPrices(ctx context.Context, in *GasPricesRequest, opts ...grpc.CallOption) (*GasPricesResponse, error) } type queryClient struct { @@ -372,9 +476,18 @@ func (c *queryClient) State(ctx context.Context, in *StateRequest, opts ...grpc. return out, nil } -func (c *queryClient) BaseFee(ctx context.Context, in *BaseFeeRequest, opts ...grpc.CallOption) (*BaseFeeResponse, error) { - out := new(BaseFeeResponse) - err := c.cc.Invoke(ctx, "/feemarket.feemarket.v1.Query/BaseFee", in, out, opts...) +func (c *queryClient) GasPrice(ctx context.Context, in *GasPriceRequest, opts ...grpc.CallOption) (*GasPriceResponse, error) { + out := new(GasPriceResponse) + err := c.cc.Invoke(ctx, "/feemarket.feemarket.v1.Query/GasPrice", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GasPrices(ctx context.Context, in *GasPricesRequest, opts ...grpc.CallOption) (*GasPricesResponse, error) { + out := new(GasPricesResponse) + err := c.cc.Invoke(ctx, "/feemarket.feemarket.v1.Query/GasPrices", in, out, opts...) if err != nil { return nil, err } @@ -387,8 +500,12 @@ type QueryServer interface { Params(context.Context, *ParamsRequest) (*ParamsResponse, error) // State returns the current feemarket module state. State(context.Context, *StateRequest) (*StateResponse, error) - // BaseFee returns the current feemarket module base fee. - BaseFee(context.Context, *BaseFeeRequest) (*BaseFeeResponse, error) + // GasPrice returns the current feemarket module gas price + // for specified denom. + GasPrice(context.Context, *GasPriceRequest) (*GasPriceResponse, error) + // GasPrices returns the current feemarket module list of gas prices + // in all available denoms. + GasPrices(context.Context, *GasPricesRequest) (*GasPricesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -401,8 +518,11 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *ParamsRequest) func (*UnimplementedQueryServer) State(ctx context.Context, req *StateRequest) (*StateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method State not implemented") } -func (*UnimplementedQueryServer) BaseFee(ctx context.Context, req *BaseFeeRequest) (*BaseFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BaseFee not implemented") +func (*UnimplementedQueryServer) GasPrice(ctx context.Context, req *GasPriceRequest) (*GasPriceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GasPrice not implemented") +} +func (*UnimplementedQueryServer) GasPrices(ctx context.Context, req *GasPricesRequest) (*GasPricesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GasPrices not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -445,20 +565,38 @@ func _Query_State_Handler(srv interface{}, ctx context.Context, dec func(interfa return interceptor(ctx, in, info, handler) } -func _Query_BaseFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(BaseFeeRequest) +func _Query_GasPrice_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GasPriceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GasPrice(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/feemarket.feemarket.v1.Query/GasPrice", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GasPrice(ctx, req.(*GasPriceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GasPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GasPricesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).BaseFee(ctx, in) + return srv.(QueryServer).GasPrices(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/feemarket.feemarket.v1.Query/BaseFee", + FullMethod: "/feemarket.feemarket.v1.Query/GasPrices", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).BaseFee(ctx, req.(*BaseFeeRequest)) + return srv.(QueryServer).GasPrices(ctx, req.(*GasPricesRequest)) } return interceptor(ctx, in, info, handler) } @@ -476,8 +614,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_State_Handler, }, { - MethodName: "BaseFee", - Handler: _Query_BaseFee_Handler, + MethodName: "GasPrice", + Handler: _Query_GasPrice_Handler, + }, + { + MethodName: "GasPrices", + Handler: _Query_GasPrices_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -596,7 +738,7 @@ func (m *StateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BaseFeeRequest) Marshal() (dAtA []byte, err error) { +func (m *GasPriceRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -606,20 +748,27 @@ func (m *BaseFeeRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BaseFeeRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *GasPriceRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BaseFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *GasPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *BaseFeeResponse) Marshal() (dAtA []byte, err error) { +func (m *GasPriceResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -629,20 +778,76 @@ func (m *BaseFeeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BaseFeeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *GasPriceResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BaseFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *GasPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Fees) > 0 { - for iNdEx := len(m.Fees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Price.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GasPricesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GasPricesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GasPricesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GasPricesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GasPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Prices) > 0 { + for iNdEx := len(m.Prices) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Fees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Prices[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -707,7 +912,31 @@ func (m *StateResponse) Size() (n int) { return n } -func (m *BaseFeeRequest) Size() (n int) { +func (m *GasPriceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *GasPriceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Price.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *GasPricesRequest) Size() (n int) { if m == nil { return 0 } @@ -716,14 +945,14 @@ func (m *BaseFeeRequest) Size() (n int) { return n } -func (m *BaseFeeResponse) Size() (n int) { +func (m *GasPricesResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Fees) > 0 { - for _, e := range m.Fees { + if len(m.Prices) > 0 { + for _, e := range m.Prices { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -1003,7 +1232,172 @@ func (m *StateResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *BaseFeeRequest) Unmarshal(dAtA []byte) error { +func (m *GasPriceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GasPriceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GasPriceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GasPriceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GasPriceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GasPriceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GasPricesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1026,10 +1420,10 @@ func (m *BaseFeeRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BaseFeeRequest: wiretype end group for non-group") + return fmt.Errorf("proto: GasPricesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BaseFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GasPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1053,7 +1447,7 @@ func (m *BaseFeeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *BaseFeeResponse) Unmarshal(dAtA []byte) error { +func (m *GasPricesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1076,15 +1470,15 @@ func (m *BaseFeeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BaseFeeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: GasPricesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BaseFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GasPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fees", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Prices", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1111,8 +1505,8 @@ func (m *BaseFeeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Fees = append(m.Fees, types.DecCoin{}) - if err := m.Fees[len(m.Fees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Prices = append(m.Prices, types.DecCoin{}) + if err := m.Prices[len(m.Prices)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/feemarket/types/query.pb.gw.go b/x/feemarket/types/query.pb.gw.go index 4461e56..bab0872 100644 --- a/x/feemarket/types/query.pb.gw.go +++ b/x/feemarket/types/query.pb.gw.go @@ -69,20 +69,74 @@ func local_request_Query_State_0(ctx context.Context, marshaler runtime.Marshale } -func request_Query_BaseFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq BaseFeeRequest +func request_Query_GasPrice_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GasPriceRequest var metadata runtime.ServerMetadata - msg, err := client.BaseFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := client.GasPrice(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_BaseFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq BaseFeeRequest +func local_request_Query_GasPrice_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GasPriceRequest var metadata runtime.ServerMetadata - msg, err := server.BaseFee(ctx, &protoReq) + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["denom"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "denom") + } + + protoReq.Denom, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "denom", err) + } + + msg, err := server.GasPrice(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GasPrices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GasPricesRequest + var metadata runtime.ServerMetadata + + msg, err := client.GasPrices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GasPrices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GasPricesRequest + var metadata runtime.ServerMetadata + + msg, err := server.GasPrices(ctx, &protoReq) return msg, metadata, err } @@ -139,7 +193,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_BaseFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GasPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -150,7 +204,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_BaseFee_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_GasPrice_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -158,7 +212,30 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_BaseFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GasPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GasPrices_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -243,7 +320,27 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_BaseFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GasPrice_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GasPrice_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GasPrice_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -252,14 +349,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_BaseFee_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_GasPrices_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_BaseFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -271,7 +368,9 @@ var ( pattern_Query_State_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"feemarket", "v1", "state"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_BaseFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"feemarket", "v1", "base_fee"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_GasPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"feemarket", "v1", "gas_price", "denom"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GasPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"feemarket", "v1", "gas_prices"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -279,5 +378,7 @@ var ( forward_Query_State_0 = runtime.ForwardResponseMessage - forward_Query_BaseFee_0 = runtime.ForwardResponseMessage + forward_Query_GasPrice_0 = runtime.ForwardResponseMessage + + forward_Query_GasPrices_0 = runtime.ForwardResponseMessage ) diff --git a/x/feemarket/types/resolver.go b/x/feemarket/types/resolver.go index d9e22ef..4ed9e3c 100644 --- a/x/feemarket/types/resolver.go +++ b/x/feemarket/types/resolver.go @@ -8,8 +8,10 @@ import ( // DenomResolver is an interface to convert a given token to the feemarket's base token. type DenomResolver interface { - // ConvertToDenom converts coin into the equivalent amount of the token denominated in denom. - ConvertToDenom(ctx sdk.Context, coin sdk.Coin, denom string) (sdk.Coin, error) + // ConvertToDenom converts deccoin into the equivalent amount of the token denominated in denom. + ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) + // ExtraDenoms returns a list of denoms in addition of `Params.base_denom` it's possible to pay fees with + ExtraDenoms(ctx sdk.Context) ([]string, error) } // TestDenomResolver is a test implementation of the DenomResolver interface. It returns "feeCoin.Amount baseDenom" for all coins that are not the baseDenom. @@ -17,12 +19,16 @@ type DenomResolver interface { type TestDenomResolver struct{} // ConvertToDenom returns "coin.Amount denom" for all coins that are not the denom. -func (r *TestDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.Coin, denom string) (sdk.Coin, error) { +func (r *TestDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) { if coin.Denom == denom { return coin, nil } - return sdk.NewCoin(denom, coin.Amount), nil + return sdk.NewDecCoinFromDec(denom, coin.Amount), nil +} + +func (r *TestDenomResolver) ExtraDenoms(_ sdk.Context) ([]string, error) { + return []string{}, nil } // ErrorDenomResolver is a test implementation of the DenomResolver interface. It returns an error for all coins that are not the baseDenom. @@ -30,10 +36,14 @@ func (r *TestDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.Coin, denom s type ErrorDenomResolver struct{} // ConvertToDenom returns an error for all coins that are not the denom. -func (r *ErrorDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.Coin, denom string) (sdk.Coin, error) { +func (r *ErrorDenomResolver) ConvertToDenom(_ sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) { if coin.Denom == denom { return coin, nil } - return sdk.Coin{}, fmt.Errorf("error resolving denom") + return sdk.DecCoin{}, fmt.Errorf("error resolving denom") +} + +func (r *ErrorDenomResolver) ExtraDenoms(_ sdk.Context) ([]string, error) { + return []string{}, nil } diff --git a/x/feemarket/types/state.go b/x/feemarket/types/state.go index b887c4e..99cca18 100644 --- a/x/feemarket/types/state.go +++ b/x/feemarket/types/state.go @@ -9,15 +9,15 @@ import ( // NewState instantiates a new fee market state instance. This is utilized // to implement both the base EIP-1559 fee market implementation and the // AIMD EIP-1559 fee market implementation. Note that on init, you initialize -// both the minimum and current base fee to the same value. +// both the minimum and current base gas price to the same value. func NewState( windowSize uint64, - baseFee math.LegacyDec, + baseGasPrice math.LegacyDec, learningRate math.LegacyDec, ) State { return State{ Window: make([]uint64, windowSize), - BaseFee: baseFee, + BaseGasPrice: baseGasPrice, Index: 0, LearningRate: learningRate, } @@ -41,21 +41,21 @@ func (s *State) IncrementHeight() { s.Window[s.Index] = 0 } -// UpdateBaseFee updates the learning rate and base fee based on the AIMD +// UpdateBaseGasPrice updates the learning rate and base gas price based on the AIMD // learning rate adjustment algorithm. The learning rate is updated -// based on the average utilization of the block window. The base fee is +// based on the average utilization of the block window. The base gas price is // update using the new learning rate and the delta adjustment. Please // see the EIP-1559 specification for more details. -func (s *State) UpdateBaseFee(params Params) (fee math.LegacyDec) { +func (s *State) UpdateBaseGasPrice(params Params) (gasPrice math.LegacyDec) { // Panic catch in case there is an overflow defer func() { if rec := recover(); rec != nil { - s.BaseFee = params.MinBaseFee - fee = s.BaseFee + s.BaseGasPrice = params.MinBaseGasPrice + gasPrice = s.BaseGasPrice } }() - // Calculate the new base fee with the learning rate adjustment. + // Calculate the new base gasPrice with the learning rate adjustment. currentBlockSize := math.LegacyNewDecFromInt(math.NewIntFromUint64(s.Window[s.Index])) targetBlockSize := math.LegacyNewDecFromInt(math.NewIntFromUint64(params.TargetBlockUtilization)) utilization := (currentBlockSize.Sub(targetBlockSize)).Quo(targetBlockSize) @@ -69,16 +69,16 @@ func (s *State) UpdateBaseFee(params Params) (fee math.LegacyDec) { // Calculate the delta adjustment. net := math.LegacyNewDecFromInt(s.GetNetUtilization(params)).Mul(params.Delta) - // Update the base fee. - fee = s.BaseFee.Mul(learningRateAdjustment).Add(net) + // Update the base gasPrice. + gasPrice = s.BaseGasPrice.Mul(learningRateAdjustment).Add(net) - // Ensure the base fee is greater than the minimum base fee. - if fee.LT(params.MinBaseFee) { - fee = params.MinBaseFee + // Ensure the base gasPrice is greater than the minimum base gasPrice. + if gasPrice.LT(params.MinBaseGasPrice) { + gasPrice = params.MinBaseGasPrice } - s.BaseFee = fee - return s.BaseFee + s.BaseGasPrice = gasPrice + return s.BaseGasPrice } // UpdateLearningRate updates the learning rate based on the AIMD @@ -160,8 +160,8 @@ func (s *State) ValidateBasic() error { return fmt.Errorf("block utilization window cannot be nil or empty") } - if s.BaseFee.IsNil() || s.BaseFee.LTE(math.LegacyZeroDec()) { - return fmt.Errorf("base fee must be positive") + if s.BaseGasPrice.IsNil() || s.BaseGasPrice.LTE(math.LegacyZeroDec()) { + return fmt.Errorf("base gas price must be positive") } if s.LearningRate.IsNil() || s.LearningRate.LTE(math.LegacyZeroDec()) { diff --git a/x/feemarket/types/state_fuzz_test.go b/x/feemarket/types/state_fuzz_test.go index 17bb64c..c9cb6af 100644 --- a/x/feemarket/types/state_fuzz_test.go +++ b/x/feemarket/types/state_fuzz_test.go @@ -31,8 +31,8 @@ func FuzzDefaultFeeMarket(f *testing.F) { state := types.DefaultState() params := types.DefaultParams() - params.MinBaseFee = math.LegacyMustNewDecFromStr("100") - state.BaseFee = math.LegacyMustNewDecFromStr("200") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("100") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("200") err := state.Update(blockGasUsed, params) if blockGasUsed > params.MaxBlockUtilization { @@ -49,8 +49,8 @@ func FuzzDefaultFeeMarket(f *testing.F) { ) require.Equal(t, defaultLR, lr) - oldFee := state.BaseFee - newFee := state.UpdateBaseFee(params) + oldFee := state.BaseGasPrice + newFee := state.UpdateBaseGasPrice(params) if blockGasUsed > params.TargetBlockUtilization { require.True(t, newFee.GT(oldFee)) @@ -79,8 +79,8 @@ func FuzzAIMDFeeMarket(f *testing.F) { f.Fuzz(func(t *testing.T, blockGasUsed uint64) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() - params.MinBaseFee = math.LegacyMustNewDecFromStr("100") - state.BaseFee = math.LegacyMustNewDecFromStr("200") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("100") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("200") state.Window = make([]uint64, 1) err := state.Update(blockGasUsed, params) @@ -92,8 +92,8 @@ func FuzzAIMDFeeMarket(f *testing.F) { require.NoError(t, err) require.Equal(t, blockGasUsed, state.Window[state.Index]) - oldFee := state.BaseFee - newFee := state.UpdateBaseFee(params) + oldFee := state.BaseGasPrice + newFee := state.UpdateBaseGasPrice(params) if blockGasUsed > params.TargetBlockUtilization { require.True(t, newFee.GT(oldFee)) diff --git a/x/feemarket/types/state_test.go b/x/feemarket/types/state_test.go index 14966a3..bbf1d65 100644 --- a/x/feemarket/types/state_test.go +++ b/x/feemarket/types/state_test.go @@ -121,68 +121,68 @@ func TestState_Update(t *testing.T) { }) } -func TestState_UpdateBaseFee(t *testing.T) { +func TestState_UpdateBaseGasPrice(t *testing.T) { t.Run("empty block with default eip-1559", func(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") - newBaseFee := state.UpdateBaseFee(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("875") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + newBaseGasPrice := state.UpdateBaseGasPrice(params) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("875") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("target block with default eip-1559", func(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") state.Window[0] = params.TargetBlockUtilization - newBaseFee := state.UpdateBaseFee(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("1000") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + newBaseGasPrice := state.UpdateBaseGasPrice(params) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("1000") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("full block with default eip-1559", func(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") state.Window[0] = params.MaxBlockUtilization - newBaseFee := state.UpdateBaseFee(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("1125") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + newBaseGasPrice := state.UpdateBaseGasPrice(params) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("1125") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("empty block with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") state.LearningRate = math.LegacyMustNewDecFromStr("0.125") state.UpdateLearningRate(params) - newBaseFee := state.UpdateBaseFee(params) + newBaseGasPrice := state.UpdateBaseGasPrice(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("850") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("850") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("target block with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") state.LearningRate = math.LegacyMustNewDecFromStr("0.125") for i := 0; i < len(state.Window); i++ { @@ -190,18 +190,18 @@ func TestState_UpdateBaseFee(t *testing.T) { } state.UpdateLearningRate(params) - newBaseFee := state.UpdateBaseFee(params) + newBaseGasPrice := state.UpdateBaseGasPrice(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("1000") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("1000") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("full blocks with default aimd eip-1559", func(t *testing.T) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() - state.BaseFee = math.LegacyMustNewDecFromStr("1000") - params.MinBaseFee = math.LegacyMustNewDecFromStr("125") + state.BaseGasPrice = math.LegacyMustNewDecFromStr("1000") + params.MinBaseGasPrice = math.LegacyMustNewDecFromStr("125") state.LearningRate = math.LegacyMustNewDecFromStr("0.125") for i := 0; i < len(state.Window); i++ { @@ -209,30 +209,30 @@ func TestState_UpdateBaseFee(t *testing.T) { } state.UpdateLearningRate(params) - newBaseFee := state.UpdateBaseFee(params) + newBaseGasPrice := state.UpdateBaseGasPrice(params) - expectedBaseFee := math.LegacyMustNewDecFromStr("1150") - require.True(t, expectedBaseFee.Equal(newBaseFee)) + expectedBaseGasPrice := math.LegacyMustNewDecFromStr("1150") + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) - t.Run("never goes below min base fee with default eip1599", func(t *testing.T) { + t.Run("never goes below min base gas price with default eip1599", func(t *testing.T) { state := types.DefaultState() params := types.DefaultParams() // Empty block - newBaseFee := state.UpdateBaseFee(params) - expectedBaseFee := params.MinBaseFee - require.True(t, expectedBaseFee.Equal(newBaseFee)) + newBaseGasPrice := state.UpdateBaseGasPrice(params) + expectedBaseGasPrice := params.MinBaseGasPrice + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) - t.Run("never goes below min base fee with default aimd eip1599", func(t *testing.T) { + t.Run("never goes below min base gas price with default aimd eip1599", func(t *testing.T) { state := types.DefaultAIMDState() params := types.DefaultAIMDParams() // Empty blocks - newBaseFee := state.UpdateBaseFee(params) - expectedBaseFee := params.MinBaseFee - require.True(t, expectedBaseFee.Equal(newBaseFee)) + newBaseGasPrice := state.UpdateBaseGasPrice(params) + expectedBaseGasPrice := params.MinBaseGasPrice + require.True(t, expectedBaseGasPrice.Equal(newBaseGasPrice)) }) t.Run("empty blocks with aimd eip1559 with a delta", func(t *testing.T) { @@ -245,20 +245,20 @@ func TestState_UpdateBaseFee(t *testing.T) { // Empty blocks state := types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) lr := state.UpdateLearningRate(params) - bf := state.UpdateBaseFee(params) + bgs := state.UpdateBaseGasPrice(params) state = types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) lrWithDelta := state.UpdateLearningRate(paramsWithDelta) - bfWithDelta := state.UpdateBaseFee(paramsWithDelta) + bgsWithDelta := state.UpdateBaseGasPrice(paramsWithDelta) // Ensure that the learning rate is the same. require.Equal(t, lr, lrWithDelta) - // Ensure that the base fee is less with the delta. - require.True(t, bfWithDelta.LT(bf)) + // Ensure that the base gas price is less with the delta. + require.True(t, bgsWithDelta.LT(bgs)) }) t.Run("full blocks with aimd eip1559 with a delta", func(t *testing.T) { @@ -271,28 +271,28 @@ func TestState_UpdateBaseFee(t *testing.T) { // Empty blocks state := types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) for i := 0; i < len(state.Window); i++ { state.Window[i] = params.MaxBlockUtilization } lr := state.UpdateLearningRate(params) - bf := state.UpdateBaseFee(params) + bgs := state.UpdateBaseGasPrice(params) state = types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) for i := 0; i < len(state.Window); i++ { state.Window[i] = params.MaxBlockUtilization } lrWithDelta := state.UpdateLearningRate(paramsWithDelta) - bfWithDelta := state.UpdateBaseFee(paramsWithDelta) + bgsWithDelta := state.UpdateBaseGasPrice(paramsWithDelta) // Ensure that the learning rate is the same. require.Equal(t, lr, lrWithDelta) - // Ensure that the base fee is greater with the delta. - require.True(t, bfWithDelta.GT(bf)) + // Ensure that the base gas price is greater with the delta. + require.True(t, bgsWithDelta.GT(bgs)) }) t.Run("target blocks with aimd eip1559 with a delta", func(t *testing.T) { @@ -305,35 +305,35 @@ func TestState_UpdateBaseFee(t *testing.T) { // Empty blocks state := types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) for i := 0; i < len(state.Window); i++ { state.Window[i] = params.TargetBlockUtilization } lr := state.UpdateLearningRate(params) - bf := state.UpdateBaseFee(params) + bgs := state.UpdateBaseGasPrice(params) state = types.DefaultAIMDState() - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) for i := 0; i < len(state.Window); i++ { state.Window[i] = params.TargetBlockUtilization } lrWithDelta := state.UpdateLearningRate(paramsWithDelta) - bfWithDelta := state.UpdateBaseFee(paramsWithDelta) + bgsWithDelta := state.UpdateBaseGasPrice(paramsWithDelta) // Ensure that the learning rate is the same. require.Equal(t, lr, lrWithDelta) - // Ensure that the base fee's are equal. - require.Equal(t, bf, bfWithDelta) + // Ensure that the base gas prices are equal. + require.Equal(t, bgs, bgsWithDelta) }) t.Run("half target block size with aimd eip1559 with a delta", func(t *testing.T) { state := types.DefaultAIMDState() state.Window = make([]uint64, 1) - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) - prevBF := state.BaseFee + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) + prevBF := state.BaseGasPrice // Instantiate the params with a delta. params := types.DefaultAIMDParams() @@ -345,7 +345,7 @@ func TestState_UpdateBaseFee(t *testing.T) { prevLR := state.LearningRate lr := state.UpdateLearningRate(params) - bf := state.UpdateBaseFee(params) + bgs := state.UpdateBaseGasPrice(params) expectedUtilization := math.LegacyMustNewDecFromStr("-0.5") expectedLR := prevLR.Add(params.Alpha) @@ -353,17 +353,17 @@ func TestState_UpdateBaseFee(t *testing.T) { expectedNetUtilization := math.LegacyNewDec(-1 * int64(params.TargetBlockUtilization) / 2) deltaDiff := expectedNetUtilization.Mul(params.Delta) - expectedFee := prevBF.Mul(expectedLRAdjustment).Add(deltaDiff) + expectedGasPrice := prevBF.Mul(expectedLRAdjustment).Add(deltaDiff) require.Equal(t, expectedLR, lr) - require.Equal(t, expectedFee, bf) + require.Equal(t, expectedGasPrice, bgs) }) t.Run("3/4 max block size with aimd eip1559 with a delta", func(t *testing.T) { state := types.DefaultAIMDState() state.Window = make([]uint64, 1) - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) - prevBF := state.BaseFee + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) + prevBGS := state.BaseGasPrice // Instantiate the params with a delta. params := types.DefaultAIMDParams() @@ -375,7 +375,7 @@ func TestState_UpdateBaseFee(t *testing.T) { prevLR := state.LearningRate lr := state.UpdateLearningRate(params) - bf := state.UpdateBaseFee(params) + bgs := state.UpdateBaseGasPrice(params) expectedUtilization := math.LegacyMustNewDecFromStr("0.5") expectedLR := prevLR.Add(params.Alpha) @@ -383,32 +383,32 @@ func TestState_UpdateBaseFee(t *testing.T) { expectedNetUtilization := math.LegacyNewDec(int64(params.MaxBlockUtilization) / 4) deltaDiff := expectedNetUtilization.Mul(params.Delta) - expectedFee := prevBF.Mul(expectedLRAdjustment).Add(deltaDiff) + expectedGasPrice := prevBGS.Mul(expectedLRAdjustment).Add(deltaDiff) require.Equal(t, expectedLR, lr) - require.Equal(t, expectedFee, bf) + require.Equal(t, expectedGasPrice, bgs) }) t.Run("recovers from overflow with large max block utilization ratio", func(t *testing.T) { state := types.DefaultAIMDState() state.Window = make([]uint64, 50) - state.BaseFee = state.BaseFee.Mul(math.LegacyMustNewDecFromStr("10")) + state.BaseGasPrice = state.BaseGasPrice.Mul(math.LegacyMustNewDecFromStr("10")) params := types.DefaultAIMDParams() params.Window = 50 - // This should overflow the base fee after a few iterations. + // This should overflow the base gas price after a few iterations. params.TargetBlockUtilization = 1 params.MaxBlockUtilization = 9_999_999_999_999_999_999 for { - var baseFee math.LegacyDec + var baseGasPrice math.LegacyDec require.NotPanics(t, func() { state.Update(params.MaxBlockUtilization, params) state.UpdateLearningRate(params) - baseFee = state.UpdateBaseFee(params) + baseGasPrice = state.UpdateBaseGasPrice(params) }) // An overflow should have occurred. - if baseFee.Equal(params.MinBaseFee) { + if baseGasPrice.Equal(params.MinBaseGasPrice) { return } @@ -858,10 +858,10 @@ func TestState_ValidateBasic(t *testing.T) { expectErr: true, }, { - name: "invalid negative base fee", + name: "invalid negative base gas price", state: types.State{ - Window: make([]uint64, 1), - BaseFee: math.LegacyMustNewDecFromStr("-1"), + Window: make([]uint64, 1), + BaseGasPrice: math.LegacyMustNewDecFromStr("-1"), }, expectErr: true, }, @@ -869,7 +869,7 @@ func TestState_ValidateBasic(t *testing.T) { name: "invalid learning rate", state: types.State{ Window: make([]uint64, 1), - BaseFee: math.LegacyMustNewDecFromStr("1"), + BaseGasPrice: math.LegacyMustNewDecFromStr("1"), LearningRate: math.LegacyMustNewDecFromStr("-1.0"), }, expectErr: true, @@ -878,16 +878,16 @@ func TestState_ValidateBasic(t *testing.T) { name: "valid other state", state: types.State{ Window: make([]uint64, 1), - BaseFee: math.LegacyMustNewDecFromStr("1"), + BaseGasPrice: math.LegacyMustNewDecFromStr("1"), LearningRate: math.LegacyMustNewDecFromStr("0.5"), }, expectErr: false, }, { - name: "invalid zero base fee", + name: "invalid zero base gas price", state: types.State{ Window: make([]uint64, 1), - BaseFee: math.LegacyZeroDec(), + BaseGasPrice: math.LegacyZeroDec(), LearningRate: math.LegacyMustNewDecFromStr("0.5"), }, expectErr: true, @@ -896,7 +896,7 @@ func TestState_ValidateBasic(t *testing.T) { name: "invalid zero learning rate", state: types.State{ Window: make([]uint64, 1), - BaseFee: math.LegacyMustNewDecFromStr("1"), + BaseGasPrice: math.LegacyMustNewDecFromStr("1"), LearningRate: math.LegacyZeroDec(), }, expectErr: true,