From 28b120c5166e862f2671f1e1d70af4b023577c76 Mon Sep 17 00:00:00 2001 From: ylsGit Date: Tue, 24 May 2022 22:38:37 +0800 Subject: [PATCH] Merge PR: fix innertx (#2094) --- x/evm/txs/base/base.go | 10 +++------- x/evm/txs/deliver/deliver.go | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/x/evm/txs/base/base.go b/x/evm/txs/base/base.go index 7df8147a43..74eb95f993 100644 --- a/x/evm/txs/base/base.go +++ b/x/evm/txs/base/base.go @@ -1,13 +1,14 @@ package base import ( + "math/big" + bam "github.com/okex/exchain/libs/cosmos-sdk/baseapp" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" authexported "github.com/okex/exchain/libs/cosmos-sdk/x/auth/exported" "github.com/okex/exchain/x/common/analyzer" "github.com/okex/exchain/x/evm/keeper" "github.com/okex/exchain/x/evm/types" - "math/big" ) // Keeper alias of keeper.Keeper, to solve import circle. also evm.Keeper is alias keeper.Keeper @@ -52,12 +53,7 @@ func (tx *Tx) GetChainConfig() (types.ChainConfig, bool) { // Transition execute evm tx func (tx *Tx) Transition(config types.ChainConfig) (result Result, err error) { result.ExecResult, result.ResultData, err, result.InnerTxs, result.Erc20Contracts = tx.StateTransition.TransitionDb(tx.Ctx, config) - if result.InnerTxs != nil { - tx.Keeper.AddInnerTx(tx.StateTransition.TxHash.Hex(), result.InnerTxs) - } - if result.Erc20Contracts != nil { - tx.Keeper.AddContract(result.Erc20Contracts) - } + // async mod goes immediately if tx.Ctx.IsAsync() { tx.Keeper.LogsManages.Set(string(tx.Ctx.TxBytes()), keeper.TxResult{ diff --git a/x/evm/txs/deliver/deliver.go b/x/evm/txs/deliver/deliver.go index 20e8837b97..6cf2445312 100644 --- a/x/evm/txs/deliver/deliver.go +++ b/x/evm/txs/deliver/deliver.go @@ -1,6 +1,8 @@ package deliver import ( + "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/okex/exchain/app/refund" bam "github.com/okex/exchain/libs/cosmos-sdk/baseapp" @@ -9,7 +11,6 @@ import ( "github.com/okex/exchain/x/evm/txs/base" "github.com/okex/exchain/x/evm/types" "github.com/okex/exchain/x/evm/watcher" - "math/big" ) type Tx struct { @@ -74,6 +75,19 @@ func (tx *Tx) RestoreWatcherTransactionReceipt(msg *types.MsgEthereumTx) { &types.ResultData{}, tx.Ctx.GasMeter().GasConsumed()) } +func (tx *Tx) Transition(config types.ChainConfig) (result base.Result, err error) { + result, err = tx.Tx.Transition(config) + + if result.InnerTxs != nil { + tx.Keeper.AddInnerTx(tx.StateTransition.TxHash.Hex(), result.InnerTxs) + } + if result.Erc20Contracts != nil { + tx.Keeper.AddContract(result.Erc20Contracts) + } + + return +} + func (tx *Tx) Commit(msg *types.MsgEthereumTx, result *base.Result) { // update block bloom filter if !tx.Ctx.IsAsync() {