Skip to content

Commit

Permalink
fix!: add missing gov v5 migration section (#3369)
Browse files Browse the repository at this point in the history
* fix!: add missing gov v5 migration section

* appease linters

* update docs for localnet forks
  • Loading branch information
MSalopek authored Oct 3, 2024
1 parent 7f16da6 commit c919fd2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/upgrades/v21/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"

"github.com/cosmos/gaia/v21/app/keepers"
)
Expand All @@ -25,7 +26,18 @@ func CreateUpgradeHandler(
return vm, err
}

err = InitializeConstitutionCollection(ctx, *keepers.GovKeeper)
if err != nil {
ctx.Logger().Error("Error initializing Constitution Collection:", "message", err.Error())
}

ctx.Logger().Info("Upgrade v21 complete")
return vm, nil
}
}

// setting the default constitution for the chain
// this is in line with cosmos-sdk v5 gov migration: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/gov/migrations/v5/store.go#L57
func InitializeConstitutionCollection(ctx sdk.Context, govKeeper govkeeper.Keeper) error {
return govKeeper.Constitution.Set(ctx, "This chain has no constitution.")
}
28 changes: 28 additions & 0 deletions app/upgrades/v21/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package v21_test

import (
"testing"

"github.com/stretchr/testify/require"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/gaia/v21/app/helpers"
v21 "github.com/cosmos/gaia/v21/app/upgrades/v21"
)

func TestInitializeConstitutionCollection(t *testing.T) {
gaiaApp := helpers.Setup(t)
ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{})

govKeeper := gaiaApp.GovKeeper

pre, err := govKeeper.Constitution.Get(ctx)
require.NoError(t, err)
require.Equal(t, "", pre)
err = v21.InitializeConstitutionCollection(ctx, *govKeeper)
require.NoError(t, err)
post, err := govKeeper.Constitution.Get(ctx)
require.NoError(t, err)
require.Equal(t, "This chain has no constitution.", post)
}
6 changes: 4 additions & 2 deletions cmd/gaiad/cmd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The command is added as a sub-command of the `gaiad testnet` command.
The gaia binary will contain the testnet extensions only if the `unsafe_start_local_validator` build tags is used.

```shell
make build BUILD_TAGS="-tag unsafe_start_local_validator"
make build BUILD_TAGS="unsafe_start_local_validator"
```

## CLI usage
Expand Down Expand Up @@ -45,7 +45,7 @@ gaiad keys parse $(gaiad keys parse $VAL_ACC_ADDR --output=json | jq .bytes -r)
}

# --validator-pubkey and --validator-privkey are in`$HOME/.gaia/config/priv_validator.json
cat $HOME/.gaia/config/priv_validator.json
cat $HOME/.gaia/config/priv_validator_key.json
{
"address": "067CC9545EC0CD744C44D611E3E8857D69E9CAD4",
"pub_key": {
Expand All @@ -59,6 +59,8 @@ cat $HOME/.gaia/config/priv_validator.json
}
```

You will also need to change your chain-id in `genesis.json` to match the chain-id of the network you are using in testing (e.g. `cosmoshub-4`).
This is because `gaiad init` creates a `genesis.json` with a testing chain id.

## Example usecase

Expand Down

0 comments on commit c919fd2

Please sign in to comment.