upgrades

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrade0_0_4 = Upgrade{
	UpgradeName: "v0.0.4",
	CreateUpgradeHandler: func(
		mm *module.Manager,
		configurator module.Configurator,
		keepers *keepers.Keepers,
	) upgradetypes.UpgradeHandler {
		return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {

			currentParams, err := keepers.ConsensusParamsKeeper.ParamsStore.Get(ctx)
			if err != nil {
				return vm, errors.Wrap(err, "failed to get consensus params")
			}

			newParams := consensusparamtypes.MsgUpdateParams{
				Authority: keepers.ConsensusParamsKeeper.GetAuthority(),
				Block:     currentParams.Block,
				Evidence:  currentParams.Evidence,
				Validator: currentParams.Validator,

				Abci: currentParams.Abci,
			}

			newParams.Block.MaxBytes = 22020096 * 2

			if _, err = keepers.ConsensusParamsKeeper.UpdateParams(ctx, &newParams); err != nil {
				return vm, errors.Wrap(err, "failed to update consensus params")
			}

			return mm.RunMigrations(ctx, configurator, vm)
		}
	},

	StoreUpgrades: storetypes.StoreUpgrades{},
}

Upgrade0_0_4 is an example of an upgrade that increases the block size. This example demonstrates how to change the block size using an upgrade.

View Source
var UpgradeExample = Upgrade{
	UpgradeName:          "v0.0.0-Example",
	CreateUpgradeHandler: defaultUpgradeHandler,

	StoreUpgrades: storetypes.StoreUpgrades{},
}

An example of an upgrade that uses the default upgrade handler and also performs additional state changes. For example, even if `ConsensusVersion` is not modified for any modules, it still might be beneficial to create an upgrade so node runners are signaled to start utilizing `Cosmovisor` for new binaries.

Functions

This section is empty.

Types

type Fork

type Fork struct {
	// Upgrade version name, for the upgrade handler, e.g. `v7`
	UpgradeName string
	// Height the upgrade occurs at.
	UpgradeHeight int64
	// Upgrade info for this fork.
	UpgradeInfo string
	// Function that runs some custom state transition code at the beginning of a fork.
	BeginForkLogic func(ctx sdk.Context, keepers *keepers.Keepers)
}

Fork defines a struct containing the requisite fields for a non-software upgrade proposal Hard Fork at a given height to implement.

type Upgrade

type Upgrade struct {
	// Upgrade version name, for the upgrade handler, e.g. `v7`
	UpgradeName string

	// CreateUpgradeHandler defines the function that creates an upgrade handler
	CreateUpgradeHandler func(*module.Manager, module.Configurator, *keepers.Keepers) upgradetypes.UpgradeHandler

	// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed.
	StoreUpgrades store.StoreUpgrades
}

Upgrade defines a struct containing necessary fields that a MsgSoftwareUpgrade must have written, in order for the state migration to go smoothly. An upgrade must implement this struct, and then set it in the app.go. The app.go will then define the handler.

Jump to

Keyboard shortcuts

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