feemarket: change basefee to be a module param (#943)
* change basefee to a module params * add changelog and fix linter * change params type of basefee and remove default base fee * restaure event * clean code * fix proto * fix protos * fix logic * update rpc tests * fix comment Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
f21592ebfe
commit
bf54193669
@ -74,6 +74,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
* (evm) [tharsis#901](https://github.com/tharsis/ethermint/pull/901) Support multiple MsgEthereumTx in single tx.
|
* (evm) [tharsis#901](https://github.com/tharsis/ethermint/pull/901) Support multiple MsgEthereumTx in single tx.
|
||||||
* (config) [tharsis#908](https://github.com/tharsis/ethermint/pull/908) Add api.enable flag for Cosmos SDK Rest server
|
* (config) [tharsis#908](https://github.com/tharsis/ethermint/pull/908) Add api.enable flag for Cosmos SDK Rest server
|
||||||
* (feemarket) [tharsis#919](https://github.com/tharsis/ethermint/pull/919) Initialize baseFee in default genesis state.
|
* (feemarket) [tharsis#919](https://github.com/tharsis/ethermint/pull/919) Initialize baseFee in default genesis state.
|
||||||
|
* (feemarket) [tharsis#943](https://github.com/tharsis/ethermint/pull/943) Store the base fee as a module param instead of using state storage.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ func (suite *AnteTestSuite) SetupTest() {
|
|||||||
feemarketGenesis := feemarkettypes.DefaultGenesisState()
|
feemarketGenesis := feemarkettypes.DefaultGenesisState()
|
||||||
feemarketGenesis.Params.EnableHeight = 1
|
feemarketGenesis.Params.EnableHeight = 1
|
||||||
feemarketGenesis.Params.NoBaseFee = false
|
feemarketGenesis.Params.NoBaseFee = false
|
||||||
feemarketGenesis.BaseFee = sdk.NewInt(feemarketGenesis.Params.InitialBaseFee)
|
|
||||||
// Verify feeMarket genesis
|
// Verify feeMarket genesis
|
||||||
err := feemarketGenesis.Validate()
|
err := feemarketGenesis.Validate()
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
2
client/docs/statik/statik.go
vendored
2
client/docs/statik/statik.go
vendored
File diff suppressed because one or more lines are too long
@ -923,8 +923,8 @@ Params defines the EVM module parameters
|
|||||||
| `no_base_fee` | [bool](#bool) | | no base fee forces the EIP-1559 base fee to 0 (needed for 0 price calls) |
|
| `no_base_fee` | [bool](#bool) | | no base fee forces the EIP-1559 base fee to 0 (needed for 0 price calls) |
|
||||||
| `base_fee_change_denominator` | [uint32](#uint32) | | base fee change denominator bounds the amount the base fee can change between blocks. |
|
| `base_fee_change_denominator` | [uint32](#uint32) | | base fee change denominator bounds the amount the base fee can change between blocks. |
|
||||||
| `elasticity_multiplier` | [uint32](#uint32) | | elasticity multiplier bounds the maximum gas limit an EIP-1559 block may have. |
|
| `elasticity_multiplier` | [uint32](#uint32) | | elasticity multiplier bounds the maximum gas limit an EIP-1559 block may have. |
|
||||||
| `initial_base_fee` | [int64](#int64) | | initial base fee for EIP-1559 blocks. |
|
|
||||||
| `enable_height` | [int64](#int64) | | height at which the base fee calculation is enabled. |
|
| `enable_height` | [int64](#int64) | | height at which the base fee calculation is enabled. |
|
||||||
|
| `base_fee` | [string](#string) | | base fee for EIP-1559 blocks. |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -956,7 +956,6 @@ GenesisState defines the feemarket module's genesis state.
|
|||||||
| Field | Type | Label | Description |
|
| Field | Type | Label | Description |
|
||||||
| ----- | ---- | ----- | ----------- |
|
| ----- | ---- | ----- | ----------- |
|
||||||
| `params` | [Params](#ethermint.feemarket.v1.Params) | | params defines all the paramaters of the module. |
|
| `params` | [Params](#ethermint.feemarket.v1.Params) | | params defines all the paramaters of the module. |
|
||||||
| `base_fee` | [string](#string) | | base fee is the exported value from previous software version. Zero by default. |
|
|
||||||
| `block_gas` | [uint64](#uint64) | | block gas is the amount of gas used on the last block before the upgrade. Zero by default. |
|
| `block_gas` | [uint64](#uint64) | | block gas is the amount of gas used on the last block before the upgrade. Zero by default. |
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package ethermint.feemarket.v1;
|
package ethermint.feemarket.v1;
|
||||||
|
|
||||||
|
import "gogoproto/gogo.proto";
|
||||||
|
|
||||||
option go_package = "github.com/tharsis/ethermint/x/feemarket/types";
|
option go_package = "github.com/tharsis/ethermint/x/feemarket/types";
|
||||||
|
|
||||||
// Params defines the EVM module parameters
|
// Params defines the EVM module parameters
|
||||||
@ -13,8 +15,14 @@ message Params {
|
|||||||
// elasticity multiplier bounds the maximum gas limit an EIP-1559 block may
|
// elasticity multiplier bounds the maximum gas limit an EIP-1559 block may
|
||||||
// have.
|
// have.
|
||||||
uint32 elasticity_multiplier = 3;
|
uint32 elasticity_multiplier = 3;
|
||||||
// initial base fee for EIP-1559 blocks.
|
// DEPRECATED: initial base fee for EIP-1559 blocks.
|
||||||
int64 initial_base_fee = 4;
|
reserved 4;
|
||||||
|
reserved "initial_base_fee";
|
||||||
// height at which the base fee calculation is enabled.
|
// height at which the base fee calculation is enabled.
|
||||||
int64 enable_height = 5;
|
int64 enable_height = 5;
|
||||||
|
// base fee for EIP-1559 blocks.
|
||||||
|
string base_fee = 6 [
|
||||||
|
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
||||||
|
(gogoproto.nullable) = false
|
||||||
|
];
|
||||||
}
|
}
|
@ -10,12 +10,10 @@ option go_package = "github.com/tharsis/ethermint/x/feemarket/types";
|
|||||||
message GenesisState {
|
message GenesisState {
|
||||||
// params defines all the paramaters of the module.
|
// params defines all the paramaters of the module.
|
||||||
Params params = 1 [ (gogoproto.nullable) = false ];
|
Params params = 1 [ (gogoproto.nullable) = false ];
|
||||||
// base fee is the exported value from previous software version.
|
// DEPRECATED: base fee is the exported value from previous software version.
|
||||||
// Zero by default.
|
// Zero by default.
|
||||||
string base_fee = 2 [
|
reserved 2;
|
||||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
|
reserved "base_fee";
|
||||||
(gogoproto.nullable) = false
|
|
||||||
];
|
|
||||||
// block gas is the amount of gas used on the last block before the upgrade.
|
// block gas is the amount of gas used on the last block before the upgrade.
|
||||||
// Zero by default.
|
// Zero by default.
|
||||||
uint64 block_gas = 3;
|
uint64 block_gas = 3;
|
||||||
|
@ -565,7 +565,7 @@ func TestEth_EthResend(t *testing.T) {
|
|||||||
func TestEth_FeeHistory(t *testing.T) {
|
func TestEth_FeeHistory(t *testing.T) {
|
||||||
params := make([]interface{}, 0)
|
params := make([]interface{}, 0)
|
||||||
params = append(params, 4)
|
params = append(params, 4)
|
||||||
params = append(params, "0x1c")
|
params = append(params, "0xa")
|
||||||
params = append(params, []int{25, 75})
|
params = append(params, []int{25, 75})
|
||||||
|
|
||||||
rpcRes := call(t, "eth_feeHistory", params)
|
rpcRes := call(t, "eth_feeHistory", params)
|
||||||
@ -577,7 +577,7 @@ func TestEth_FeeHistory(t *testing.T) {
|
|||||||
baseFeePerGas := info["baseFeePerGas"].([]interface{})
|
baseFeePerGas := info["baseFeePerGas"].([]interface{})
|
||||||
gasUsedRatio := info["gasUsedRatio"].([]interface{})
|
gasUsedRatio := info["gasUsedRatio"].([]interface{})
|
||||||
|
|
||||||
require.Equal(t, info["oldestBlock"].(string), "0x18")
|
require.Equal(t, info["oldestBlock"].(string), "0x6")
|
||||||
require.Equal(t, 4, len(gasUsedRatio))
|
require.Equal(t, 4, len(gasUsedRatio))
|
||||||
require.Equal(t, 4, len(baseFeePerGas))
|
require.Equal(t, 4, len(baseFeePerGas))
|
||||||
require.Equal(t, 4, len(reward))
|
require.Equal(t, 4, len(reward))
|
||||||
|
@ -91,10 +91,8 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
|
|||||||
if suite.enableFeemarket {
|
if suite.enableFeemarket {
|
||||||
feemarketGenesis.Params.EnableHeight = 1
|
feemarketGenesis.Params.EnableHeight = 1
|
||||||
feemarketGenesis.Params.NoBaseFee = false
|
feemarketGenesis.Params.NoBaseFee = false
|
||||||
feemarketGenesis.BaseFee = sdk.NewInt(feemarketGenesis.Params.InitialBaseFee)
|
|
||||||
} else {
|
} else {
|
||||||
feemarketGenesis.Params.NoBaseFee = true
|
feemarketGenesis.Params.NoBaseFee = true
|
||||||
feemarketGenesis.BaseFee = sdk.NewInt(0)
|
|
||||||
}
|
}
|
||||||
genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
|
genesis[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
|
||||||
if !suite.enableLondonHF {
|
if !suite.enableLondonHF {
|
||||||
|
@ -15,7 +15,6 @@ func InitGenesis(
|
|||||||
data types.GenesisState,
|
data types.GenesisState,
|
||||||
) []abci.ValidatorUpdate {
|
) []abci.ValidatorUpdate {
|
||||||
k.SetParams(ctx, data.Params)
|
k.SetParams(ctx, data.Params)
|
||||||
k.SetBaseFee(ctx, data.BaseFee.BigInt())
|
|
||||||
k.SetBlockGasUsed(ctx, data.BlockGas)
|
k.SetBlockGasUsed(ctx, data.BlockGas)
|
||||||
|
|
||||||
return []abci.ValidatorUpdate{}
|
return []abci.ValidatorUpdate{}
|
||||||
@ -23,15 +22,8 @@ func InitGenesis(
|
|||||||
|
|
||||||
// ExportGenesis exports genesis state of the fee market module
|
// ExportGenesis exports genesis state of the fee market module
|
||||||
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
||||||
baseFee := sdk.ZeroInt()
|
|
||||||
baseFeeInt := k.GetBaseFee(ctx)
|
|
||||||
if baseFeeInt != nil {
|
|
||||||
baseFee = sdk.NewIntFromBigInt(baseFeeInt)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &types.GenesisState{
|
return &types.GenesisState{
|
||||||
Params: k.GetParams(ctx),
|
Params: k.GetParams(ctx),
|
||||||
BaseFee: baseFee,
|
|
||||||
BlockGas: k.GetBlockGasUsed(ctx),
|
BlockGas: k.GetBlockGasUsed(ctx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
|
|||||||
|
|
||||||
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
// If the current block is the first EIP-1559 block, return the InitialBaseFee.
|
||||||
if ctx.BlockHeight() == params.EnableHeight {
|
if ctx.BlockHeight() == params.EnableHeight {
|
||||||
return new(big.Int).SetInt64(params.InitialBaseFee)
|
return params.BaseFee.BigInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the block gas used and the base fee values for the parent block.
|
// get the block gas used and the base fee values for the parent block.
|
||||||
parentBaseFee := k.GetBaseFee(ctx)
|
parentBaseFee := params.BaseFee.BigInt()
|
||||||
if parentBaseFee == nil {
|
if parentBaseFee == nil {
|
||||||
parentBaseFee = new(big.Int).SetInt64(params.InitialBaseFee)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
parentGasUsed := k.GetBlockGasUsed(ctx)
|
parentGasUsed := k.GetBlockGasUsed(ctx)
|
||||||
@ -43,7 +43,7 @@ func (k Keeper) CalculateBaseFee(ctx sdk.Context) *big.Int {
|
|||||||
|
|
||||||
parentGasTargetBig := new(big.Int).Div(gasLimit, new(big.Int).SetUint64(uint64(params.ElasticityMultiplier)))
|
parentGasTargetBig := new(big.Int).Div(gasLimit, new(big.Int).SetUint64(uint64(params.ElasticityMultiplier)))
|
||||||
if !parentGasTargetBig.IsUint64() {
|
if !parentGasTargetBig.IsUint64() {
|
||||||
return new(big.Int).SetInt64(params.InitialBaseFee)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
parentGasTarget := parentGasTargetBig.Uint64()
|
parentGasTarget := parentGasTargetBig.Uint64()
|
||||||
|
@ -2,9 +2,8 @@ package keeper_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
|
||||||
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestCalculateBaseFee() {
|
func (suite *KeeperTestSuite) TestCalculateBaseFee() {
|
||||||
@ -26,7 +25,7 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() {
|
|||||||
func() {
|
func() {
|
||||||
suite.ctx = suite.ctx.WithBlockHeight(0)
|
suite.ctx = suite.ctx.WithBlockHeight(0)
|
||||||
},
|
},
|
||||||
big.NewInt(suite.app.FeeMarketKeeper.GetParams(suite.ctx).InitialBaseFee),
|
suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with BaseFee - parent block used the same gas as its target",
|
"with BaseFee - parent block used the same gas as its target",
|
||||||
@ -51,7 +50,7 @@ func (suite *KeeperTestSuite) TestCalculateBaseFee() {
|
|||||||
params.ElasticityMultiplier = 1
|
params.ElasticityMultiplier = 1
|
||||||
suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
|
suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
|
||||||
},
|
},
|
||||||
big.NewInt(suite.app.FeeMarketKeeper.GetParams(suite.ctx).InitialBaseFee),
|
suite.app.FeeMarketKeeper.GetParams(suite.ctx).BaseFee.BigInt(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"with BaseFee - parent block used more gas than its target",
|
"with BaseFee - parent block used more gas than its target",
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
@ -65,27 +63,3 @@ func (k Keeper) SetBlockGasUsed(ctx sdk.Context, gas uint64) {
|
|||||||
gasBz := sdk.Uint64ToBigEndian(gas)
|
gasBz := sdk.Uint64ToBigEndian(gas)
|
||||||
store.Set(types.KeyPrefixBlockGasUsed, gasBz)
|
store.Set(types.KeyPrefixBlockGasUsed, gasBz)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// Parent Base Fee
|
|
||||||
// Required by EIP1559 base fee calculation.
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// GetBaseFee returns the last base fee value from the store.
|
|
||||||
// returns nil if base fee is not enabled.
|
|
||||||
func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int {
|
|
||||||
store := ctx.KVStore(k.storeKey)
|
|
||||||
bz := store.Get(types.KeyPrefixBaseFee)
|
|
||||||
if len(bz) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return new(big.Int).SetBytes(bz)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBaseFee set the last base fee value to the store.
|
|
||||||
// CONTRACT: this should be only called during EndBlock.
|
|
||||||
func (k Keeper) SetBaseFee(ctx sdk.Context, baseFee *big.Int) {
|
|
||||||
store := ctx.KVStore(k.storeKey)
|
|
||||||
store.Set(types.KeyPrefixBaseFee, baseFee.Bytes())
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
"math/big"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/tharsis/ethermint/x/feemarket/types"
|
"github.com/tharsis/ethermint/x/feemarket/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -16,3 +17,24 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
|||||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||||
k.paramSpace.SetParamSet(ctx, ¶ms)
|
k.paramSpace.SetParamSet(ctx, ¶ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Parent Base Fee
|
||||||
|
// Required by EIP1559 base fee calculation.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// GetBaseFee get's the base fee from the paramSpace
|
||||||
|
// return nil if base fee is not enabled
|
||||||
|
func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int {
|
||||||
|
params := k.GetParams(ctx)
|
||||||
|
if params.NoBaseFee {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return params.BaseFee.BigInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetBaseFee set's the base fee in the paramSpace
|
||||||
|
func (k Keeper) SetBaseFee(ctx sdk.Context, baseFee *big.Int) {
|
||||||
|
k.paramSpace.Set(ctx, types.ParamStoreKeyBaseFee, sdk.NewIntFromBigInt(baseFee))
|
||||||
|
}
|
||||||
|
@ -6,16 +6,14 @@ import (
|
|||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/tharsis/ethermint/x/feemarket/types"
|
"github.com/tharsis/ethermint/x/feemarket/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RandomizedGenState generates a random GenesisState for nft
|
// RandomizedGenState generates a random GenesisState for nft
|
||||||
func RandomizedGenState(simState *module.SimulationState) {
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Int63(), simState.Rand.Int63())
|
params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Uint64(), simState.Rand.Int63())
|
||||||
baseFee := sdk.NewInt(simState.Rand.Int63())
|
|
||||||
blockGas := simState.Rand.Uint64()
|
blockGas := simState.Rand.Uint64()
|
||||||
feemarketGenesis := types.NewGenesisState(params, baseFee, blockGas)
|
feemarketGenesis := types.NewGenesisState(params, blockGas)
|
||||||
|
|
||||||
bz, err := json.MarshalIndent(feemarketGenesis, "", " ")
|
bz, err := json.MarshalIndent(feemarketGenesis, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
128
x/feemarket/types/feemarket.pb.go
generated
128
x/feemarket/types/feemarket.pb.go
generated
@ -5,6 +5,8 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
_ "github.com/gogo/protobuf/gogoproto"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
proto "github.com/gogo/protobuf/proto"
|
||||||
io "io"
|
io "io"
|
||||||
math "math"
|
math "math"
|
||||||
@ -32,10 +34,10 @@ type Params struct {
|
|||||||
// elasticity multiplier bounds the maximum gas limit an EIP-1559 block may
|
// elasticity multiplier bounds the maximum gas limit an EIP-1559 block may
|
||||||
// have.
|
// have.
|
||||||
ElasticityMultiplier uint32 `protobuf:"varint,3,opt,name=elasticity_multiplier,json=elasticityMultiplier,proto3" json:"elasticity_multiplier,omitempty"`
|
ElasticityMultiplier uint32 `protobuf:"varint,3,opt,name=elasticity_multiplier,json=elasticityMultiplier,proto3" json:"elasticity_multiplier,omitempty"`
|
||||||
// initial base fee for EIP-1559 blocks.
|
|
||||||
InitialBaseFee int64 `protobuf:"varint,4,opt,name=initial_base_fee,json=initialBaseFee,proto3" json:"initial_base_fee,omitempty"`
|
|
||||||
// height at which the base fee calculation is enabled.
|
// height at which the base fee calculation is enabled.
|
||||||
EnableHeight int64 `protobuf:"varint,5,opt,name=enable_height,json=enableHeight,proto3" json:"enable_height,omitempty"`
|
EnableHeight int64 `protobuf:"varint,5,opt,name=enable_height,json=enableHeight,proto3" json:"enable_height,omitempty"`
|
||||||
|
// base fee for EIP-1559 blocks.
|
||||||
|
BaseFee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Reset() { *m = Params{} }
|
func (m *Params) Reset() { *m = Params{} }
|
||||||
@ -92,13 +94,6 @@ func (m *Params) GetElasticityMultiplier() uint32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) GetInitialBaseFee() int64 {
|
|
||||||
if m != nil {
|
|
||||||
return m.InitialBaseFee
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Params) GetEnableHeight() int64 {
|
func (m *Params) GetEnableHeight() int64 {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.EnableHeight
|
return m.EnableHeight
|
||||||
@ -115,25 +110,29 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_4feb8b20cf98e6e1 = []byte{
|
var fileDescriptor_4feb8b20cf98e6e1 = []byte{
|
||||||
// 286 bytes of a gzipped FileDescriptorProto
|
// 343 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0xc1, 0x4a, 0x03, 0x31,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcf, 0x6a, 0xea, 0x40,
|
||||||
0x10, 0x86, 0x1b, 0xab, 0x45, 0xa3, 0x15, 0x59, 0x54, 0x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, 0x0c, 0x19, 0x4d, 0x8b, 0x65, 0x8c,
|
||||||
|
0xc6, 0x9b, 0xbd, 0x45, 0xb6, 0x7b, 0x8b, 0x7c, 0xee, 0x2d, 0xf2, 0x7a, 0xb0, 0xb4, 0xed, 0xc1,
|
||||||
|
0xd2, 0xde, 0x0f, 0x96, 0xf6, 0xec, 0x9e, 0xb5, 0xc0, 0x84, 0x4a, 0xc5, 0x94, 0x57, 0x26, 0xf5,
|
||||||
|
0x72, 0x96, 0x55, 0xde, 0x2e, 0x6c, 0xe4, 0x7b, 0x1f, 0x7e, 0x05, 0x00, 0x00, 0xff, 0xff, 0xee,
|
||||||
|
0xfc, 0x5c, 0x06, 0xcf, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Params) Marshal() (dAtA []byte, err error) {
|
func (m *Params) Marshal() (dAtA []byte, err error) {
|
||||||
@ -156,16 +155,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
_ = i
|
_ = i
|
||||||
var l int
|
var l int
|
||||||
_ = l
|
_ = l
|
||||||
|
{
|
||||||
|
size := m.BaseFee.Size()
|
||||||
|
i -= size
|
||||||
|
if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i = encodeVarintFeemarket(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x32
|
||||||
if m.EnableHeight != 0 {
|
if m.EnableHeight != 0 {
|
||||||
i = encodeVarintFeemarket(dAtA, i, uint64(m.EnableHeight))
|
i = encodeVarintFeemarket(dAtA, i, uint64(m.EnableHeight))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x28
|
dAtA[i] = 0x28
|
||||||
}
|
}
|
||||||
if m.InitialBaseFee != 0 {
|
|
||||||
i = encodeVarintFeemarket(dAtA, i, uint64(m.InitialBaseFee))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x20
|
|
||||||
}
|
|
||||||
if m.ElasticityMultiplier != 0 {
|
if m.ElasticityMultiplier != 0 {
|
||||||
i = encodeVarintFeemarket(dAtA, i, uint64(m.ElasticityMultiplier))
|
i = encodeVarintFeemarket(dAtA, i, uint64(m.ElasticityMultiplier))
|
||||||
i--
|
i--
|
||||||
@ -215,12 +219,11 @@ func (m *Params) Size() (n int) {
|
|||||||
if m.ElasticityMultiplier != 0 {
|
if m.ElasticityMultiplier != 0 {
|
||||||
n += 1 + sovFeemarket(uint64(m.ElasticityMultiplier))
|
n += 1 + sovFeemarket(uint64(m.ElasticityMultiplier))
|
||||||
}
|
}
|
||||||
if m.InitialBaseFee != 0 {
|
|
||||||
n += 1 + sovFeemarket(uint64(m.InitialBaseFee))
|
|
||||||
}
|
|
||||||
if m.EnableHeight != 0 {
|
if m.EnableHeight != 0 {
|
||||||
n += 1 + sovFeemarket(uint64(m.EnableHeight))
|
n += 1 + sovFeemarket(uint64(m.EnableHeight))
|
||||||
}
|
}
|
||||||
|
l = m.BaseFee.Size()
|
||||||
|
n += 1 + l + sovFeemarket(uint64(l))
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,25 +320,6 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 4:
|
|
||||||
if wireType != 0 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field InitialBaseFee", wireType)
|
|
||||||
}
|
|
||||||
m.InitialBaseFee = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowFeemarket
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
m.InitialBaseFee |= int64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 5:
|
case 5:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field EnableHeight", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field EnableHeight", wireType)
|
||||||
@ -355,6 +339,40 @@ func (m *Params) Unmarshal(dAtA []byte) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 6:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowFeemarket
|
||||||
|
}
|
||||||
|
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 ErrInvalidLengthFeemarket
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthFeemarket
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skipFeemarket(dAtA[iNdEx:])
|
skippy, err := skipFeemarket(dAtA[iNdEx:])
|
||||||
|
@ -1,27 +1,17 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DefaultGenesisState sets default fee market genesis state.
|
// DefaultGenesisState sets default fee market genesis state.
|
||||||
func DefaultGenesisState() *GenesisState {
|
func DefaultGenesisState() *GenesisState {
|
||||||
return &GenesisState{
|
return &GenesisState{
|
||||||
Params: DefaultParams(),
|
Params: DefaultParams(),
|
||||||
// the default base fee should be initialized because the default enable height is zero.
|
|
||||||
BaseFee: sdk.NewIntFromUint64(params.InitialBaseFee),
|
|
||||||
BlockGas: 0,
|
BlockGas: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGenesisState creates a new genesis state.
|
// NewGenesisState creates a new genesis state.
|
||||||
func NewGenesisState(params Params, baseFee sdk.Int, blockGas uint64) *GenesisState {
|
func NewGenesisState(params Params, blockGas uint64) *GenesisState {
|
||||||
return &GenesisState{
|
return &GenesisState{
|
||||||
Params: params,
|
Params: params,
|
||||||
BaseFee: baseFee,
|
|
||||||
BlockGas: blockGas,
|
BlockGas: blockGas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,9 +19,5 @@ func NewGenesisState(params Params, baseFee sdk.Int, blockGas uint64) *GenesisSt
|
|||||||
// Validate performs basic genesis state validation returning an error upon any
|
// Validate performs basic genesis state validation returning an error upon any
|
||||||
// failure.
|
// failure.
|
||||||
func (gs GenesisState) Validate() error {
|
func (gs GenesisState) Validate() error {
|
||||||
if gs.BaseFee.IsNegative() {
|
|
||||||
return fmt.Errorf("base fee cannot be negative: %s", gs.BaseFee)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gs.Params.Validate()
|
return gs.Params.Validate()
|
||||||
}
|
}
|
||||||
|
86
x/feemarket/types/genesis.pb.go
generated
86
x/feemarket/types/genesis.pb.go
generated
@ -5,7 +5,6 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
_ "github.com/gogo/protobuf/gogoproto"
|
_ "github.com/gogo/protobuf/gogoproto"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
proto "github.com/gogo/protobuf/proto"
|
||||||
io "io"
|
io "io"
|
||||||
@ -28,9 +27,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
|||||||
type GenesisState struct {
|
type GenesisState struct {
|
||||||
// params defines all the paramaters of the module.
|
// params defines all the paramaters of the module.
|
||||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||||
// base fee is the exported value from previous software version.
|
|
||||||
// Zero by default.
|
|
||||||
BaseFee github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=base_fee,json=baseFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"base_fee"`
|
|
||||||
// block gas is the amount of gas used on the last block before the upgrade.
|
// block gas is the amount of gas used on the last block before the upgrade.
|
||||||
// Zero by default.
|
// Zero by default.
|
||||||
BlockGas uint64 `protobuf:"varint,3,opt,name=block_gas,json=blockGas,proto3" json:"block_gas,omitempty"`
|
BlockGas uint64 `protobuf:"varint,3,opt,name=block_gas,json=blockGas,proto3" json:"block_gas,omitempty"`
|
||||||
@ -92,25 +88,23 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_6241c21661288629 = []byte{
|
var fileDescriptor_6241c21661288629 = []byte{
|
||||||
// 286 bytes of a gzipped FileDescriptorProto
|
// 246 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x31, 0x4b, 0xc3, 0x40,
|
0x1f, 0x8b, 0x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0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8,
|
||||||
0x24, 0xe6, 0x12, 0x37, 0xcf, 0x15, 0x3e, 0x67, 0x5c, 0xbf, 0x97, 0x80, 0x6c, 0x52, 0xe8, 0xe0,
|
0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57,
|
||||||
0xa8, 0xc9, 0xdf, 0x01, 0x38, 0xe7, 0x76, 0x37, 0x7c, 0x91, 0x51, 0x36, 0x8d, 0x05, 0xf6, 0x0e,
|
0xbf, 0x24, 0x23, 0xb1, 0xa8, 0x38, 0xb3, 0x58, 0x1f, 0xe1, 0x9f, 0x0a, 0x24, 0x1f, 0x95, 0x54,
|
||||||
0x5d, 0xe2, 0xb5, 0x82, 0x8e, 0x19, 0x8c, 0x05, 0xfa, 0xf7, 0x8b, 0x8a, 0x92, 0x65, 0x45, 0xc9,
|
0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xfd, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x4e,
|
||||||
0x4f, 0x45, 0xc9, 0x47, 0x4d, 0xad, 0x65, 0x4d, 0xad, 0xaf, 0x9a, 0x5a, 0x4f, 0x6c, 0xcf, 0xa3,
|
0x2a, 0x68, 0x49, 0x01, 0x00, 0x00,
|
||||||
0x13, 0xa1, 0x30, 0x45, 0xbe, 0xeb, 0xe2, 0x6d, 0xaf, 0x0d, 0xe3, 0x0c, 0xdb, 0xa6, 0x87, 0x9b,
|
|
||||||
0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x41, 0xbf, 0x7e, 0x16, 0x85, 0x01, 0x00, 0x00,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||||
@ -138,16 +132,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
i--
|
i--
|
||||||
dAtA[i] = 0x18
|
dAtA[i] = 0x18
|
||||||
}
|
}
|
||||||
{
|
|
||||||
size := m.BaseFee.Size()
|
|
||||||
i -= size
|
|
||||||
if _, err := m.BaseFee.MarshalTo(dAtA[i:]); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
|
||||||
}
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x12
|
|
||||||
{
|
{
|
||||||
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
|
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -180,8 +164,6 @@ func (m *GenesisState) Size() (n int) {
|
|||||||
_ = l
|
_ = l
|
||||||
l = m.Params.Size()
|
l = m.Params.Size()
|
||||||
n += 1 + l + sovGenesis(uint64(l))
|
n += 1 + l + sovGenesis(uint64(l))
|
||||||
l = m.BaseFee.Size()
|
|
||||||
n += 1 + l + sovGenesis(uint64(l))
|
|
||||||
if m.BlockGas != 0 {
|
if m.BlockGas != 0 {
|
||||||
n += 1 + sovGenesis(uint64(m.BlockGas))
|
n += 1 + sovGenesis(uint64(m.BlockGas))
|
||||||
}
|
}
|
||||||
@ -256,40 +238,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field BaseFee", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return ErrIntOverflowGenesis
|
|
||||||
}
|
|
||||||
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 ErrInvalidLengthGenesis
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return ErrInvalidLengthGenesis
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if err := m.BaseFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 3:
|
case 3:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field BlockGas", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field BlockGas", wireType)
|
||||||
|
@ -3,7 +3,6 @@ package types
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
|
|||||||
"valid genesis",
|
"valid genesis",
|
||||||
&GenesisState{
|
&GenesisState{
|
||||||
DefaultParams(),
|
DefaultParams(),
|
||||||
sdk.ZeroInt(),
|
|
||||||
uint64(1),
|
uint64(1),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -39,7 +37,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
|
|||||||
"valid New genesis",
|
"valid New genesis",
|
||||||
NewGenesisState(
|
NewGenesisState(
|
||||||
DefaultParams(),
|
DefaultParams(),
|
||||||
sdk.ZeroInt(),
|
|
||||||
uint64(1),
|
uint64(1),
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
@ -48,16 +45,6 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
|
|||||||
"empty genesis",
|
"empty genesis",
|
||||||
&GenesisState{
|
&GenesisState{
|
||||||
Params: Params{},
|
Params: Params{},
|
||||||
BaseFee: sdk.ZeroInt(),
|
|
||||||
BlockGas: 0,
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"base fee is negative",
|
|
||||||
&GenesisState{
|
|
||||||
Params: Params{},
|
|
||||||
BaseFee: sdk.OneInt().Neg(),
|
|
||||||
BlockGas: 0,
|
BlockGas: 0,
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
|
@ -3,6 +3,7 @@ package types
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
@ -14,7 +15,7 @@ var (
|
|||||||
ParamStoreKeyNoBaseFee = []byte("NoBaseFee")
|
ParamStoreKeyNoBaseFee = []byte("NoBaseFee")
|
||||||
ParamStoreKeyBaseFeeChangeDenominator = []byte("BaseFeeChangeDenominator")
|
ParamStoreKeyBaseFeeChangeDenominator = []byte("BaseFeeChangeDenominator")
|
||||||
ParamStoreKeyElasticityMultiplier = []byte("ElasticityMultiplier")
|
ParamStoreKeyElasticityMultiplier = []byte("ElasticityMultiplier")
|
||||||
ParamStoreKeyInitialBaseFee = []byte("InitialBaseFee")
|
ParamStoreKeyBaseFee = []byte("BaseFee")
|
||||||
ParamStoreKeyEnableHeight = []byte("EnableHeight")
|
ParamStoreKeyEnableHeight = []byte("EnableHeight")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,12 +25,12 @@ func ParamKeyTable() paramtypes.KeyTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewParams creates a new Params instance
|
// NewParams creates a new Params instance
|
||||||
func NewParams(noBaseFee bool, baseFeeChangeDenom, elasticityMultiplier uint32, initialBaseFee, enableHeight int64) Params {
|
func NewParams(noBaseFee bool, baseFeeChangeDenom, elasticityMultiplier uint32, baseFee uint64, enableHeight int64) Params {
|
||||||
return Params{
|
return Params{
|
||||||
NoBaseFee: noBaseFee,
|
NoBaseFee: noBaseFee,
|
||||||
BaseFeeChangeDenominator: baseFeeChangeDenom,
|
BaseFeeChangeDenominator: baseFeeChangeDenom,
|
||||||
ElasticityMultiplier: elasticityMultiplier,
|
ElasticityMultiplier: elasticityMultiplier,
|
||||||
InitialBaseFee: initialBaseFee,
|
BaseFee: sdk.NewIntFromUint64(baseFee),
|
||||||
EnableHeight: enableHeight,
|
EnableHeight: enableHeight,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -40,7 +41,7 @@ func DefaultParams() Params {
|
|||||||
NoBaseFee: false,
|
NoBaseFee: false,
|
||||||
BaseFeeChangeDenominator: params.BaseFeeChangeDenominator,
|
BaseFeeChangeDenominator: params.BaseFeeChangeDenominator,
|
||||||
ElasticityMultiplier: params.ElasticityMultiplier,
|
ElasticityMultiplier: params.ElasticityMultiplier,
|
||||||
InitialBaseFee: params.InitialBaseFee,
|
BaseFee: sdk.NewIntFromUint64(params.InitialBaseFee),
|
||||||
EnableHeight: 0,
|
EnableHeight: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
|||||||
paramtypes.NewParamSetPair(ParamStoreKeyNoBaseFee, &p.NoBaseFee, validateBool),
|
paramtypes.NewParamSetPair(ParamStoreKeyNoBaseFee, &p.NoBaseFee, validateBool),
|
||||||
paramtypes.NewParamSetPair(ParamStoreKeyBaseFeeChangeDenominator, &p.BaseFeeChangeDenominator, validateBaseFeeChangeDenominator),
|
paramtypes.NewParamSetPair(ParamStoreKeyBaseFeeChangeDenominator, &p.BaseFeeChangeDenominator, validateBaseFeeChangeDenominator),
|
||||||
paramtypes.NewParamSetPair(ParamStoreKeyElasticityMultiplier, &p.ElasticityMultiplier, validateElasticityMultiplier),
|
paramtypes.NewParamSetPair(ParamStoreKeyElasticityMultiplier, &p.ElasticityMultiplier, validateElasticityMultiplier),
|
||||||
paramtypes.NewParamSetPair(ParamStoreKeyInitialBaseFee, &p.InitialBaseFee, validateInitialBaseFee),
|
paramtypes.NewParamSetPair(ParamStoreKeyBaseFee, &p.BaseFee, validateBaseFee),
|
||||||
paramtypes.NewParamSetPair(ParamStoreKeyEnableHeight, &p.EnableHeight, validateEnableHeight),
|
paramtypes.NewParamSetPair(ParamStoreKeyEnableHeight, &p.EnableHeight, validateEnableHeight),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,8 +63,8 @@ func (p Params) Validate() error {
|
|||||||
return fmt.Errorf("base fee change denominator cannot be 0")
|
return fmt.Errorf("base fee change denominator cannot be 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.InitialBaseFee < 0 {
|
if p.BaseFee.IsNegative() {
|
||||||
return fmt.Errorf("initial base fee cannot be negative: %d", p.InitialBaseFee)
|
return fmt.Errorf("initial base fee cannot be negative: %s", p.BaseFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.EnableHeight < 0 {
|
if p.EnableHeight < 0 {
|
||||||
@ -106,14 +107,14 @@ func validateElasticityMultiplier(i interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateInitialBaseFee(i interface{}) error {
|
func validateBaseFee(i interface{}) error {
|
||||||
value, ok := i.(int64)
|
value, ok := i.(sdk.Int)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("invalid parameter type: %T", i)
|
return fmt.Errorf("invalid parameter type: %T", i)
|
||||||
}
|
}
|
||||||
|
|
||||||
if value < 0 {
|
if value.IsNegative() {
|
||||||
return fmt.Errorf("initial base fee cannot be negative: %d", value)
|
return fmt.Errorf("base fee cannot be negative")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
@ -41,16 +42,6 @@ func (suite *ParamsTestSuite) TestParamsValidate() {
|
|||||||
NewParams(true, 0, 3, 2000000000, int64(544435345345435345)),
|
NewParams(true, 0, 3, 2000000000, int64(544435345345435345)),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"initial base fee cannot is negative",
|
|
||||||
NewParams(true, 7, 3, -2000000000, int64(544435345345435345)),
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"initial base fee cannot is negative",
|
|
||||||
NewParams(true, 7, 3, 2000000000, int64(-544435345345435345)),
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
@ -72,9 +63,10 @@ func (suite *ParamsTestSuite) TestParamsValidatePriv() {
|
|||||||
suite.Require().NoError(validateBaseFeeChangeDenominator(uint32(7)))
|
suite.Require().NoError(validateBaseFeeChangeDenominator(uint32(7)))
|
||||||
suite.Require().Error(validateElasticityMultiplier(""))
|
suite.Require().Error(validateElasticityMultiplier(""))
|
||||||
suite.Require().NoError(validateElasticityMultiplier(uint32(2)))
|
suite.Require().NoError(validateElasticityMultiplier(uint32(2)))
|
||||||
suite.Require().Error(validateInitialBaseFee(""))
|
suite.Require().Error(validateBaseFee(""))
|
||||||
suite.Require().Error(validateInitialBaseFee(int64(-2000000000)))
|
suite.Require().Error(validateBaseFee(int64(2000000000)))
|
||||||
suite.Require().NoError(validateInitialBaseFee(int64(2000000000)))
|
suite.Require().Error(validateBaseFee(sdk.NewInt(-2000000000)))
|
||||||
|
suite.Require().NoError(validateBaseFee(sdk.NewInt(2000000000)))
|
||||||
suite.Require().Error(validateEnableHeight(""))
|
suite.Require().Error(validateEnableHeight(""))
|
||||||
suite.Require().Error(validateEnableHeight(int64(-544435345345435345)))
|
suite.Require().Error(validateEnableHeight(int64(-544435345345435345)))
|
||||||
suite.Require().NoError(validateEnableHeight(int64(544435345345435345)))
|
suite.Require().NoError(validateEnableHeight(int64(544435345345435345)))
|
||||||
|
Loading…
Reference in New Issue
Block a user