Skip to content

Commit c118601

Browse files
authored
Merge pull request #1065 from gurukamath/run-all-tests
Run all tests
2 parents 5a9f77c + 322053a commit c118601

File tree

61 files changed

+449
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+449
-66
lines changed

Diff for: setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ doc =
178178
fladrif>=0.2.0,<0.3.0
179179

180180
optimized =
181-
rust-pyspec-glue>=0.0.7,<0.1.0
181+
rust-pyspec-glue>=0.0.9,<0.1.0
182182
ethash @ git+https://github.com/chfast/ethash.git@e08bd0fadb8785f7ccf1e2fb07b75f54fe47f92e
183183

184184
[flake8]

Diff for: src/ethereum/arrow_glacier/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
364364
Returns
365365
-------
366366
has_code_or_nonce : `bool`
367-
True if if an account has non zero nonce or non empty code,
367+
True if the account has non zero nonce or non empty code,
368368
False otherwise.
369369
"""
370370
account = get_account(state, address)
371371
return account.nonce != Uint(0) or account.code != b""
372372

373373

374+
def account_has_storage(state: State, address: Address) -> bool:
375+
"""
376+
Checks if an account has storage.
377+
378+
Parameters
379+
----------
380+
state:
381+
The state
382+
address:
383+
Address of the account that needs to be checked.
384+
385+
Returns
386+
-------
387+
has_storage : `bool`
388+
True if the account has storage, False otherwise.
389+
"""
390+
return address in state._storage_tries
391+
392+
374393
def is_account_empty(state: State, address: Address) -> bool:
375394
"""
376395
Checks if an account has zero nonce, empty code and zero balance.

Diff for: src/ethereum/arrow_glacier/vm/instructions/system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ...state import (
2121
account_exists_and_is_empty,
2222
account_has_code_or_nonce,
23+
account_has_storage,
2324
get_account,
2425
increment_nonce,
2526
is_account_alive,
@@ -90,7 +91,9 @@ def generic_create(
9091
push(evm.stack, U256(0))
9192
return
9293

93-
if account_has_code_or_nonce(evm.env.state, contract_address):
94+
if account_has_code_or_nonce(
95+
evm.env.state, contract_address
96+
) or account_has_storage(evm.env.state, contract_address):
9497
increment_nonce(evm.env.state, evm.message.current_target)
9598
push(evm.stack, U256(0))
9699
return

Diff for: src/ethereum/arrow_glacier/vm/interpreter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..state import (
3434
account_exists_and_is_empty,
3535
account_has_code_or_nonce,
36+
account_has_storage,
3637
begin_transaction,
3738
commit_transaction,
3839
destroy_storage,
@@ -109,7 +110,7 @@ def process_message_call(
109110
if message.target == Bytes0(b""):
110111
is_collision = account_has_code_or_nonce(
111112
env.state, message.current_target
112-
)
113+
) or account_has_storage(env.state, message.current_target)
113114
if is_collision:
114115
return MessageCallOutput(
115116
Uint(0), U256(0), tuple(), set(), set(), AddressCollision()

Diff for: src/ethereum/berlin/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
364364
Returns
365365
-------
366366
has_code_or_nonce : `bool`
367-
True if if an account has non zero nonce or non empty code,
367+
True if the account has non zero nonce or non empty code,
368368
False otherwise.
369369
"""
370370
account = get_account(state, address)
371371
return account.nonce != Uint(0) or account.code != b""
372372

373373

374+
def account_has_storage(state: State, address: Address) -> bool:
375+
"""
376+
Checks if an account has storage.
377+
378+
Parameters
379+
----------
380+
state:
381+
The state
382+
address:
383+
Address of the account that needs to be checked.
384+
385+
Returns
386+
-------
387+
has_storage : `bool`
388+
True if the account has storage, False otherwise.
389+
"""
390+
return address in state._storage_tries
391+
392+
374393
def is_account_empty(state: State, address: Address) -> bool:
375394
"""
376395
Checks if an account has zero nonce, empty code and zero balance.

Diff for: src/ethereum/berlin/vm/instructions/system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ...state import (
2121
account_exists_and_is_empty,
2222
account_has_code_or_nonce,
23+
account_has_storage,
2324
get_account,
2425
increment_nonce,
2526
is_account_alive,
@@ -91,7 +92,9 @@ def generic_create(
9192
push(evm.stack, U256(0))
9293
return
9394

94-
if account_has_code_or_nonce(evm.env.state, contract_address):
95+
if account_has_code_or_nonce(
96+
evm.env.state, contract_address
97+
) or account_has_storage(evm.env.state, contract_address):
9598
increment_nonce(evm.env.state, evm.message.current_target)
9699
push(evm.stack, U256(0))
97100
return

Diff for: src/ethereum/berlin/vm/interpreter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..state import (
3434
account_exists_and_is_empty,
3535
account_has_code_or_nonce,
36+
account_has_storage,
3637
begin_transaction,
3738
commit_transaction,
3839
destroy_storage,
@@ -108,7 +109,7 @@ def process_message_call(
108109
if message.target == Bytes0(b""):
109110
is_collision = account_has_code_or_nonce(
110111
env.state, message.current_target
111-
)
112+
) or account_has_storage(env.state, message.current_target)
112113
if is_collision:
113114
return MessageCallOutput(
114115
Uint(0), U256(0), tuple(), set(), set(), AddressCollision()

Diff for: src/ethereum/byzantium/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
338338
Returns
339339
-------
340340
has_code_or_nonce : `bool`
341-
True if if an account has non zero nonce or non empty code,
341+
True if the account has non zero nonce or non empty code,
342342
False otherwise.
343343
"""
344344
account = get_account(state, address)
345345
return account.nonce != Uint(0) or account.code != b""
346346

347347

348+
def account_has_storage(state: State, address: Address) -> bool:
349+
"""
350+
Checks if an account has storage.
351+
352+
Parameters
353+
----------
354+
state:
355+
The state
356+
address:
357+
Address of the account that needs to be checked.
358+
359+
Returns
360+
-------
361+
has_storage : `bool`
362+
True if the account has storage, False otherwise.
363+
"""
364+
return address in state._storage_tries
365+
366+
348367
def is_account_empty(state: State, address: Address) -> bool:
349368
"""
350369
Checks if an account has zero nonce, empty code and zero balance.

Diff for: src/ethereum/byzantium/vm/instructions/system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ...state import (
1919
account_exists_and_is_empty,
2020
account_has_code_or_nonce,
21+
account_has_storage,
2122
get_account,
2223
increment_nonce,
2324
is_account_alive,
@@ -96,7 +97,9 @@ def create(evm: Evm) -> None:
9697
):
9798
push(evm.stack, U256(0))
9899
evm.gas_left += create_message_gas
99-
elif account_has_code_or_nonce(evm.env.state, contract_address):
100+
elif account_has_code_or_nonce(
101+
evm.env.state, contract_address
102+
) or account_has_storage(evm.env.state, contract_address):
100103
increment_nonce(evm.env.state, evm.message.current_target)
101104
push(evm.stack, U256(0))
102105
else:

Diff for: src/ethereum/byzantium/vm/interpreter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..state import (
3434
account_exists_and_is_empty,
3535
account_has_code_or_nonce,
36+
account_has_storage,
3637
begin_transaction,
3738
commit_transaction,
3839
destroy_storage,
@@ -107,7 +108,7 @@ def process_message_call(
107108
if message.target == Bytes0(b""):
108109
is_collision = account_has_code_or_nonce(
109110
env.state, message.current_target
110-
)
111+
) or account_has_storage(env.state, message.current_target)
111112
if is_collision:
112113
return MessageCallOutput(
113114
Uint(0), U256(0), tuple(), set(), set(), AddressCollision()

Diff for: src/ethereum/cancun/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
397397
Returns
398398
-------
399399
has_code_or_nonce : `bool`
400-
True if if an account has non zero nonce or non empty code,
400+
True if the account has non zero nonce or non empty code,
401401
False otherwise.
402402
"""
403403
account = get_account(state, address)
404404
return account.nonce != Uint(0) or account.code != b""
405405

406406

407+
def account_has_storage(state: State, address: Address) -> bool:
408+
"""
409+
Checks if an account has storage.
410+
411+
Parameters
412+
----------
413+
state:
414+
The state
415+
address:
416+
Address of the account that needs to be checked.
417+
418+
Returns
419+
-------
420+
has_storage : `bool`
421+
True if the account has storage, False otherwise.
422+
"""
423+
return address in state._storage_tries
424+
425+
407426
def is_account_empty(state: State, address: Address) -> bool:
408427
"""
409428
Checks if an account has zero nonce, empty code and zero balance.

Diff for: src/ethereum/cancun/vm/instructions/system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ...state import (
2121
account_exists_and_is_empty,
2222
account_has_code_or_nonce,
23+
account_has_storage,
2324
get_account,
2425
increment_nonce,
2526
is_account_alive,
@@ -103,7 +104,9 @@ def generic_create(
103104
push(evm.stack, U256(0))
104105
return
105106

106-
if account_has_code_or_nonce(evm.env.state, contract_address):
107+
if account_has_code_or_nonce(
108+
evm.env.state, contract_address
109+
) or account_has_storage(evm.env.state, contract_address):
107110
increment_nonce(evm.env.state, evm.message.current_target)
108111
push(evm.stack, U256(0))
109112
return

Diff for: src/ethereum/cancun/vm/interpreter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..state import (
3434
account_exists_and_is_empty,
3535
account_has_code_or_nonce,
36+
account_has_storage,
3637
begin_transaction,
3738
commit_transaction,
3839
destroy_storage,
@@ -109,7 +110,7 @@ def process_message_call(
109110
if message.target == Bytes0(b""):
110111
is_collision = account_has_code_or_nonce(
111112
env.state, message.current_target
112-
)
113+
) or account_has_storage(env.state, message.current_target)
113114
if is_collision:
114115
return MessageCallOutput(
115116
Uint(0), U256(0), tuple(), set(), set(), AddressCollision()

Diff for: src/ethereum/constantinople/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
338338
Returns
339339
-------
340340
has_code_or_nonce : `bool`
341-
True if if an account has non zero nonce or non empty code,
341+
True if the account has non zero nonce or non empty code,
342342
False otherwise.
343343
"""
344344
account = get_account(state, address)
345345
return account.nonce != Uint(0) or account.code != b""
346346

347347

348+
def account_has_storage(state: State, address: Address) -> bool:
349+
"""
350+
Checks if an account has storage.
351+
352+
Parameters
353+
----------
354+
state:
355+
The state
356+
address:
357+
Address of the account that needs to be checked.
358+
359+
Returns
360+
-------
361+
has_storage : `bool`
362+
True if the account has storage, False otherwise.
363+
"""
364+
return address in state._storage_tries
365+
366+
348367
def is_account_empty(state: State, address: Address) -> bool:
349368
"""
350369
Checks if an account has zero nonce, empty code and zero balance.

Diff for: src/ethereum/constantinople/vm/instructions/system.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ...state import (
2121
account_exists_and_is_empty,
2222
account_has_code_or_nonce,
23+
account_has_storage,
2324
get_account,
2425
increment_nonce,
2526
is_account_alive,
@@ -88,7 +89,9 @@ def generic_create(
8889
push(evm.stack, U256(0))
8990
return
9091

91-
if account_has_code_or_nonce(evm.env.state, contract_address):
92+
if account_has_code_or_nonce(
93+
evm.env.state, contract_address
94+
) or account_has_storage(evm.env.state, contract_address):
9295
increment_nonce(evm.env.state, evm.message.current_target)
9396
push(evm.stack, U256(0))
9497
return

Diff for: src/ethereum/constantinople/vm/interpreter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..state import (
3434
account_exists_and_is_empty,
3535
account_has_code_or_nonce,
36+
account_has_storage,
3637
begin_transaction,
3738
commit_transaction,
3839
destroy_storage,
@@ -107,7 +108,7 @@ def process_message_call(
107108
if message.target == Bytes0(b""):
108109
is_collision = account_has_code_or_nonce(
109110
env.state, message.current_target
110-
)
111+
) or account_has_storage(env.state, message.current_target)
111112
if is_collision:
112113
return MessageCallOutput(
113114
Uint(0), U256(0), tuple(), set(), set(), AddressCollision()

Diff for: src/ethereum/dao_fork/state.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,32 @@ def account_has_code_or_nonce(state: State, address: Address) -> bool:
338338
Returns
339339
-------
340340
has_code_or_nonce : `bool`
341-
True if if an account has non zero nonce or non empty code,
341+
True if the account has non zero nonce or non empty code,
342342
False otherwise.
343343
"""
344344
account = get_account(state, address)
345345
return account.nonce != Uint(0) or account.code != b""
346346

347347

348+
def account_has_storage(state: State, address: Address) -> bool:
349+
"""
350+
Checks if an account has storage.
351+
352+
Parameters
353+
----------
354+
state:
355+
The state
356+
address:
357+
Address of the account that needs to be checked.
358+
359+
Returns
360+
-------
361+
has_storage : `bool`
362+
True if the account has storage, False otherwise.
363+
"""
364+
return address in state._storage_tries
365+
366+
348367
def modify_state(
349368
state: State, address: Address, f: Callable[[Account], None]
350369
) -> None:

0 commit comments

Comments
 (0)