From e30a55ac1d17f12da801d88500ad114916fe1fa8 Mon Sep 17 00:00:00 2001 From: Leo <52782564+LeoGuo621@users.noreply.github.com> Date: Fri, 2 Jun 2023 13:59:31 +0800 Subject: [PATCH] UpdateTxCount only when there is cosmos tx in block & fix vmbridge smb (#164) * support concurrency of wasm tx oktc pr#3117 double commit * Update app_test.go rewrite ut * add MercuryHeight * add init * MercuryHeight isolation * fix ut * UpdateTxCount only when there is cosmos tx in block & fix vmbridge smb --------- Co-authored-by: KamiD <44460798+KamiD@users.noreply.github.com> Co-authored-by: chengzhinei --- libs/cosmos-sdk/baseapp/baseapp_parallel.go | 10 +++++++++- x/wasm/types/types.go | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/cosmos-sdk/baseapp/baseapp_parallel.go b/libs/cosmos-sdk/baseapp/baseapp_parallel.go index 5cbd9ac9d..5b2181933 100644 --- a/libs/cosmos-sdk/baseapp/baseapp_parallel.go +++ b/libs/cosmos-sdk/baseapp/baseapp_parallel.go @@ -137,6 +137,11 @@ func (app *BaseApp) calGroup() { app.parallelTxManage.putResult(index, &executeResult{paraMsg: &sdk.ParaMsg{}, msIsNil: true}) } + if !tx.isEvm && tx.supportPara { + // means wasm tx + para.haveCosmosTxInBlock = true + } + if !tx.isEvm { para.txByteMpCosmosIndex[string(para.txs[index])] = para.cosmosTxIndexInBlock para.cosmosTxIndexInBlock++ @@ -300,7 +305,10 @@ func (app *BaseApp) runTxs() []*abci.ResponseDeliverTx { ctx, _ := app.cacheTxContext(app.getContextForTx(runTxModeDeliver, []byte{}), []byte{}) ctx.SetMultiStore(app.parallelTxManage.cms) - app.updateCosmosTxCount(ctx, app.parallelTxManage.cosmosTxIndexInBlock-1) + if app.parallelTxManage.haveCosmosTxInBlock { + app.updateCosmosTxCount(ctx, app.parallelTxManage.cosmosTxIndexInBlock-1) + } + for index, v := range receiptsLogs { if len(v) != 0 { // only update evm tx result pm.deliverTxs[index].Data = v diff --git a/x/wasm/types/types.go b/x/wasm/types/types.go index cb0506af7..de18d7aea 100644 --- a/x/wasm/types/types.go +++ b/x/wasm/types/types.go @@ -11,6 +11,7 @@ import ( codectypes "github.com/okx/okbchain/libs/cosmos-sdk/codec/types" sdk "github.com/okx/okbchain/libs/cosmos-sdk/types" sdkerrors "github.com/okx/okbchain/libs/cosmos-sdk/types/errors" + "github.com/okx/okbchain/libs/tendermint/types" ) const ( @@ -281,6 +282,10 @@ func NewEnv(ctx sdk.Context, contractAddr sdk.WasmAddress) wasmvmtypes.Env { } else { if txCounter, ok := TXCounter(ctx); ok { env.Transaction = &wasmvmtypes.TransactionInfo{Index: txCounter} + } else if types.HigherThanMercury(ctx.BlockHeight()) { + // fix smb caused by vm-bridge tx + // more detail see https://github.com/okx/oec/issues/2190 + env.Transaction = &wasmvmtypes.TransactionInfo{Index: 0} } } return env