Skip to content

Commit

Permalink
Improve Precompile Contract Interface
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Mar 19, 2024
1 parent 638be0d commit f6c748c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 27 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func NewEthermintApp(
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, nil,
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
nil, geth.NewEVM, tracer, evmSs,
)

Expand Down
8 changes: 0 additions & 8 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ type Keeper struct {
// fetch EIP1559 base fee and parameters
feeMarketKeeper types.FeeMarketKeeper

ibcTransferKeeper statedb.IBCTransferKeeper

// chain ID number obtained from the context's chain id
eip155ChainID *big.Int

Expand Down Expand Up @@ -93,7 +91,6 @@ func NewKeeper(
bankKeeper types.BankKeeper,
sk types.StakingKeeper,
fmk types.FeeMarketKeeper,
ibcTransferKeeper statedb.IBCTransferKeeper,
customPrecompiles evm.PrecompiledContracts,
evmConstructor evm.Constructor,
tracer string,
Expand Down Expand Up @@ -121,7 +118,6 @@ func NewKeeper(
bankKeeper: bankKeeper,
stakingKeeper: sk,
feeMarketKeeper: fmk,
ibcTransferKeeper: ibcTransferKeeper,
storeKey: storeKey,
transientKey: transientKey,
customPrecompiles: customPrecompiles,
Expand Down Expand Up @@ -404,7 +400,3 @@ func (k Keeper) AddTransientGasUsed(ctx sdk.Context, gasUsed uint64) (uint64, er
k.SetTransientGasUsed(ctx, result)
return result, nil
}

func (k Keeper) IBCTransferKeeper() statedb.IBCTransferKeeper {
return k.ibcTransferKeeper
}
8 changes: 0 additions & 8 deletions x/evm/statedb/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
package statedb

import (
"context"
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
)
Expand All @@ -35,10 +33,6 @@ type ExtStateDB interface {
AppendJournalEntry(JournalEntry)
}

type IBCTransferKeeper interface {
Transfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error)
}

// Keeper provide underlying storage of StateDB
type Keeper interface {
// Read methods
Expand All @@ -54,6 +48,4 @@ type Keeper interface {
SetCode(ctx sdk.Context, codeHash []byte, code []byte)
SetBalance(ctx sdk.Context, addr common.Address, amount *big.Int) error
DeleteAccount(ctx sdk.Context, addr common.Address) error

IBCTransferKeeper() IBCTransferKeeper
}
10 changes: 0 additions & 10 deletions x/evm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"math/big"

sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
Expand Down Expand Up @@ -472,12 +471,3 @@ func (s *StateDB) SetError(err error) {

s.sdkError = err
}

func (s *StateDB) IBCTransfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error) {
resp, err := s.keeper.IBCTransferKeeper().Transfer(goCtx, msg)
if err != nil {
return nil, err
}

return resp, nil
}

0 comments on commit f6c748c

Please sign in to comment.