paramfilter

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

x/paramfilter

Abstract

The paramfilter module allows for specific parameters to be added to a block list, so that they cannot be changed by governance proposals. If a proposal contains a single blocked parameter change, then none of the parameters are updated.

This is useful for forcing hardforks to change parameters that are critical to the network's operation that are also part of the cosmos-sdk's standard modules. New modules should not use this module, and instead use hardcoded constants.

State

The state consists only of the parameters that are protected by the paramfilter. All state is immutable and stored in memory during the application's initialization.

// ParamBlockList keeps track of parameters that cannot be changed by governance
// proposals
type ParamBlockList struct {
	params map[string]bool
}

// NewParamBlockList creates a new ParamBlockList that can be used to block gov
// proposals that attempt to change hard-coded parameters.
func NewParamBlockList(blockedParams ...[2]string) ParamBlockList {
	consolidatedParams := make(map[string]bool, len(blockedParams))
	for _, param := range blockedParams {
		consolidatedParams[fmt.Sprintf("%s-%s", param[0], param[1])] = true
	}
	return ParamBlockList{params: consolidatedParams}
}

Usage

Pass a list of the blocked subspace key pairs that describe each parameter to the block list, then register the param change handler with the governance module.

func (*App) Blocked() [][2]string {
	return [][2]string{
		{banktypes.ModuleName, string(banktypes.KeySendEnabled)},
		{stakingtypes.ModuleName, string(stakingtypes.KeyUnbondingTime)},
		{stakingtypes.ModuleName, string(stakingtypes.KeyBondDenom)},
		{baseapp.Paramspace, string(baseapp.ParamStoreKeyValidatorParams)},
	}
}

func NewApp(...) *App {
    ...
    paramBlockList := paramfilter.NewParamBlockList(app.BlockedParams()...)

	// register the proposal types
	govRouter := oldgovtypes.NewRouter()
	govRouter.AddRoute(paramproposal.RouterKey, paramBlockList.GovHandler(app.ParamsKeeper))
    ...
}

Documentation

Index

Constants

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "paramfilter"
)

Variables

View Source
var ErrBlockedParameter = sdkerrors.Register(ModuleName, baseErrorCode, "parameter can not be modified")

ErrBlockedParameter is the error wrapped when a proposal to change a blocked parameter is submitted.

Functions

This section is empty.

Types

type ParamBlockList

type ParamBlockList struct {
	// contains filtered or unexported fields
}

ParamBlockList keeps track of parameters that cannot be changed by governance proposals

func NewParamBlockList

func NewParamBlockList(blockedParams ...[2]string) ParamBlockList

NewParamBlockList creates a new ParamBlockList that can be used to block gov proposals that attempt to change locked parameters.

func (ParamBlockList) GovHandler

func (pbl ParamBlockList) GovHandler(pk paramskeeper.Keeper) govtypes.Handler

GovHandler creates a new governance Handler for a ParamChangeProposal using the underlying ParamBlockList.

func (ParamBlockList) IsBlocked

func (pbl ParamBlockList) IsBlocked(subspace string, key string) bool

IsBlocked returns true if the given parameter is blocked.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL