Skip to content

Commit

Permalink
Introduce error type for txs originating from accounts with code (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed Oct 31, 2024
1 parent e71d405 commit 98d6dda
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/ethereum/arrow_glacier/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -794,7 +794,7 @@ def process_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

effective_gas_fee = tx.gas * env.gas_price

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/berlin/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -683,7 +683,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/byzantium/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -671,7 +671,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/cancun/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -427,7 +427,7 @@ def check_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

return sender, effective_gas_price, blob_versioned_hashes

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/constantinople/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -671,7 +671,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/dao_fork/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import FORK_CRITERIA, vm
Expand Down Expand Up @@ -677,7 +677,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
7 changes: 7 additions & 0 deletions src/ethereum/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ class RLPEncodingError(EthereumException):
"""
Indicates that RLP encoding failed.
"""


class InvalidSenderError(InvalidTransaction):
"""
Thrown when a transaction originates from an account that cannot send
transactions.
"""
4 changes: 2 additions & 2 deletions src/ethereum/frontier/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -658,7 +658,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/gray_glacier/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -794,7 +794,7 @@ def process_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

effective_gas_fee = tx.gas * env.gas_price

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/homestead/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -659,7 +659,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/istanbul/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -672,7 +672,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/london/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import FORK_CRITERIA, vm
Expand Down Expand Up @@ -800,7 +800,7 @@ def process_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

effective_gas_fee = tx.gas * env.gas_price

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/muir_glacier/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -672,7 +672,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/paris/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -584,7 +584,7 @@ def process_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

effective_gas_fee = tx.gas * env.gas_price

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/shanghai/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -607,7 +607,7 @@ def process_transaction(
if Uint(sender_account.balance) < max_gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

effective_gas_fee = tx.gas * env.gas_price

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/spurious_dragon/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -667,7 +667,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/tangerine_whistle/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ethereum.crypto.elliptic_curve import SECP256K1N, secp256k1_recover
from ethereum.crypto.hash import Hash32, keccak256
from ethereum.ethash import dataset_size, generate_cache, hashimoto_light
from ethereum.exceptions import InvalidBlock
from ethereum.exceptions import InvalidBlock, InvalidSenderError

from .. import rlp
from . import vm
Expand Down Expand Up @@ -659,7 +659,7 @@ def process_transaction(
if Uint(sender_account.balance) < gas_fee + Uint(tx.value):
raise InvalidBlock
if sender_account.code != bytearray():
raise InvalidBlock
raise InvalidSenderError("not EOA")

gas = tx.gas - calculate_intrinsic_cost(tx)
increment_nonce(env.state, sender)
Expand Down

0 comments on commit 98d6dda

Please sign in to comment.