From 16651d6002084693f3c6e99de6bec8113c94650a Mon Sep 17 00:00:00 2001 From: Eric Mokaya Date: Tue, 14 Jan 2025 14:09:58 +0300 Subject: [PATCH] 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))