Skip to content

Commit 98d6dda

Browse files
committed
Introduce error type for txs originating from accounts with code (#1021)
1 parent e71d405 commit 98d6dda

File tree

17 files changed

+39
-32
lines changed

17 files changed

+39
-32
lines changed

src/ethereum/arrow_glacier/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -794,7 +794,7 @@ def process_transaction(
794794
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
795795
raise InvalidBlock
796796
if sender_account.code != bytearray():
797-
raise InvalidBlock
797+
raise InvalidSenderError("not EOA")
798798

799799
effective_gas_fee = tx.gas * env.gas_price
800800

src/ethereum/berlin/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -683,7 +683,7 @@ def process_transaction(
683683
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
684684
raise InvalidBlock
685685
if sender_account.code != bytearray():
686-
raise InvalidBlock
686+
raise InvalidSenderError("not EOA")
687687

688688
gas = tx.gas - calculate_intrinsic_cost(tx)
689689
increment_nonce(env.state, sender)

src/ethereum/byzantium/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -671,7 +671,7 @@ def process_transaction(
671671
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
672672
raise InvalidBlock
673673
if sender_account.code != bytearray():
674-
raise InvalidBlock
674+
raise InvalidSenderError("not EOA")
675675

676676
gas = tx.gas - calculate_intrinsic_cost(tx)
677677
increment_nonce(env.state, sender)

src/ethereum/cancun/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
23-
from ethereum.exceptions import InvalidBlock
23+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2424

2525
from .. import rlp
2626
from . import vm
@@ -427,7 +427,7 @@ def check_transaction(
427427
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
428428
raise InvalidBlock
429429
if sender_account.code != bytearray():
430-
raise InvalidBlock
430+
raise InvalidSenderError("not EOA")
431431

432432
return sender, effective_gas_price, blob_versioned_hashes
433433

src/ethereum/constantinople/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -671,7 +671,7 @@ def process_transaction(
671671
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
672672
raise InvalidBlock
673673
if sender_account.code != bytearray():
674-
raise InvalidBlock
674+
raise InvalidSenderError("not EOA")
675675

676676
gas = tx.gas - calculate_intrinsic_cost(tx)
677677
increment_nonce(env.state, sender)

src/ethereum/dao_fork/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2424
from ethereum.crypto.hash import Hash32, keccak256
2525
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
26-
from ethereum.exceptions import InvalidBlock
26+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2727

2828
from .. import rlp
2929
from . import FORK_CRITERIA, vm
@@ -677,7 +677,7 @@ def process_transaction(
677677
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
678678
raise InvalidBlock
679679
if sender_account.code != bytearray():
680-
raise InvalidBlock
680+
raise InvalidSenderError("not EOA")
681681

682682
gas = tx.gas - calculate_intrinsic_cost(tx)
683683
increment_nonce(env.state, sender)

src/ethereum/exceptions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ class RLPEncodingError(EthereumException):
3232
"""
3333
Indicates that RLP encoding failed.
3434
"""
35+
36+
37+
class InvalidSenderError(InvalidTransaction):
38+
"""
39+
Thrown when a transaction originates from an account that cannot send
40+
transactions.
41+
"""

src/ethereum/frontier/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -658,7 +658,7 @@ def process_transaction(
658658
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
659659
raise InvalidBlock
660660
if sender_account.code != bytearray():
661-
raise InvalidBlock
661+
raise InvalidSenderError("not EOA")
662662

663663
gas = tx.gas - calculate_intrinsic_cost(tx)
664664
increment_nonce(env.state, sender)

src/ethereum/gray_glacier/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -794,7 +794,7 @@ def process_transaction(
794794
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
795795
raise InvalidBlock
796796
if sender_account.code != bytearray():
797-
raise InvalidBlock
797+
raise InvalidSenderError("not EOA")
798798

799799
effective_gas_fee = tx.gas * env.gas_price
800800

src/ethereum/homestead/fork.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
2222
from ethereum.crypto.hash import Hash32, keccak256
2323
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
24-
from ethereum.exceptions import InvalidBlock
24+
from ethereum.exceptions import InvalidBlock, InvalidSenderError
2525

2626
from .. import rlp
2727
from . import vm
@@ -659,7 +659,7 @@ def process_transaction(
659659
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
660660
raise InvalidBlock
661661
if sender_account.code != bytearray():
662-
raise InvalidBlock
662+
raise InvalidSenderError("not EOA")
663663

664664
gas = tx.gas - calculate_intrinsic_cost(tx)
665665
increment_nonce(env.state, sender)

0 commit comments

Comments
 (0)