Skip to content

Commit

Permalink
fix: add ConsensusParams upgrade and query (#84)
Browse files Browse the repository at this point in the history
* add consensus params fix

* chore: update test

Signed-off-by: Norman Meier <[email protected]>

* chore: update test in ci

Signed-off-by: Norman Meier <[email protected]>

* update comment for consensus params query cli

---------

Signed-off-by: Norman Meier <[email protected]>
Co-authored-by: Norman Meier <[email protected]>
  • Loading branch information
go7066 and n0izn0iz authored Jan 22, 2024
1 parent a4abd9d commit 0485022
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
repository: TERITORI/teritori-dapp
path: teritori-dapp
ref: 66134e9580135a07aba64e00b68af9f30f8fdb93
ref: 3a01c9753a19f39f5b399b9985f3a1d44ec81d23

- uses: actions/setup-go@v3
with:
Expand Down
10 changes: 10 additions & 0 deletions app/upgrades/v200/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/TERITORI/teritori-chain/app/keepers"
minttypes "github.com/TERITORI/teritori-chain/x/mint/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
Expand Down Expand Up @@ -72,6 +74,14 @@ func CreateUpgradeHandler(
v = reflect.Indirect(reflect.ValueOf(params.TotalBurntAmount)).Interface()
subspace.Set(ctx, minttypes.KeyTotalBurntAmount, v)

cp := tmtypes.DefaultConsensusParams().ToProto()
keepers.ConsensusParamsKeeper.Set(ctx, &tmproto.ConsensusParams{
Block: cp.Block,
Validator: cp.Validator,
Evidence: cp.Evidence,
Version: cp.Version,
})

return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion integration-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail
IFS=$'\n\t'
set -x

commit=66134e9580135a07aba64e00b68af9f30f8fdb93
commit=3a01c9753a19f39f5b399b9985f3a1d44ec81d23

if [[ -z "${TERITORI_DAPP_REPO:-}" ]]; then
rm -fr teritori-dapp
Expand Down
44 changes: 44 additions & 0 deletions x/mint/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package cli
import (
"context"
"fmt"
"strings"

"github.com/spf13/cobra"

"github.com/TERITORI/teritori-chain/x/mint/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
)

// GetQueryCmd returns the cli query commands for the minting module.
Expand All @@ -27,6 +30,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryBlockProvisions(),
GetCmdQueryInflation(),
GetCmdQueryStakingAPR(),
GetConsensusParamsCmd(),
)

return mintingQueryCmd
Expand Down Expand Up @@ -143,3 +147,43 @@ func GetCmdQueryStakingAPR() *cobra.Command {
flags.AddQueryFlagsToCmd(cmd)
return cmd
}

func GetConsensusParamsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "consensus-params",
Short: "Query consensus params",
Long: strings.TrimSpace(
fmt.Sprintf(`Query consensus params.
Example:
$ %s query %s consensus-params
`,
version.AppName, types.ModuleName,
),
),
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := consensustypes.NewQueryClient(clientCtx)

ctx := cmd.Context()

params := consensustypes.QueryParamsRequest{}

res, err := queryClient.Params(ctx, &params)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

0 comments on commit 0485022

Please sign in to comment.