fix (sims): state written in sims loop (#20936)

This commit is contained in:
Alexander Peters 2024-07-12 17:17:23 +02:00 committed by GitHub
parent 10465a6aab
commit dc5c16b0be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -40,6 +40,12 @@ func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo,
return gasInfo, result, err
}
// SimWriteState is an entrypoint for simulations only. They are not executed during the normal ABCI finalize
// block step but later. Therefor an extra call to the root multi-store (app.cms) is required to write the changes.
func (app *BaseApp) SimWriteState() {
app.finalizeBlockState.ms.Write()
}
// NewContextLegacy returns a new sdk.Context with the provided header
func (app *BaseApp) NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context {
if isCheckTx {

View File

@ -246,6 +246,7 @@ func SimulateFromSeedX(
proposerAddress = validators.randomProposer(r)
if config.Commit {
app.SimWriteState()
if _, err := app.Commit(); err != nil {
return params, fmt.Errorf("commit failed at height %d: %w", blockHeight, err)
}