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

imp(all): Add EVM, ERC-20, feemarket and precompiles from Evmos #37

Merged
merged 32 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
408300c
import evm feemarket and precompiles
MalteHerrmann Aug 13, 2024
d1bfb7c
add changelog entry
MalteHerrmann Aug 13, 2024
00b2252
more wip
MalteHerrmann Aug 13, 2024
2d1515c
add erc20 module and IBC middleware
MalteHerrmann Aug 13, 2024
56efcc9
regenerate protos
MalteHerrmann Aug 13, 2024
dc2e88f
untangle
MalteHerrmann Aug 13, 2024
b966b96
run go mod tidy
MalteHerrmann Aug 13, 2024
305393e
more wip
MalteHerrmann Aug 13, 2024
1b21e5b
Merge branch 'main' into add-modules
MalteHerrmann Aug 14, 2024
2faaaa1
wip
MalteHerrmann Aug 15, 2024
413d96c
fix all this s
MalteHerrmann Aug 16, 2024
ac682fd
address linters
MalteHerrmann Aug 16, 2024
79ac817
move some chain native stuff to testutils
MalteHerrmann Aug 16, 2024
b731356
fix extension options type url
MalteHerrmann Aug 16, 2024
81d3ef4
use empty default extensions as params
MalteHerrmann Aug 16, 2024
08b54b5
run go work sync
MalteHerrmann Aug 19, 2024
11aad01
rework default EVM genesis after removing default EVM params to be pa…
MalteHerrmann Aug 19, 2024
5e95113
fix error message and tests
MalteHerrmann Aug 19, 2024
013edbf
fix ante tests
MalteHerrmann Aug 19, 2024
774ac37
commit wip fixing tests
MalteHerrmann Aug 19, 2024
bd25c16
linters
MalteHerrmann Aug 19, 2024
ca5e49a
more evm tests fixed
MalteHerrmann Aug 20, 2024
196313c
add ibc module to example app
MalteHerrmann Aug 20, 2024
d8eafcf
use all available precompiles in example app
MalteHerrmann Aug 20, 2024
b99dfdc
fix more tests and add initial token pair to example application
MalteHerrmann Aug 20, 2024
50f5a5f
refactors to align genesis states with example chain and tests
MalteHerrmann Aug 20, 2024
7642c13
add default power reduction for 18 decimals and fixes / linters
MalteHerrmann Aug 21, 2024
c167e7e
fix tests
MalteHerrmann Aug 21, 2024
03c017d
avoid using hardcoded bech32 prefix in distribution precompile
MalteHerrmann Aug 21, 2024
6b6710e
address G115 int overflow linters
MalteHerrmann Aug 21, 2024
175c482
rename example app import alias
MalteHerrmann Aug 23, 2024
a3c4f48
add missing linters
MalteHerrmann Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This changelog was created using the `clu` binary

### Improvements

- (all) [#37](https://github.com/evmos/os/pull/37) Add EVM, feemarket and precompiles from evmOS.
- (all) [#30](https://github.com/evmos/os/pull/30) Add example chain implementation and ante handlers.
- (ci) [#35](https://github.com/evmos/os/pull/35) Disable dependabot temporarily.
- (contracts) [#24](https://github.com/evmos/os/pull/24) Add contracts directory and compilation script.
Expand Down
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 @@
"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 @@
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 Expand Up @@ -428,7 +428,7 @@
app.EVMKeeper = evmkeeper.NewKeeper(
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,

Check failure on line 431 in example_chain/app.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

cannot use app.FeeMarketKeeper (variable of type "github.com/evmos/os/x/feemarket/keeper".Keeper) as "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper value in argument to evmkeeper.NewKeeper: "github.com/evmos/os/x/feemarket/keeper".Keeper does not implement "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper (wrong type for method GetParams)

Check failure on line 431 in example_chain/app.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

cannot use app.FeeMarketKeeper (variable of type "github.com/evmos/os/x/feemarket/keeper".Keeper) as "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper value in argument to evmkeeper.NewKeeper: "github.com/evmos/os/x/feemarket/keeper".Keeper does not implement "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper (wrong type for method GetParams)

Check failure on line 431 in example_chain/app.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

cannot use app.FeeMarketKeeper (variable of type "github.com/evmos/os/x/feemarket/keeper".Keeper) as "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper value in argument to evmkeeper.NewKeeper: "github.com/evmos/os/x/feemarket/keeper".Keeper does not implement "github.com/evmos/evmos/v19/x/evm/types".FeeMarketKeeper (wrong type for method GetParams)
&app.Erc20Keeper,
tracer, app.GetSubspace(evmtypes.ModuleName),
)
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
Loading