Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
add changelog and fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy committed Feb 16, 2022
1 parent 68acba8 commit d483578
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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.
* (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#943](https://github.com/tharsis/ethermint/pull/943) Store the base fee as a module param instead of using state storage.

### Bug Fixes

Expand Down
4 changes: 2 additions & 2 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (suite *AnteTestSuite) SetupTest() {
feemarketGenesis := feemarkettypes.DefaultGenesisState()
feemarketGenesis.Params.EnableHeight = 1
feemarketGenesis.Params.NoBaseFee = false
bf, _ := sdk.NewIntFromString(feemarketGenesis.Params.BaseFee)
feemarketGenesis.DefaultBaseFee =bf
bf, _ := sdk.NewIntFromString(feemarketGenesis.Params.BaseFee)
feemarketGenesis.DefaultBaseFee = bf
// Verify feeMarket genesis
err := feemarketGenesis.Validate()
suite.Require().NoError(err)
Expand Down
6 changes: 2 additions & 4 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion x/evm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (suite *KeeperTestSuite) DoSetupTest(t require.TestingT) {
if suite.enableFeemarket {
feemarketGenesis.Params.EnableHeight = 1
feemarketGenesis.Params.NoBaseFee = false
bf, _ := sdk.NewIntFromString(feemarketGenesis.Params.BaseFee)
bf, _ := sdk.NewIntFromString(feemarketGenesis.Params.BaseFee)
feemarketGenesis.DefaultBaseFee = bf
} else {
feemarketGenesis.Params.NoBaseFee = true
Expand Down
6 changes: 3 additions & 3 deletions x/feemarket/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
}

return &types.GenesisState{
Params: k.GetParams(ctx),
DefaultBaseFee: baseFee,
BlockGas: k.GetBlockGasUsed(ctx),
Params: k.GetParams(ctx),
DefaultBaseFee: baseFee,
BlockGas: k.GetBlockGasUsed(ctx),
}
}
5 changes: 3 additions & 2 deletions x/feemarket/keeper/params.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package keeper

import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tharsis/ethermint/x/feemarket/types"
"math/big"
)

// GetParams returns the total set of fee market parameters.
Expand Down Expand Up @@ -39,4 +40,4 @@ func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int {
// 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, baseFee.String())
}
}
10 changes: 5 additions & 5 deletions x/feemarket/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ func DefaultGenesisState() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
// the default base fee should be initialized because the default enable height is zero.
DefaultBaseFee: sdk.NewIntFromUint64(params.InitialBaseFee),
BlockGas: 0,
DefaultBaseFee: sdk.NewIntFromUint64(params.InitialBaseFee),
BlockGas: 0,
}
}

// NewGenesisState creates a new genesis state.
func NewGenesisState(params Params, baseFee sdk.Int, blockGas uint64) *GenesisState {
return &GenesisState{
Params: params,
DefaultBaseFee: baseFee,
BlockGas: blockGas,
Params: params,
DefaultBaseFee: baseFee,
BlockGas: blockGas,
}
}

Expand Down
12 changes: 6 additions & 6 deletions x/feemarket/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ func (suite *GenesisTestSuite) TestValidateGenesis() {
{
"empty genesis",
&GenesisState{
Params: Params{},
DefaultBaseFee: sdk.ZeroInt(),
BlockGas: 0,
Params: Params{},
DefaultBaseFee: sdk.ZeroInt(),
BlockGas: 0,
},
false,
},
{
"base fee is negative",
&GenesisState{
Params: Params{},
DefaultBaseFee: sdk.OneInt().Neg(),
BlockGas: 0,
Params: Params{},
DefaultBaseFee: sdk.OneInt().Neg(),
BlockGas: 0,
},
false,
},
Expand Down
12 changes: 5 additions & 7 deletions x/feemarket/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (
ParamStoreKeyNoBaseFee = []byte("NoBaseFee")
ParamStoreKeyBaseFeeChangeDenominator = []byte("BaseFeeChangeDenominator")
ParamStoreKeyElasticityMultiplier = []byte("ElasticityMultiplier")
ParamStoreKeyBaseFee = []byte("BaseFee")
ParamStoreKeyBaseFee = []byte("BaseFee")
ParamStoreKeyEnableHeight = []byte("EnableHeight")
)

Expand All @@ -31,7 +31,7 @@ func NewParams(noBaseFee bool, baseFeeChangeDenom, elasticityMultiplier uint32,
NoBaseFee: noBaseFee,
BaseFeeChangeDenominator: baseFeeChangeDenom,
ElasticityMultiplier: elasticityMultiplier,
BaseFee: strconv.FormatInt(baseFee, 10),
BaseFee: strconv.FormatInt(baseFee, 10),
EnableHeight: enableHeight,
}
}
Expand All @@ -42,7 +42,7 @@ func DefaultParams() Params {
NoBaseFee: false,
BaseFeeChangeDenominator: params.BaseFeeChangeDenominator,
ElasticityMultiplier: params.ElasticityMultiplier,
BaseFee: strconv.FormatInt(params.InitialBaseFee, 10),
BaseFee: strconv.FormatInt(params.InitialBaseFee, 10),
EnableHeight: 0,
}
}
Expand All @@ -64,10 +64,9 @@ func (p Params) Validate() error {
return fmt.Errorf("base fee change denominator cannot be 0")
}

baseFee , valid := new(big.Int).SetString(p.BaseFee, 10)
baseFee, valid := new(big.Int).SetString(p.BaseFee, 10)
if !valid {
return fmt.Errorf("not a valid base fee: %s", p.BaseFee)

}

if baseFee.Sign() < 0 {
Expand Down Expand Up @@ -120,10 +119,9 @@ func validateBaseFee(i interface{}) error {
return fmt.Errorf("invalid parameter type: %T", i)
}

baseFee , valid := new(big.Int).SetString(value, 10)
baseFee, valid := new(big.Int).SetString(value, 10)
if !valid {
return fmt.Errorf("not a valid base fee: %s", baseFee)

}

if baseFee.Sign() < 0 {
Expand Down

0 comments on commit d483578

Please sign in to comment.