From de691a98e62de26a48aa72568724afa6203ee51b Mon Sep 17 00:00:00 2001 From: MSalopek Date: Sat, 31 Aug 2024 18:18:31 +0200 Subject: [PATCH 1/3] fix(x/consensus)!: update cons params parsing checks (#21484) (cherry picked from commit f79b3802acc081463a8773e097056e6a6a66d36a) # Conflicts: # x/consensus/keeper/keeper.go --- x/consensus/keeper/keeper.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/x/consensus/keeper/keeper.go b/x/consensus/keeper/keeper.go index 50b5b2d93f6c..3ebb19ec2a3d 100644 --- a/x/consensus/keeper/keeper.go +++ b/x/consensus/keeper/keeper.go @@ -78,7 +78,41 @@ func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (* if err != nil { return nil, err } +<<<<<<< HEAD params := cmttypes.ConsensusParamsFromProto(paramsProto) +======= + + if err := k.ParamsStore.Set(ctx, nextParams.ToProto()); err != nil { + return nil, err + } + + if err := k.EventService.EventManager(ctx).EmitKV( + "update_consensus_params", + event.NewAttribute("authority", msg.Authority), + event.NewAttribute("parameters", consensusParams.String())); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} + +// paramCheck validates the consensus params +func (k Keeper) paramCheck(ctx context.Context, consensusParams cmtproto.ConsensusParams) (*cmttypes.ConsensusParams, error) { + var params cmttypes.ConsensusParams + + paramsProto, err := k.ParamsStore.Get(ctx) + if err == nil { + // initialize version params with zero value if not set + if paramsProto.Version == nil { + paramsProto.Version = &cmtproto.VersionParams{} + } + params = cmttypes.ConsensusParamsFromProto(paramsProto) + } else if errors.Is(err, collections.ErrNotFound) { + params = cmttypes.ConsensusParams{} + } else { + return nil, err + } +>>>>>>> f79b3802a (fix(x/consensus)!: update cons params parsing checks (#21484)) nextParams := params.Update(&consensusParams) From 71380b1c4becdbc33b9344be263d086064bbe962 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 2 Sep 2024 10:06:19 +0200 Subject: [PATCH 2/3] fixes --- CHANGELOG.md | 1 + x/consensus/keeper/keeper.go | 36 ++++-------------------------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ee41b033eb..383d00033017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (x/consensus) [#21493](https://github.com/cosmos/cosmos-sdk/pull/21493) Fix regression that prevented to upgrade to > v0.50.7 without consensus version params. * (baseapp) [#21256](https://github.com/cosmos/cosmos-sdk/pull/21256) Halt height will not commit the block indicated, meaning that if halt-height is set to 10, only blocks until 9 (included) will be committed. This is to go back to the original behavior before a change was introduced in v0.50.0. * (baseapp) [#21444](https://github.com/cosmos/cosmos-sdk/pull/21444) Follow-up, Return PreBlocker events in FinalizeBlockResponse. diff --git a/x/consensus/keeper/keeper.go b/x/consensus/keeper/keeper.go index 3ebb19ec2a3d..b239a9ee5ee7 100644 --- a/x/consensus/keeper/keeper.go +++ b/x/consensus/keeper/keeper.go @@ -78,41 +78,13 @@ func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (* if err != nil { return nil, err } -<<<<<<< HEAD - params := cmttypes.ConsensusParamsFromProto(paramsProto) -======= - - if err := k.ParamsStore.Set(ctx, nextParams.ToProto()); err != nil { - return nil, err - } - if err := k.EventService.EventManager(ctx).EmitKV( - "update_consensus_params", - event.NewAttribute("authority", msg.Authority), - event.NewAttribute("parameters", consensusParams.String())); err != nil { - return nil, err + // initialize version params with zero value if not set + if paramsProto.Version == nil { + paramsProto.Version = &cmtproto.VersionParams{} } - return &types.MsgUpdateParamsResponse{}, nil -} - -// paramCheck validates the consensus params -func (k Keeper) paramCheck(ctx context.Context, consensusParams cmtproto.ConsensusParams) (*cmttypes.ConsensusParams, error) { - var params cmttypes.ConsensusParams - - paramsProto, err := k.ParamsStore.Get(ctx) - if err == nil { - // initialize version params with zero value if not set - if paramsProto.Version == nil { - paramsProto.Version = &cmtproto.VersionParams{} - } - params = cmttypes.ConsensusParamsFromProto(paramsProto) - } else if errors.Is(err, collections.ErrNotFound) { - params = cmttypes.ConsensusParams{} - } else { - return nil, err - } ->>>>>>> f79b3802a (fix(x/consensus)!: update cons params parsing checks (#21484)) + params := cmttypes.ConsensusParamsFromProto(paramsProto) nextParams := params.Update(&consensusParams) From 12a55c69fe50318ce585025517ed3138fd24652f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 2 Sep 2024 10:19:00 +0200 Subject: [PATCH 3/3] fix docker compose --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f6f8b4f4f54d..181de584d26e 100644 --- a/Makefile +++ b/Makefile @@ -467,10 +467,10 @@ localnet-build-dlv: localnet-build-nodes: $(DOCKER) run --rm -v $(CURDIR)/.testnets:/data cosmossdk/simd \ testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test - docker-compose up -d + docker compose up -d localnet-stop: - docker-compose down + docker compose down # localnet-start will run a 4-node testnet locally. The nodes are # based off the docker images in: ./contrib/images/simd-env