diff --git a/app/app.go b/app/app.go index e9427f8b55..1ad041c4f2 100644 --- a/app/app.go +++ b/app/app.go @@ -143,7 +143,7 @@ var ( capability.AppModuleBasic{}, stakingModule{}, mintModule{}, - distr.AppModuleBasic{}, + distributionModule{}, newGovModule(), params.AppModuleBasic{}, crisisModule{}, diff --git a/app/default_overrides.go b/app/default_overrides.go index c851581f32..46216e0f1e 100644 --- a/app/default_overrides.go +++ b/app/default_overrides.go @@ -15,7 +15,9 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/crisis" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distribution "github.com/cosmos/cosmos-sdk/x/distribution" distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" @@ -117,6 +119,20 @@ func (crisisModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { }) } +type distributionModule struct { + distribution.AppModuleBasic +} + +// DefaultGenesis returns custom x/distribution module genesis state. +func (distributionModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + params := distributiontypes.DefaultParams() + params.BaseProposerReward = sdk.ZeroDec() // 0% + params.BonusProposerReward = sdk.ZeroDec() // 0% + return cdc.MustMarshalJSON(&distributiontypes.GenesisState{ + Params: params, + }) +} + type ibcModule struct { ibc.AppModuleBasic } diff --git a/app/default_overrides_test.go b/app/default_overrides_test.go index f63fa8b655..8987df18d5 100644 --- a/app/default_overrides_test.go +++ b/app/default_overrides_test.go @@ -6,6 +6,7 @@ import ( "github.com/celestiaorg/celestia-app/app/encoding" "github.com/cosmos/cosmos-sdk/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/stretchr/testify/assert" ) @@ -32,3 +33,21 @@ func Test_newGovModule(t *testing.T) { assert.Equal(t, oneWeek, *govGenesisState.DepositParams.MaxDepositPeriod) assert.Equal(t, oneWeek, *govGenesisState.VotingParams.VotingPeriod) } + +// TestDefaultGenesis verifies that the distribution module's genesis state has +// defaults overridden. +func TestDefaultGenesis(t *testing.T) { + encCfg := encoding.MakeConfig(ModuleEncodingRegisters...) + dm := distributionModule{} + raw := dm.DefaultGenesis(encCfg.Codec) + distributionGenesisState := distributiontypes.GenesisState{} + encCfg.Codec.MustUnmarshalJSON(raw, &distributionGenesisState) + + // Verify that BaseProposerReward and BonusProposerReward were overridden to 0%. + assert.Equal(t, types.ZeroDec(), distributionGenesisState.Params.BaseProposerReward) + assert.Equal(t, types.ZeroDec(), distributionGenesisState.Params.BonusProposerReward) + + // Verify that other params weren't overridden. + assert.Equal(t, distributiontypes.DefaultParams().WithdrawAddrEnabled, distributionGenesisState.Params.WithdrawAddrEnabled) + assert.Equal(t, distributiontypes.DefaultParams().CommunityTax, distributionGenesisState.Params.CommunityTax) +}