Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(x/simulation): finalize block after operations #23382

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Bug Fixes

* (x/simulation) [#23382](https://github.com/cosmos/cosmos-sdk/pull/23382) Finalize block after queued operations.

### API Breaking Changes

* (x/params) [#22995](https://github.com/cosmos/cosmos-sdk/pull/22995) Remove `x/params`. Migrate to the new params system introduced in `v0.47` as demonstrated [here](https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#xparams).
Expand Down
11 changes: 6 additions & 5 deletions x/simulation/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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))

Expand Down
Loading