diff --git a/app/upgrades.go b/app/upgrades.go index 015c1338c..b3c83c5ba 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -12,6 +12,7 @@ import ( var allUpgrades = []upgrades.Upgrade{ upgrades.Upgrade_0_0_4, upgrades.Upgrade_v0_0_9_2, + upgrades.Upgrade_v0_0_9_3, } // setUpgrades sets upgrade handlers for all upgrades and executes KVStore migration if an upgrade plan file exists. diff --git a/app/upgrades/v0.0.9-2.go b/app/upgrades/v0.0.9.go similarity index 55% rename from app/upgrades/v0.0.9-2.go rename to app/upgrades/v0.0.9.go index 33f195af3..5faac18bd 100644 --- a/app/upgrades/v0.0.9-2.go +++ b/app/upgrades/v0.0.9.go @@ -9,3 +9,11 @@ var Upgrade_v0_0_9_2 = Upgrade{ CreateUpgradeHandler: defaultUpgradeHandler, StoreUpgrades: storetypes.StoreUpgrades{}, } + +// Upgrade_v0_0_9_2 is an upgrade on Beta TestNet. +var Upgrade_v0_0_9_3 = Upgrade{ + // the transaction needs to have a plan with the same name. + PlanName: "v0.0.9-3", + CreateUpgradeHandler: defaultUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{}, +} diff --git a/tools/scripts/upgrades/authz_upgrade_tx_example_v0.0.9-2.json b/tools/scripts/upgrades/authz_upgrade_tx_example_v0.0.9-2.json new file mode 100644 index 000000000..307716546 --- /dev/null +++ b/tools/scripts/upgrades/authz_upgrade_tx_example_v0.0.9-2.json @@ -0,0 +1,15 @@ +{ + "body": { + "messages": [ + { + "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "plan": { + "name": "v0.0.9-2", + "height": "17102", + "info": "{\"binaries\":{\"linux\/amd64\":\"https:\/\/github.com\/pokt-network\/poktroll\/releases\/download\/v0.0.9-2\/poktroll_linux_amd64.tar.gz?checksum=sha256:bbef89b677fa6ee92afa4b93421653b093f0e679ee890f3f6d0fce9b11b11cd3\",\"linux\/arm64\":\"https:\/\/github.com\/pokt-network\/poktroll\/releases\/download\/v0.0.9-2\/poktroll_linux_arm64.tar.gz?checksum=sha256:d5dadb7c5d50493ba7717ec29785b074d4d76ce167e3eb54c183829d3560cc70\",\"darwin\/amd64\":\"https:\/\/github.com\/pokt-network\/poktroll\/releases\/download\/v0.0.9-2\/poktroll_darwin_amd64.tar.gz?checksum=sha256:d0134c208bf85cf4992461a4e3b56557c178edc745e0ae677b8548abf9f56cbb\",\"darwin\/arm64\":\"https:\/\/github.com\/pokt-network\/poktroll\/releases\/download\/v0.0.9-2\/poktroll_darwin_arm64.tar.gz?checksum=sha256:0c7e025cd91e054cd2d95833c339c3875927eb8474142eb61ab21f6bfa648442\"}}" + } + } + ] + } +} \ No newline at end of file diff --git a/tools/scripts/upgrades/local_test_v0.0.9-2.json b/tools/scripts/upgrades/local_test_v0.0.9-2.json new file mode 100644 index 000000000..63f576851 --- /dev/null +++ b/tools/scripts/upgrades/local_test_v0.0.9-2.json @@ -0,0 +1,15 @@ +{ + "body": { + "messages": [ + { + "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", + "authority": "pokt10d07y265gmmuvt4z0w9aw880jnsr700j8yv32t", + "plan": { + "name": "v0.0.9-2", + "height": "50", + "info": "NOT NEEDED FOR LOCAL TESTING" + } + } + ] + } + } \ No newline at end of file diff --git a/x/tokenomics/keeper/migrations.go b/x/tokenomics/keeper/migrations.go new file mode 100644 index 000000000..253c30d6e --- /dev/null +++ b/x/tokenomics/keeper/migrations.go @@ -0,0 +1,21 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + v2 "github.com/pokt-network/poktroll/x/tokenomics/migrations/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.keeper.storeService, m.keeper.cdc) +} diff --git a/x/tokenomics/migrations/v2/migration.go b/x/tokenomics/migrations/v2/migration.go new file mode 100644 index 000000000..70f6f739c --- /dev/null +++ b/x/tokenomics/migrations/v2/migration.go @@ -0,0 +1,15 @@ +package v2 + +import ( + "context" + "fmt" + + corestoretypes "cosmossdk.io/core/store" + "github.com/cosmos/cosmos-sdk/codec" +) + +// MigrateStore - NOOP migration to upgrade the consensus version. +func MigrateStore(ctx context.Context, storeService corestoretypes.KVStoreService, cdc codec.BinaryCodec) error { + fmt.Println("Would migrate the store here, but not doing anything - we don't have anything to migrate.") + return nil +} diff --git a/x/tokenomics/module/module.go b/x/tokenomics/module/module.go index d6c79ce91..a0aec7fd6 100644 --- a/x/tokenomics/module/module.go +++ b/x/tokenomics/module/module.go @@ -3,6 +3,7 @@ package tokenomics import ( "context" "encoding/json" + "fmt" // this line is used by starport scaffolding # 1 @@ -120,6 +121,12 @@ func NewAppModule( func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.tokenomicsKeeper)) types.RegisterQueryServer(cfg.QueryServer(), am.tokenomicsKeeper) + + m := keeper.NewMigrator(am.tokenomicsKeeper) + err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) + if err != nil { + panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err)) + } } // RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) @@ -143,7 +150,11 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion is a sequence number for state-breaking change of the module. // It should be incremented on each consensus-breaking change introduced by the module. // To avoid wrong/empty versions, the initial version should be set to 1. -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { + // Bumping the `ConsensusVersion` to see if it will allow to rollback and fork the network when + // there are other full-nodes gossiping the blocks signed by the same validator. + return 2 +} // BeginBlock contains the logic that is automatically triggered at the beginning of each block. // The begin block implementation is optional.