From ce55ced719c4da9935f7de71c0e27500e33daefc Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:52:41 +0000 Subject: [PATCH] fix(baseapp)!: Halt at height now does not produce the halt height block (backport #21256) (#21322) Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Julien Robert --- baseapp/abci.go | 4 ++-- baseapp/abci_test.go | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/baseapp/abci.go b/baseapp/abci.go index d2d87a5cf562..49470e0af771 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -914,10 +914,10 @@ func (app *BaseApp) FinalizeBlock(req *abci.FinalizeBlockRequest) (res *abci.Fin 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 f935da1b318e..8183c454dca9 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -2021,9 +2021,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}, }