From 6a5158fe29e2d0491e9d4d439684f49db28f357e Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 1 Mar 2024 21:41:10 +0800 Subject: [PATCH 1/3] fix: tx context gas meter is shared at the beginning ref: #19613 Before the ante handler set the gas meter using tx gas-wanted, the gas meter in ctx remains a globally shared one, although it don't have bad effect right now, but it's a race condition when executing in parallel. --- baseapp/baseapp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7f7ef4ac5279..44bbaa917250 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -668,7 +668,8 @@ func (app *BaseApp) getContextForTx(mode execMode, txBytes []byte) sdk.Context { panic(fmt.Sprintf("state is nil for mode %v", mode)) } ctx := modeState.Context(). - WithTxBytes(txBytes) + WithTxBytes(txBytes). + WithGasMeter(storetypes.NewInfiniteGasMeter()) // WithVoteInfos(app.voteInfos) // TODO: identify if this is needed ctx = ctx.WithIsSigverifyTx(app.sigverifyTx) From 52e3e9b44e88531760fd87bf175c5ccf388a396f Mon Sep 17 00:00:00 2001 From: yihuang Date: Sun, 3 Mar 2024 14:04:24 +0800 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9939c7bd8d..8dedc9a75c23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test. * (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT * (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object +* (server) [#19616](https://github.com/cosmos/cosmos-sdk/pull/19616) Fix shared gas meter at the beginning of tx execution. ### API Breaking Changes From 45dfe41b110f2ed9331b34682e42d28b8285c763 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 20 Mar 2024 10:46:16 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd09debfbede..673a71dc3686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,7 +94,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test. * (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT * (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object -* (server) [#19616](https://github.com/cosmos/cosmos-sdk/pull/19616) Fix shared gas meter at the beginning of tx execution. +* (baseapp) [#19616](https://github.com/cosmos/cosmos-sdk/pull/19616) Fix shared gas meter at the beginning of tx execution. ### API Breaking Changes