From acf6d31da0ec36fbb1eeae30644161fece507bc8 Mon Sep 17 00:00:00 2001 From: librelois Date: Wed, 21 Jun 2023 16:25:29 +0200 Subject: [PATCH 1/3] check EIP-3607 at transaction validation --- frame/ethereum/src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 975a5d46f3..1fa9029a2f 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -492,6 +492,19 @@ impl Pallet { .and_then(|v| v.with_balance_for(&who)) .map_err(|e| e.0)?; + // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 + // Do not allow transactions for which `tx.sender` has any code deployed. + // + // This check should be done on the transaction validation (here) **and** + // on trnasaction execution, otherwise a contract tx will be included in + // the mempool and pollute the mempool forever. + if !pallet_evm::AccountCodes::::get(source).is_empty() { + return Err(RunnerError { + error: Error::::TransactionMustComeFromEOA, + weight, + }); + } + let priority = match ( transaction_data.gas_price, transaction_data.max_fee_per_gas, From 606e6fdeaeab237bf8af9b9e1d78121634ee4908 Mon Sep 17 00:00:00 2001 From: librelois Date: Wed, 21 Jun 2023 17:30:40 +0200 Subject: [PATCH 2/3] fix rust compilation --- frame/ethereum/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 1fa9029a2f..f3cc47c970 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -498,11 +498,8 @@ impl Pallet { // This check should be done on the transaction validation (here) **and** // on trnasaction execution, otherwise a contract tx will be included in // the mempool and pollute the mempool forever. - if !pallet_evm::AccountCodes::::get(source).is_empty() { - return Err(RunnerError { - error: Error::::TransactionMustComeFromEOA, - weight, - }); + if !pallet_evm::AccountCodes::::get(&origin).is_empty() { + return Err(InvalidTransaction::BadSigner.into()); } let priority = match ( From 37b85069f457316a46b69687b5f6dc0be99f00f0 Mon Sep 17 00:00:00 2001 From: librelois Date: Wed, 21 Jun 2023 18:33:51 +0200 Subject: [PATCH 3/3] clippy --- frame/ethereum/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index f3cc47c970..c4c9921088 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -498,7 +498,7 @@ impl Pallet { // This check should be done on the transaction validation (here) **and** // on trnasaction execution, otherwise a contract tx will be included in // the mempool and pollute the mempool forever. - if !pallet_evm::AccountCodes::::get(&origin).is_empty() { + if !pallet_evm::AccountCodes::::get(origin).is_empty() { return Err(InvalidTransaction::BadSigner.into()); }