Skip to content

Commit

Permalink
import evm feemarket and precompiles
Browse files Browse the repository at this point in the history
  • Loading branch information
MalteHerrmann committed Aug 13, 2024
1 parent b051d35 commit 408300c
Show file tree
Hide file tree
Showing 485 changed files with 119,816 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ante/cosmos/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/evmos/evmos/v19/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v19/x/evm/types"
feemarkettypes "github.com/evmos/evmos/v19/x/feemarket/types"
"github.com/evmos/os/ante"
evmante "github.com/evmos/os/ante/evm"
"github.com/evmos/os/crypto/ethsecp256k1"
Expand All @@ -33,6 +32,7 @@ import (
chaintestutil "github.com/evmos/os/example_chain/testutil"
"github.com/evmos/os/testutil"
"github.com/evmos/os/types"
feemarkettypes "github.com/evmos/os/x/feemarket/types"
)

type AnteTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/ethereum/go-ethereum/core/types"
evmtypes "github.com/evmos/evmos/v19/x/evm/types"
feemarkettypes "github.com/evmos/evmos/v19/x/feemarket/types"
evmosante "github.com/evmos/os/ante"
"github.com/evmos/os/encoding"
"github.com/evmos/os/ethereum/eip712"
app "github.com/evmos/os/example_chain"
chainante "github.com/evmos/os/example_chain/ante"
"github.com/evmos/os/testutil"
feemarkettypes "github.com/evmos/os/x/feemarket/types"
)

type AnteTestSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion ante/interfaces/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/evmos/evmos/v19/x/evm/statedb"
evmtypes "github.com/evmos/evmos/v19/x/evm/types"
feemarkettypes "github.com/evmos/evmos/v19/x/feemarket/types"
feemarkettypes "github.com/evmos/os/x/feemarket/types"
)

// EVMKeeper exposes the required EVM keeper interface required for ante handlers
Expand Down
6 changes: 3 additions & 3 deletions example_chain/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ import (
"github.com/evmos/evmos/v19/x/evm/core/vm"
evmkeeper "github.com/evmos/evmos/v19/x/evm/keeper"
evmtypes "github.com/evmos/evmos/v19/x/evm/types"
"github.com/evmos/evmos/v19/x/feemarket"
feemarketkeeper "github.com/evmos/evmos/v19/x/feemarket/keeper"
feemarkettypes "github.com/evmos/evmos/v19/x/feemarket/types"
evmosante "github.com/evmos/os/ante"
evmosevmante "github.com/evmos/os/ante/evm"
evmosencoding "github.com/evmos/os/encoding"
Expand All @@ -108,6 +105,9 @@ import (
srvflags "github.com/evmos/os/server/flags"
evmostypes "github.com/evmos/os/types"
evmosutils "github.com/evmos/os/utils"
"github.com/evmos/os/x/feemarket"
feemarketkeeper "github.com/evmos/os/x/feemarket/keeper"
feemarkettypes "github.com/evmos/os/x/feemarket/types"
"github.com/spf13/cast"
)

Expand Down
20 changes: 10 additions & 10 deletions example_chain/testutil/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"

evm "github.com/evmos/evmos/v19/x/evm/types"
app "github.com/evmos/os/example_chain"
example_app "github.com/evmos/os/example_chain"
"github.com/evmos/os/testutil/tx"
evm "github.com/evmos/os/x/evm/types"
)

// ContractArgs are the params used for calling a smart contract.
Expand All @@ -42,7 +42,7 @@ type ContractCallArgs struct {
Contract ContractArgs
// Nonce is the nonce to use for the transaction.
Nonce *big.Int
// Amount is the aevmos amount to send in the transaction.
// Amount is the amount of the native denomination to send in the transaction.
Amount *big.Int
// GasLimit to use for the transaction
GasLimit uint64
Expand All @@ -54,7 +54,7 @@ type ContractCallArgs struct {
// compiled contract data and constructor arguments
func DeployContract(
ctx sdk.Context,
app *app.ExampleChain,
app *example_app.ExampleChain,
priv cryptotypes.PrivKey,
queryClientEvm evm.QueryClient,
contract evm.CompiledContract,
Expand Down Expand Up @@ -102,14 +102,14 @@ func DeployContract(
// with the provided factoryAddress
func DeployContractWithFactory(
ctx sdk.Context,
evmosApp *app.ExampleChain,
exampleApp *example_app.ExampleChain,
priv cryptotypes.PrivKey,
factoryAddress common.Address,
) (common.Address, abci.ResponseDeliverTx, error) {
chainID := evmosApp.EVMKeeper.ChainID()
chainID := exampleApp.EVMKeeper.ChainID()
from := common.BytesToAddress(priv.PubKey().Address().Bytes())
factoryNonce := evmosApp.EVMKeeper.GetNonce(ctx, factoryAddress)
nonce := evmosApp.EVMKeeper.GetNonce(ctx, from)
factoryNonce := exampleApp.EVMKeeper.GetNonce(ctx, factoryAddress)
nonce := exampleApp.EVMKeeper.GetNonce(ctx, from)

msgEthereumTx := evm.NewTx(&evm.EvmTxArgs{
ChainID: chainID,
Expand All @@ -120,12 +120,12 @@ func DeployContractWithFactory(
})
msgEthereumTx.From = from.String()

res, err := DeliverEthTx(evmosApp, priv, msgEthereumTx)
res, err := DeliverEthTx(exampleApp, priv, msgEthereumTx)
if err != nil {
return common.Address{}, abci.ResponseDeliverTx{}, err
}

if _, err := CheckEthTxResponse(res, evmosApp.AppCodec()); err != nil {
if _, err := CheckEthTxResponse(res, exampleApp.AppCodec()); err != nil {
return common.Address{}, abci.ResponseDeliverTx{}, err
}

Expand Down
4 changes: 3 additions & 1 deletion example_chain/testutil/fund.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddr
}

// FundAccountWithBaseDenom is a utility function that uses the FundAccount function
// to fund an account with the default Evmos denomination.
// to fund an account with the default denomination.
//
// TODO: as per Freddy these methods should be replaced with a bank transfer from a main account, not by minting in the process
func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amount int64) error {
coins := sdk.NewCoins(
sdk.NewCoin(testutil.ExampleAttoDenom, math.NewInt(amount)),
Expand Down
11 changes: 11 additions & 0 deletions ibc/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)
package ibc

import "errors"

var (
ErrNoIBCVoucherDenom = errors.New("denom is not an IBC voucher")
ErrDenomTraceNotFound = errors.New("denom trace not found")
ErrInvalidBaseDenom = errors.New("invalid base denomination")
)
129 changes: 129 additions & 0 deletions ibc/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright Tharsis Labs Ltd.(Evmos)
// SPDX-License-Identifier:ENCL-1.0(https://github.com/evmos/evmos/blob/main/LICENSE)

package ibc

import (
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
)

var _ porttypes.IBCModule = &Module{}

// Module a concrete type for a module boilerplate.
type Module struct {
app porttypes.IBCModule
}

// NewModule creates a new IBC Module boilerplate given the underlying IBC app
func NewModule(app porttypes.IBCModule) *Module {
return &Module{
app: app,
}
}

// OnChanOpenInit implements the Module interface
// It calls the underlying app's OnChanOpenInit callback.
func (im Module) OnChanOpenInit(
ctx sdk.Context,
order channeltypes.Order,
connectionHops []string,
portID string,
channelID string,
chanCap *capabilitytypes.Capability,
counterparty channeltypes.Counterparty,
version string,
) (string, error) {
return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, version)
}

// OnChanOpenTry implements the Module interface.
// It calls the underlying app's OnChanOpenTry callback.
func (im Module) OnChanOpenTry(
ctx sdk.Context,
order channeltypes.Order,
connectionHops []string,
portID,
channelID string,
chanCap *capabilitytypes.Capability,
counterparty channeltypes.Counterparty,
counterpartyVersion string,
) (version string, err error) {
return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion)
}

// OnChanOpenAck implements the Module interface.
// It calls the underlying app's OnChanOpenAck callback.
func (im Module) OnChanOpenAck(
ctx sdk.Context,
portID,
channelID,
counterpartyChannelID,
counterpartyVersion string,
) error {
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion)
}

// OnChanOpenConfirm implements the Module interface.
// It calls the underlying app's OnChanOpenConfirm callback.
func (im Module) OnChanOpenConfirm(
ctx sdk.Context,
portID,
channelID string,
) error {
return im.app.OnChanOpenConfirm(ctx, portID, channelID)
}

// OnChanCloseInit implements the Module interface
// It calls the underlying app's OnChanCloseInit callback.
func (im Module) OnChanCloseInit(
ctx sdk.Context,
portID,
channelID string,
) error {
return im.app.OnChanCloseInit(ctx, portID, channelID)
}

// OnChanCloseConfirm implements the Module interface.
// It calls the underlying app's OnChanCloseConfirm callback.
func (im Module) OnChanCloseConfirm(
ctx sdk.Context,
portID,
channelID string,
) error {
return im.app.OnChanCloseConfirm(ctx, portID, channelID)
}

// OnRecvPacket implements the Module interface.
// It calls the underlying app's OnRecvPacket callback.
func (im Module) OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) exported.Acknowledgement {
return im.app.OnRecvPacket(ctx, packet, relayer)
}

// OnAcknowledgementPacket implements the Module interface.
// It calls the underlying app's OnAcknowledgementPacket callback.
func (im Module) OnAcknowledgementPacket(
ctx sdk.Context,
packet channeltypes.Packet,
acknowledgement []byte,
relayer sdk.AccAddress,
) error {
return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer)
}

// OnTimeoutPacket implements the Module interface.
// It calls the underlying app's OnTimeoutPacket callback.
func (im Module) OnTimeoutPacket(
ctx sdk.Context,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) error {
return im.app.OnTimeoutPacket(ctx, packet, relayer)
}
Loading

0 comments on commit 408300c

Please sign in to comment.