Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fungible): use PostTxProcessing in EVM call #1373

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions testutil/keeper/mocks/fungible/evm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions x/fungible/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,24 @@ func (k Keeper) CallEVMWithData(
if err != nil {
return nil, err
}
logs := evmtypes.LogsToEthereum(res.Logs)

if res.Failed() {
return res, cosmoserrors.Wrap(evmtypes.ErrVMExecution, fmt.Sprintf("%s: ret 0x%x", res.VmError, res.Ret))
}

// Emit events and log for the transaction if it is committed
// call PostTxProcessing hook
receipt := &ethtypes.Receipt{
Logs: logs,
TxHash: common.HexToHash(res.Hash),
}
if err = k.evmKeeper.PostTxProcessing(ctx, msg, receipt); err != nil {
// if post-processing return error, revert the whole tx
k.Logger(ctx).Error("tx post processing failed", "error", err)
return nil, cosmoserrors.Wrap(evmtypes.ErrPostTxProcessing, err.Error())
}

// emit events and log for the transaction if it is committed
if commit {
msgBytes, err := json.Marshal(msg)
if err != nil {
Expand Down Expand Up @@ -715,7 +727,6 @@ func (k Keeper) CallEVMWithData(
})
}

logs := evmtypes.LogsToEthereum(res.Logs)
var bloomReceipt ethtypes.Bloom
if len(logs) > 0 {
bloom := k.evmKeeper.GetBlockBloomTransient(ctx)
Expand Down
3 changes: 3 additions & 0 deletions x/fungible/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"math/big"

ethtypes "github.com/ethereum/go-ethereum/core/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -67,4 +69,5 @@ type EVMKeeper interface {
) (*evmtypes.MsgEthereumTxResponse, error)
GetAccount(ctx sdk.Context, addr ethcommon.Address) *statedb.Account
SetAccount(ctx sdk.Context, addr ethcommon.Address, account statedb.Account) error
PostTxProcessing(ctx sdk.Context, _ core.Message, receipt *ethtypes.Receipt) error
}
Loading