Skip to content

Commit

Permalink
UpdateTxCount only when there is cosmos tx in block & fix vmbridge smb (
Browse files Browse the repository at this point in the history
#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 <[email protected]>
Co-authored-by: chengzhinei <[email protected]>
  • Loading branch information
3 people authored Jun 2, 2023
1 parent 3dd4d46 commit e30a55a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libs/cosmos-sdk/baseapp/baseapp_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions x/wasm/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e30a55a

Please sign in to comment.