Skip to content

Commit

Permalink
fix: override proposer rewards to 0% (#2717)
Browse files Browse the repository at this point in the history
Closes #2716

## Testing

```bash
./scripts/single-node.sh
cat ~/.celestia-app/config/genesis.json
```

### Before

```genesis.json
    "distribution": {
      "params": {
        "community_tax": "0.020000000000000000",
        "base_proposer_reward": "0.010000000000000000",
        "bonus_proposer_reward": "0.040000000000000000",
        "withdraw_addr_enabled": true
      },
```

### After

```genesis.json
    "distribution": {
      "params": {
        "community_tax": "0.020000000000000000",
        "base_proposer_reward": "0.000000000000000000",
        "bonus_proposer_reward": "0.000000000000000000",
        "withdraw_addr_enabled": true
      },
```

(cherry picked from commit dfd9959)
  • Loading branch information
rootulp authored and mergify[bot] committed Oct 19, 2023
1 parent c79fb45 commit 95532c5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var (
capability.AppModuleBasic{},
stakingModule{},
mintModule{},
distr.AppModuleBasic{},
distributionModule{},
newGovModule(),
params.AppModuleBasic{},
crisisModule{},
Expand Down
16 changes: 16 additions & 0 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 19 additions & 0 deletions app/default_overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
}

0 comments on commit 95532c5

Please sign in to comment.