Skip to content

(WIP) feat: EIP-7702 #690

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

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions ante/interfaces/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ func ValidateEthBasic(ctx sdk.Context, tx sdk.Tx, evmParams *evmtypes.Params, ba
"rejected unprotected Ethereum transaction. Please EIP155 sign your transaction to protect it against replay-attacks")
}

// Check that EIP-7702 authorization list signatures are well formed.
if tx.SetCodeAuthorizations() != nil {
if tx.To() == nil {
return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "EIP-7702 set code transaction cannot be contract creation (sender %v)", msgEthTx.From)
}
if len(tx.SetCodeAuthorizations()) == 0 {
return errorsmod.Wrapf(errortypes.ErrInvalidRequest, "EIP-7702 authorization list cannot be empty (sender %v)", msgEthTx.From)
}
}

txFee = txFee.Add(sdk.Coin{Denom: evmDenom, Amount: sdkmath.NewIntFromBigInt(msgEthTx.GetFee())})
}

Expand Down
2 changes: 2 additions & 0 deletions evmd/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func (suite *AnteTestSuite) SetupTest() {
evmGenesis.Params.ChainConfig.GrayGlacierBlock = &maxInt
evmGenesis.Params.ChainConfig.MergeNetsplitBlock = &maxInt
evmGenesis.Params.ChainConfig.ShanghaiTime = &maxInt
evmGenesis.Params.ChainConfig.CancunTime = &maxInt
evmGenesis.Params.ChainConfig.PragueTime = &maxInt
}
if suite.evmParamsOption != nil {
suite.evmParamsOption(&evmGenesis.Params)
Expand Down
17 changes: 15 additions & 2 deletions nix/testenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ poetry2nix.mkPoetryEnv {
eth-bloom = [ "setuptools" ];
};
in
lib.mapAttrs
(lib.mapAttrs
(attr: systems: super.${attr}.overridePythonAttrs
(old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems;
}))
buildSystems
buildSystems) // {
# Fix malformed license field in types-requests package
types-requests = super.types-requests.overridePythonAttrs (old: {
postPatch = (old.postPatch or "") + ''
# Fix malformed license field in pyproject.toml
if [ -f pyproject.toml ]; then
# Fix license field format
sed -i 's/license = "Apache-2.0"/license = {text = "Apache-2.0"}/' pyproject.toml
# Remove invalid license-files property from [project] section
sed -i '/^license-files = /d' pyproject.toml
fi
'';
});
}
);
}
84 changes: 28 additions & 56 deletions proto/ethermint/evm/v1/chain_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ option go_package = "github.com/evmos/ethermint/x/evm/types";
// instead of *big.Int.
message ChainConfig {
// homestead_block switch (nil no fork, 0 = already homestead)
string homestead_block = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"homestead_block\""
];
string homestead_block = 1
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"homestead_block\""];
// dao_fork_block corresponds to TheDAO hard-fork switch block (nil no fork)
string dao_fork_block = 2 [
(gogoproto.customname) = "DAOForkBlock",
Expand Down Expand Up @@ -44,74 +42,48 @@ message ChainConfig {
(gogoproto.moretags) = "yaml:\"eip158_block\""
];
// byzantium_block: Byzantium switch block (nil no fork, 0 = already on byzantium)
string byzantium_block = 8 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"byzantium_block\""
];
string byzantium_block = 8
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"byzantium_block\""];
// constantinople_block: Constantinople switch block (nil no fork, 0 = already activated)
string constantinople_block = 9 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"constantinople_block\""
];
string constantinople_block = 9
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"constantinople_block\""];
// petersburg_block: Petersburg switch block (nil same as Constantinople)
string petersburg_block = 10 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"petersburg_block\""
];
string petersburg_block = 10
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"petersburg_block\""];
// istanbul_block: Istanbul switch block (nil no fork, 0 = already on istanbul)
string istanbul_block = 11 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"istanbul_block\""
];
string istanbul_block = 11
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"istanbul_block\""];
// muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 = already activated)
string muir_glacier_block = 12 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"muir_glacier_block\""
];
string muir_glacier_block = 12
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"muir_glacier_block\""];
// berlin_block: Berlin switch block (nil = no fork, 0 = already on berlin)
string berlin_block = 13 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"berlin_block\""
];
string berlin_block = 13
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"berlin_block\""];
// DEPRECATED: EWASM, YOLOV3 and Catalyst block have been deprecated
reserved 14, 15, 16;
reserved "yolo_v3_block", "ewasm_block", "catalyst_block";
// london_block: London switch block (nil = no fork, 0 = already on london)
string london_block = 17 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"london_block\""
];
string london_block = 17
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"london_block\""];
// arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
string arrow_glacier_block = 18 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"arrow_glacier_block\""
];
string arrow_glacier_block = 18
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"arrow_glacier_block\""];
// DEPRECATED: merge fork block was deprecated: https://github.com/ethereum/go-ethereum/pull/24904
reserved 19;
reserved "merge_fork_block";
// gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
string gray_glacier_block = 20 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"gray_glacier_block\""
];
string gray_glacier_block = 20
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"gray_glacier_block\""];
// merge_netsplit_block: Virtual fork after The Merge to use as a network splitter
string merge_netsplit_block = 21 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"merge_netsplit_block\""
];
string merge_netsplit_block = 21
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"merge_netsplit_block\""];
// shanghai switch time (nil = no fork, 0 = already on shanghai)
string shanghai_time = 22 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"shanghai_time\""
];
string shanghai_time = 22
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"shanghai_time\""];
// cancun switch time (nil = no fork, 0 = already on cancun)
string cancun_time = 23 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"cancun_time\""
];
string cancun_time = 23
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"cancun_time\""];
// prague switch time (nil = no fork, 0 = already on prague)
string prague_time = 24 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"prague_time\""
];
string prague_time = 24
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"prague_time\""];
}
78 changes: 26 additions & 52 deletions proto/ethermint/evm/v1/chain_config_v0.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ option go_package = "github.com/evmos/ethermint/x/evm/types";
// instead of *big.Int.
message V0ChainConfig {
// homestead_block switch (nil no fork, 0 = already homestead)
string homestead_block = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"homestead_block\""
];
string homestead_block = 1
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"homestead_block\""];
// dao_fork_block corresponds to TheDAO hard-fork switch block (nil no fork)
string dao_fork_block = 2 [
(gogoproto.customname) = "DAOForkBlock",
Expand Down Expand Up @@ -44,69 +42,45 @@ message V0ChainConfig {
(gogoproto.moretags) = "yaml:\"eip158_block\""
];
// byzantium_block: Byzantium switch block (nil no fork, 0 = already on byzantium)
string byzantium_block = 8 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"byzantium_block\""
];
string byzantium_block = 8
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"byzantium_block\""];
// constantinople_block: Constantinople switch block (nil no fork, 0 = already activated)
string constantinople_block = 9 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"constantinople_block\""
];
string constantinople_block = 9
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"constantinople_block\""];
// petersburg_block: Petersburg switch block (nil same as Constantinople)
string petersburg_block = 10 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"petersburg_block\""
];
string petersburg_block = 10
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"petersburg_block\""];
// istanbul_block: Istanbul switch block (nil no fork, 0 = already on istanbul)
string istanbul_block = 11 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"istanbul_block\""
];
string istanbul_block = 11
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"istanbul_block\""];
// muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 = already activated)
string muir_glacier_block = 12 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"muir_glacier_block\""
];
string muir_glacier_block = 12
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"muir_glacier_block\""];
// berlin_block: Berlin switch block (nil = no fork, 0 = already on berlin)
string berlin_block = 13 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"berlin_block\""
];
string berlin_block = 13
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"berlin_block\""];
// DEPRECATED: EWASM, YOLOV3 and Catalyst block have been deprecated
reserved 14, 15, 16;
reserved "yolo_v3_block", "ewasm_block", "catalyst_block";
// london_block: London switch block (nil = no fork, 0 = already on london)
string london_block = 17 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"london_block\""
];
string london_block = 17
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"london_block\""];
// arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
string arrow_glacier_block = 18 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"arrow_glacier_block\""
];
string arrow_glacier_block = 18
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"arrow_glacier_block\""];
// DEPRECATED: merge fork block was deprecated: https://github.com/ethereum/go-ethereum/pull/24904
reserved 19;
reserved "merge_fork_block";
// gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
string gray_glacier_block = 20 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"gray_glacier_block\""
];
string gray_glacier_block = 20
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"gray_glacier_block\""];
// merge_netsplit_block: Virtual fork after The Merge to use as a network splitter
string merge_netsplit_block = 21 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"merge_netsplit_block\""
];
string merge_netsplit_block = 21
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"merge_netsplit_block\""];
// shanghai_block switch block (nil = no fork, 0 = already on shanghai)
string shanghai_block = 22 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"shanghai_block\""
];
string shanghai_block = 22
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"shanghai_block\""];
// cancun_block switch block (nil = no fork, 0 = already on cancun)
string cancun_block = 23 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.moretags) = "yaml:\"cancun_block\""
];
string cancun_block = 23
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"cancun_block\""];
}
5 changes: 4 additions & 1 deletion proto/ethermint/evm/v1/params_v4.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ message V4Params {
// extra_eips defines the additional EIPs for the vm.Config
ExtraEIPs extra_eips = 4 [(gogoproto.customname) = "ExtraEIPs", (gogoproto.nullable) = false];
// chain_config defines the EVM chain configuration parameters
V0ChainConfig chain_config = 5 [(gogoproto.nullable) = false];
V0ChainConfig chain_config = 5 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/evmos/ethermint/x/evm/migrations/v0/types.V0ChainConfig"
];
// allow_unprotected_txs defines if replay-protected (i.e non EIP155
// signed) transactions can be executed on the state machine.
bool allow_unprotected_txs = 6;
Expand Down
22 changes: 22 additions & 0 deletions proto/ethermint/evm/v1/set_code_authorization.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package ethermint.evm.v1;

import "gogoproto/gogo.proto";

option go_package = "github.com/evmos/ethermint/x/evm/types";

// SetCodeAuthorization is an authorization from an account to deploy code at its address.
message SetCodeAuthorization {
option (gogoproto.goproto_getters) = false;

string chain_id = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.customname) = "ChainID",
(gogoproto.jsontag) = "chainID"
];
string address = 2;
uint64 nonce = 3;
bytes v = 4;
bytes r = 5;
bytes s = 6;
}
51 changes: 45 additions & 6 deletions proto/ethermint/evm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "google/protobuf/any.proto";
import "ethermint/evm/v1/access_tuple.proto";
import "ethermint/evm/v1/log.proto";
import "ethermint/evm/v1/params.proto";
import "ethermint/evm/v1/set_code_authorization.proto";

option go_package = "github.com/evmos/ethermint/x/evm/types";

Expand Down Expand Up @@ -61,8 +62,7 @@ message LegacyTx {
// to is the hex formatted address of the recipient
string to = 4;
// value defines the unsigned integer value of the transaction amount.
string value = 5
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
string value = 5 [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 6;
// v defines the signature value
Expand Down Expand Up @@ -93,8 +93,7 @@ message AccessListTx {
// to is the recipient address in hex format
string to = 5;
// value defines the unsigned integer value of the transaction amount.
string value = 6
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
string value = 6 [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 7;
// accesses is an array of access tuples
Expand Down Expand Up @@ -130,8 +129,7 @@ message DynamicFeeTx {
// to is the hex formatted address of the recipient
string to = 6;
// value defines the the transaction amount.
string value = 7
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
string value = 7 [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 8;
// accesses is an array of access tuples
Expand All @@ -145,6 +143,47 @@ message DynamicFeeTx {
bytes s = 12;
}

// SetCodeTx implements the EIP-7702 transaction type which temporarily installs
// the code at the signer's address.
message SetCodeTx {
option (gogoproto.goproto_getters) = false;
option (cosmos_proto.implements_interface) = "TxData";

// chain_id of the destination EVM chain
string chain_id = 1 [
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.customname) = "ChainID",
(gogoproto.jsontag) = "chainID"
];
// nonce corresponds to the account nonce (transaction sequence).
uint64 nonce = 2;
// gas_tip_cap defines the max value for the gas tip
string gas_tip_cap = 3 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
// gas_fee_cap defines the max value for the gas fee
string gas_fee_cap = 4 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
// gas defines the gas limit defined for the transaction.
uint64 gas = 5 [(gogoproto.customname) = "GasLimit"];
// to is the hex formatted address of the recipient
string to = 6;
// value defines the the transaction amount.
string value = 7 [(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
// data is the data payload bytes of the transaction.
bytes data = 8;
// accesses is an array of access tuples
repeated AccessTuple accesses = 9
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
// auth_list is a list of tuples that indicate what code the signer of each tuple desires to execute in the context of
// their EOA
repeated SetCodeAuthorization auth_list = 10
[(gogoproto.castrepeated) = "AuthList", (gogoproto.jsontag) = "authList", (gogoproto.nullable) = false];
// v defines the signature value
bytes v = 11;
// r defines the signature value
bytes r = 12;
// s define the signature value
bytes s = 13;
}

// ExtensionOptionsEthereumTx is an extension option for ethereum transactions
message ExtensionOptionsEthereumTx {
option (gogoproto.goproto_getters) = false;
Expand Down
Loading
Loading