Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: prevent modifications on governance unmodifiable params #2919

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,22 @@ func (app *App) setPostHanders() {
// governance.
func (*App) BlockedParams() [][2]string {
return [][2]string{
// MaxSquareSize
{blobmoduletypes.ModuleName, string(blobmoduletypes.KeyGovMaxSquareSize)},
// bank.SendEnabled
{banktypes.ModuleName, string(banktypes.KeySendEnabled)},
// staking.UnbondingTime
{stakingtypes.ModuleName, string(stakingtypes.KeyUnbondingTime)},
// staking.BondDenom
{stakingtypes.ModuleName, string(stakingtypes.KeyBondDenom)},
// MaxBlockBytes and consensus.block.TimeIotaMs
{baseapp.Paramspace, string(baseapp.ParamStoreKeyBlockParams)},
// consensus.validator.PubKeyTypes
{baseapp.Paramspace, string(baseapp.ParamStoreKeyValidatorParams)},
// consensus.Version.AppVersion
{baseapp.Paramspace, string(baseapp.ParamStoreKeyVersionParams)},
// staking.BondDenom
{stakingtypes.ModuleName, string(stakingtypes.KeyBondDenom)},
// staking.MaxValidators
{stakingtypes.ModuleName, string(stakingtypes.KeyMaxValidators)},
// staking.UnbondingTime
{stakingtypes.ModuleName, string(stakingtypes.KeyUnbondingTime)},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] this adds more params to the list of blocked params which is potentially something we need to do so that there isn't a divergence between what is stated in params.md and what is actually modifiable. However, it's not clear if these need to be added without appropriate test coverage.

IMO we should tackle this in a few steps:

  1. Write a table-driven test with test cases for each param listed in params.md. The test should attempt to modify the param and see if it was actually modified. Each test case should have a boolean field that indicates if modification was expected to happen (i.e. that param is governance modifiable) or not happen (i.e. that param is not governance modifiable).
  2. Once we have the test above, we can compare the test results to params.md. If any divergences exist, create a GH issue with the divergence so that we can get alignment on whether the param should be governance modifiable.
  3. [Optional] If there are any params that are governance modifiable and shouldn't be, we may need to add them to this BlockedParams list.

Comment on lines +741 to +748
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] this is a breaking change so if it is included in this PR then the PR title needs a ! to conform to conventional commits.

IMO we shouldn't add this to the blocked list yet. We should create a GH issue with the list of params that are governance modifiable even though the specs claim they shouldn't be. We should get team alignment on what to do for those params. Then we may update this list or update the specs accordingly. cc: @evan-forbes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah any consens breaking change needs a CIP

@fahimahmedx, this is consensus breaking since nodes running this won't change a param, where nodes that are not will change the param

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CIP doesn't have to be super in depth, since the change is pretty small, but we do still need to explain the benefits of adding or removing any params

}
fahimahmedx marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
25 changes: 0 additions & 25 deletions x/paramfilter/test/param_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/celestiaorg/celestia-app/x/paramfilter"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
tmlog "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/proto/tendermint/types"
Expand All @@ -34,30 +33,6 @@ func TestParamFilter(t *testing.T) {
require.Error(t, err)
require.Contains(t, err.Error(), "parameter can not be modified")
}

// ensure that we are not filtering out valid proposals
validChange := proposal.NewParamChange(stakingtypes.ModuleName, string(stakingtypes.KeyMaxValidators), "1")
p := testProposal(validChange)
err := handler(ctx, p)
require.NoError(t, err)

ps := app.StakingKeeper.GetParams(ctx)
require.Equal(t, ps.MaxValidators, uint32(1))

// ensure that we're throwing out entire proposals if any of the changes are blocked
for _, p := range app.BlockedParams() {
// try to set the max validators to 2, unlike above this should fail
validChange := proposal.NewParamChange(stakingtypes.ModuleName, string(stakingtypes.KeyMaxValidators), "2")
fahimahmedx marked this conversation as resolved.
Show resolved Hide resolved
invalidChange := proposal.NewParamChange(p[0], p[1], "value")
p := testProposal(validChange, invalidChange)
err := handler(ctx, p)
require.Error(t, err)
require.Contains(t, err.Error(), "parameter can not be modified")

ps := app.StakingKeeper.GetParams(ctx)
require.Equal(t, ps.MaxValidators, uint32(1))

}
}

func testProposal(changes ...proposal.ParamChange) *proposal.ParameterChangeProposal {
Expand Down