Sync from fork #74
@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
### API Breaking
|
### API Breaking
|
||||||
|
|
||||||
|
* (evm) [tharsis#1027](https://github.com/tharsis/ethermint/pull/1027) Change the `PostTxProcessing` hook interface to include the full message data.
|
||||||
* (feemarket) [tharsis#1026](https://github.com/tharsis/ethermint/pull/1026) Fix REST endpoints to use `/ethermint/feemarket/*` instead of `/feemarket/evm/*`.
|
* (feemarket) [tharsis#1026](https://github.com/tharsis/ethermint/pull/1026) Fix REST endpoints to use `/ethermint/feemarket/*` instead of `/feemarket/evm/*`.
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@ -679,13 +680,13 @@ func (suite *EvmTestSuite) TestContractDeploymentRevert() {
|
|||||||
// DummyHook implements EvmHooks interface
|
// DummyHook implements EvmHooks interface
|
||||||
type DummyHook struct{}
|
type DummyHook struct{}
|
||||||
|
|
||||||
func (dh *DummyHook) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (dh *DummyHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FailureHook implements EvmHooks interface
|
// FailureHook implements EvmHooks interface
|
||||||
type FailureHook struct{}
|
type FailureHook struct{}
|
||||||
|
|
||||||
func (dh *FailureHook) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (dh *FailureHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
return errors.New("mock error")
|
return errors.New("mock error")
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package keeper
|
|||||||
import (
|
import (
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/core"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/tharsis/ethermint/x/evm/types"
|
"github.com/tharsis/ethermint/x/evm/types"
|
||||||
)
|
)
|
||||||
@ -19,9 +19,9 @@ func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PostTxProcessing delegate the call to underlying hooks
|
// PostTxProcessing delegate the call to underlying hooks
|
||||||
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
for i := range mh {
|
for i := range mh {
|
||||||
if err := mh[i].PostTxProcessing(ctx, from, to, receipt); err != nil {
|
if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil {
|
||||||
return sdkerrors.Wrapf(err, "EVM hook %T failed", mh[i])
|
return sdkerrors.Wrapf(err, "EVM hook %T failed", mh[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"github.com/tharsis/ethermint/x/evm/keeper"
|
"github.com/tharsis/ethermint/x/evm/keeper"
|
||||||
@ -18,7 +19,7 @@ type LogRecordHook struct {
|
|||||||
Logs []*ethtypes.Log
|
Logs []*ethtypes.Log
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dh *LogRecordHook) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (dh *LogRecordHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
dh.Logs = receipt.Logs
|
dh.Logs = receipt.Logs
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ func (dh *LogRecordHook) PostTxProcessing(ctx sdk.Context, from common.Address,
|
|||||||
// FailureHook always fail
|
// FailureHook always fail
|
||||||
type FailureHook struct{}
|
type FailureHook struct{}
|
||||||
|
|
||||||
func (dh FailureHook) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (dh FailureHook) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
return errors.New("post tx processing failed")
|
return errors.New("post tx processing failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
|
|||||||
TxHash: txHash,
|
TxHash: txHash,
|
||||||
Logs: logs,
|
Logs: logs,
|
||||||
}
|
}
|
||||||
result := k.PostTxProcessing(ctx, common.Address{}, nil, receipt)
|
result := k.PostTxProcessing(ctx, ethtypes.Message{}, receipt)
|
||||||
|
|
||||||
tc.expFunc(hook, result)
|
tc.expFunc(hook, result)
|
||||||
}
|
}
|
||||||
|
@ -221,11 +221,11 @@ func (k *Keeper) SetHooks(eh types.EvmHooks) *Keeper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PostTxProcessing delegate the call to the hooks. If no hook has been registered, this function returns with a `nil` error
|
// PostTxProcessing delegate the call to the hooks. If no hook has been registered, this function returns with a `nil` error
|
||||||
func (k *Keeper) PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error {
|
func (k *Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
|
||||||
if k.hooks == nil {
|
if k.hooks == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return k.hooks.PostTxProcessing(ctx, from, to, receipt)
|
return k.hooks.PostTxProcessing(ctx, msg, receipt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tracer return a default vm.Tracer based on current keeper state
|
// Tracer return a default vm.Tracer based on current keeper state
|
||||||
|
@ -264,7 +264,7 @@ func (k *Keeper) ApplyTransaction(ctx sdk.Context, tx *ethtypes.Transaction) (*t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only call hooks if tx executed successfully.
|
// Only call hooks if tx executed successfully.
|
||||||
if err = k.PostTxProcessing(tmpCtx, msg.From(), tx.To(), receipt); err != nil {
|
if err = k.PostTxProcessing(tmpCtx, msg, receipt); err != nil {
|
||||||
// If hooks return error, revert the whole tx.
|
// If hooks return error, revert the whole tx.
|
||||||
res.VmError = types.ErrPostTxProcessing.Error()
|
res.VmError = types.ErrPostTxProcessing.Error()
|
||||||
k.Logger(ctx).Error("tx post processing failed", "error", err)
|
k.Logger(ctx).Error("tx post processing failed", "error", err)
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||||
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
||||||
)
|
)
|
||||||
@ -53,5 +53,5 @@ type FeeMarketKeeper interface {
|
|||||||
// EvmHooks event hooks for evm tx processing
|
// EvmHooks event hooks for evm tx processing
|
||||||
type EvmHooks interface {
|
type EvmHooks interface {
|
||||||
// Must be called after tx is processed successfully, if return an error, the whole transaction is reverted.
|
// Must be called after tx is processed successfully, if return an error, the whole transaction is reverted.
|
||||||
PostTxProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) error
|
PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user