From 16651d6002084693f3c6e99de6bec8113c94650a Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Tue, 14 Jan 2025 14:09:58 +0300 Subject: [PATCH 1/2] fix(x/simulation): finalize block after operations --- x/simulation/simulate.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 3cd8c5c4f66e..dce5a4f44eda 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -202,11 +202,6 @@ func SimulateFromSeedX( // Run the BeginBlock handler logWriter.AddEntry(BeginBlockEntry(blockTime, blockHeight)) - res, err := app.FinalizeBlock(finalizeBlockReq) - if err != nil { - return params, accs, fmt.Errorf("block finalization failed at height %d: %w", blockHeight, err) - } - ctx := app.NewContextLegacy(false, cmtproto.Header{ Height: blockHeight, Time: blockTime, @@ -260,6 +255,11 @@ func SimulateFromSeedX( break } + res, err := app.FinalizeBlock(finalizeBlockReq) + if err != nil { + return params, accs, fmt.Errorf("block finalization failed at height %d: %w", blockHeight, err) + } + // Generate a random RequestBeginBlock with the current validator set // for the next block finalizeBlockReq = RandomRequestFinalizeBlock(r, params, validators, pastTimes, pastVoteInfos, eventStats.Tally, blockHeight, blockTime, proposerAddress) @@ -278,6 +278,7 @@ func SimulateFromSeedX( exportedParams = params } } + logger.Info("Simulation complete", "height", blockHeight, "block-time", blockTime, "opsCount", opCount, "run-time", time.Since(startTime), "app-hash", hex.EncodeToString(app.LastCommitID().Hash)) From 8bbf320aef2ac118583d9c36b12381e932f2f94e Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Mon, 20 Jan 2025 12:24:50 +0300 Subject: [PATCH 2/2] chore(x/simulation): changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9aaa3e584459..bf6772ef623f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (x/auth/tx) [#23170](https://github.com/cosmos/cosmos-sdk/pull/23170) Avoid panic from newWrapperFromDecodedTx when AuthInfo.Fee is optional in decodedTx. * (x/auth/tx) [23144](https://github.com/cosmos/cosmos-sdk/pull/23144) Add missing CacheWithValue for ExtensionOptions. * (x/auth/tx) [#23148](https://github.com/cosmos/cosmos-sdk/pull/23148) Avoid panic from intoAnyV2 when v1.PublicKey is optional. +* (x/simulation) [#23382](https://github.com/cosmos/cosmos-sdk/pull/23382) Finalize block after queued operations. ### API Breaking Changes