From 624fe4a027e97eef4fd0e9209339b5da37d7e31a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:16:30 +0200 Subject: [PATCH] fix(baseapp)!: Halt at height now does not produce the halt height block (backport #21256) (#21323) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Facundo --- CHANGELOG.md | 4 ++++ baseapp/abci.go | 4 ++-- baseapp/abci_test.go | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac62854b440a..dd73d04d79d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (cli) [#20779](https://github.com/cosmos/cosmos-sdk/pull/20779) Added `module-hash-by-height` command to query and retrieve module hashes at a specified blockchain height, enhancing debugging capabilities. +### Bug Fixes + +* (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. + ## [v0.50.9](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.9) - 2024-08-07 ## Bug Fixes diff --git a/baseapp/abci.go b/baseapp/abci.go index edfab76ef0c3..cb924e271e9b 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -896,10 +896,10 @@ func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (res *abci.Res func (app *BaseApp) checkHalt(height int64, time time.Time) error { var halt bool switch { - case app.haltHeight > 0 && uint64(height) > app.haltHeight: + case app.haltHeight > 0 && uint64(height) >= app.haltHeight: halt = true - case app.haltTime > 0 && time.Unix() > int64(app.haltTime): + case app.haltTime > 0 && time.Unix() >= int64(app.haltTime): halt = true } diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index 3c67385dfa67..d57a98a801b0 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -1988,9 +1988,11 @@ func TestABCI_HaltChain(t *testing.T) { expHalt bool }{ {"default", 0, 0, 10, 0, false}, - {"halt-height-edge", 10, 0, 10, 0, false}, - {"halt-height", 10, 0, 11, 0, true}, - {"halt-time-edge", 0, 10, 1, 10, false}, + {"halt-height-edge", 11, 0, 10, 0, false}, + {"halt-height-equal", 10, 0, 10, 0, true}, + {"halt-height", 10, 0, 10, 0, true}, + {"halt-time-edge", 0, 11, 1, 10, false}, + {"halt-time-equal", 0, 10, 1, 10, true}, {"halt-time", 0, 10, 1, 11, true}, }