Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [\#609](https://github.com/cosmos/evm/pull/609) Make `erc20Keeper` optional in the EVM keeper
- [\#624](https://github.com/cosmos/evm/pull/624) Cleanup unnecessary `fix-revert-gas-refund-height`.
- [\#635](https://github.com/cosmos/evm/pull/635) Move DefaultStaticPrecompiles to /evm and allow projects to set it by default alongside the keeper.
- [\#639](https://github.com/cosmos/evm/pull/639) Remove `/types` from top-level repo and move files to respective areas.


### FEATURES
Expand Down
5 changes: 2 additions & 3 deletions ante/cosmos/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/crypto/ethsecp256k1"
"github.com/cosmos/evm/ethereum/eip712"
"github.com/cosmos/evm/types"

errorsmod "cosmossdk.io/errors"

Expand All @@ -30,7 +29,7 @@ var evmCodec codec.ProtoCodecMarshaler

func init() {
registry := codectypes.NewInterfaceRegistry()
types.RegisterInterfaces(registry)
eip712.RegisterInterfaces(registry)
evmCodec = codec.NewProtoCodec(registry)
}

Expand Down Expand Up @@ -204,7 +203,7 @@ func VerifySignature(
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesn't contain expected amount of extension options")
}

extOpt, ok := opts[0].GetCachedValue().(*types.ExtensionOptionsWeb3Tx)
extOpt, ok := opts[0].GetCachedValue().(*eip712.ExtensionOptionsWeb3Tx)
if !ok {
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "unknown extension option")
}
Expand Down
6 changes: 3 additions & 3 deletions ante/evm/08_gas_consume.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/types"
types2 "github.com/cosmos/evm/ante/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -99,7 +99,7 @@ func GetMsgPriority(

// TODO: (@fedekunze) Why is this necessary? This seems to be a duplicate from the CheckGasWanted function.
func CheckBlockGasLimit(ctx sdktypes.Context, gasWanted uint64, minPriority int64) (sdktypes.Context, error) {
blockGasLimit := types.BlockGasLimit(ctx)
blockGasLimit := types2.BlockGasLimit(ctx)

// return error if the tx gas is greater than the block limit (max gas)

Expand All @@ -122,7 +122,7 @@ func CheckBlockGasLimit(ctx sdktypes.Context, gasWanted uint64, minPriority int6
// FIXME: use a custom gas configuration that doesn't add any additional gas and only
// takes into account the gas consumed at the end of the EVM transaction.
ctx = ctx.
WithGasMeter(types.NewInfiniteGasMeterWithLimit(gasWanted)).
WithGasMeter(evmtypes.NewInfiniteGasMeterWithLimit(gasWanted)).
WithPriority(minPriority)

return ctx, nil
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/10_gas_wanted.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math/big"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/types"
"github.com/cosmos/evm/ante/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/params"

anteinterfaces "github.com/cosmos/evm/ante/interfaces"
cosmosevmtypes "github.com/cosmos/evm/types"
cosmosevmtypes "github.com/cosmos/evm/ante/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
Expand Down
2 changes: 1 addition & 1 deletion ante/evm/fee_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/cosmos/evm/ante/evm"
anteinterfaces "github.com/cosmos/evm/ante/interfaces"
"github.com/cosmos/evm/ante/types"
"github.com/cosmos/evm/encoding"
"github.com/cosmos/evm/testutil/config"
testconstants "github.com/cosmos/evm/testutil/constants"
"github.com/cosmos/evm/types"
feemarkettypes "github.com/cosmos/evm/x/feemarket/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions types/dynamic_fee.pb.go → ante/types/dynamic_fee.pb.go

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

9 changes: 4 additions & 5 deletions crypto/hd/algorithm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

cryptocodec "github.com/cosmos/evm/crypto/codec"
enccodec "github.com/cosmos/evm/encoding/codec"
cosmosevmtypes "github.com/cosmos/evm/types"

amino "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -49,7 +48,7 @@ func TestKeyring(t *testing.T) {
require.Nil(t, info)

mockIn.Reset("password\npassword\n")
info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, cosmosevmtypes.BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1)
info, mnemonic, err := kr.NewMnemonic("foo", keyring.English, BIP44HDPath, keyring.DefaultBIP39Passphrase, EthSecp256k1)
require.NoError(t, err)
require.NotEmpty(t, mnemonic)
require.Equal(t, "foo", info.Name)
Expand All @@ -58,7 +57,7 @@ func TestKeyring(t *testing.T) {
require.NoError(t, err)
require.Equal(t, string(EthSecp256k1Type), pubKey.Type())

hdPath := cosmosevmtypes.BIP44HDPath
hdPath := BIP44HDPath

bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, hdPath)
require.NoError(t, err)
Expand All @@ -84,7 +83,7 @@ func TestKeyring(t *testing.T) {
}

func TestDerivation(t *testing.T) {
bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, cosmosevmtypes.BIP44HDPath)
bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath)
require.NoError(t, err)
require.NotEmpty(t, bz)

Expand All @@ -102,7 +101,7 @@ func TestDerivation(t *testing.T) {
wallet, err := NewFromMnemonic(mnemonic)
require.NoError(t, err)

path := MustParseDerivationPath(cosmosevmtypes.BIP44HDPath)
path := MustParseDerivationPath(BIP44HDPath)
account, err := wallet.Derive(path, false)
require.NoError(t, err)

Expand Down
6 changes: 2 additions & 4 deletions crypto/hd/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ package hd
import (
"testing"

"github.com/cosmos/evm/types"

"github.com/cosmos/cosmos-sdk/crypto/keyring"
)

func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
deriveFn := EthSecp256k1.Derive()
if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath); err != nil {
if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath); err != nil {
b.Fatal(err)
}
}
}

func BenchmarkEthSecp256k1Algo_Generate(b *testing.B) {
bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, types.BIP44HDPath)
bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, BIP44HDPath)
if err != nil {
b.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions types/hdpath.go → crypto/hd/hdpath.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types
package hd

import (
ethaccounts "github.com/ethereum/go-ethereum/accounts"
Expand All @@ -13,12 +13,12 @@ var (
)

type (
HDPathIterator func() ethaccounts.DerivationPath
PathIterator func() ethaccounts.DerivationPath
)

// NewHDPathIterator receives a base path as a string and a boolean for the desired iterator type and
// returns a function that iterates over the base HD path, returning the string.
func NewHDPathIterator(basePath string, ledgerIter bool) (HDPathIterator, error) {
func NewHDPathIterator(basePath string, ledgerIter bool) (PathIterator, error) {
hdPath, err := ethaccounts.ParseDerivationPath(basePath)
if err != nil {
return nil, err
Expand Down
15 changes: 14 additions & 1 deletion docs/migrations/v0.4.0_to_v0.5.0_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@ go mod tidy

---

## 2) App wiring in `app.go`
## 2) Fix `"github.com/cosmos/evm/types" imports`

`v0.5.0` removes `github.com/cosmos/evm/types` and moves files to their folders, respective to function.
For a complete list of changes, refer to [this PR](https://github.com/cosmos/evm/pull/639). The
following list includes references within `evmd` that have been moved.

- `Bip44CoinType`, `BIP44HDPath` was moved to `"github.com/cosmos/evm/crypto/hd"`
- `HasDynamicFeeExtensionOption` was moved `"github.com/cosmos/evm/ante/types"`
- `GenesisState` was removed as a duplicate object can be found in the `evmd` folder and a testing version is in `"github.com/cosmos/evm/testutil"`
- `AttoPowerReduction` was moved to `"github.com/cosmos/evm/utils"`

---

## 3) App wiring in `app.go`

### Mempool

Expand Down
4 changes: 2 additions & 2 deletions encoding/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package codec

import (
cryptocodec "github.com/cosmos/evm/crypto/codec"
"github.com/cosmos/evm/types"
"github.com/cosmos/evm/ethereum/eip712"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand All @@ -21,5 +21,5 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
std.RegisterInterfaces(interfaceRegistry)
cryptocodec.RegisterInterfaces(interfaceRegistry)
types.RegisterInterfaces(interfaceRegistry)
eip712.RegisterInterfaces(interfaceRegistry)
}
6 changes: 4 additions & 2 deletions types/codec.go → ethereum/eip712/codec.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types
package eip712

import (
types2 "github.com/cosmos/evm/ante/types"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
Expand All @@ -23,6 +25,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*tx.TxExtensionOptionI)(nil),
&ExtensionOptionsWeb3Tx{},
&ExtensionOptionDynamicFeeTx{},
&types2.ExtensionOptionDynamicFeeTx{},
)
}
4 changes: 1 addition & 3 deletions ethereum/eip712/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package eip712
import (
"fmt"

"github.com/cosmos/evm/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -55,7 +53,7 @@ func PreprocessLedgerTx(evmChainID uint64, keyType cosmoskr.KeyType, txBuilder c
}
// Add ExtensionOptionsWeb3Tx extension with signature
var option *codectypes.Any
option, err = codectypes.NewAnyWithValue(&types.ExtensionOptionsWeb3Tx{
option, err = codectypes.NewAnyWithValue(&ExtensionOptionsWeb3Tx{
FeePayer: feePayerAddr,
TypedDataChainID: evmChainID,
FeePayerSig: sigBytes,
Expand Down
3 changes: 1 addition & 2 deletions ethereum/eip712/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/cosmos/evm/ethereum/eip712"
"github.com/cosmos/evm/testutil/constants"
utiltx "github.com/cosmos/evm/testutil/tx"
"github.com/cosmos/evm/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

"cosmossdk.io/math"
Expand Down Expand Up @@ -81,7 +80,7 @@ func TestLedgerPreprocessing(t *testing.T) {
require.True(t, ok)
require.True(t, len(hasExtOptsTx.GetExtensionOptions()) == 1)

expectedExt := types.ExtensionOptionsWeb3Tx{
expectedExt := eip712.ExtensionOptionsWeb3Tx{
TypedDataChainID: 9001,
FeePayer: feePayerAddress,
FeePayerSig: tc.expectedSignatureBytes,
Expand Down
43 changes: 22 additions & 21 deletions types/web3.pb.go → ethereum/eip712/web3.pb.go

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

4 changes: 2 additions & 2 deletions evmd/ante/evm_antehandler_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ante_test

import (
"fmt"
antetypes "github.com/cosmos/evm/ante/types"
"math/big"
"testing"

Expand All @@ -14,7 +15,6 @@ import (
"github.com/cosmos/evm/testutil/integration/evm/grpc"
"github.com/cosmos/evm/testutil/integration/evm/network"
testkeyring "github.com/cosmos/evm/testutil/keyring"
cosmosevmtypes "github.com/cosmos/evm/types"
evmtypes "github.com/cosmos/evm/x/vm/types"

"cosmossdk.io/errors"
Expand Down Expand Up @@ -148,7 +148,7 @@ func (s *benchmarkSuite) generateHandlerOptions() ante.HandlerOptions {
Cdc: s.network.App.AppCodec(),
AccountKeeper: s.network.App.GetAccountKeeper(),
BankKeeper: s.network.App.GetBankKeeper(),
ExtensionOptionChecker: cosmosevmtypes.HasDynamicFeeExtensionOption,
ExtensionOptionChecker: antetypes.HasDynamicFeeExtensionOption,
EvmKeeper: s.network.App.GetEVMKeeper(),
FeegrantKeeper: s.network.App.GetFeeGrantKeeper(),
IBCKeeper: s.network.App.GetIBCKeeper(),
Expand Down
Loading
Loading