Skip to content

Commit cf421d1

Browse files
authored
Update fixtures to the v6.0.0-beta.3 release (#1644)
* Fix exception during fixture failures * Add ByzantiumToConstantinopleAt5 network * Check for DAO extradata while running blockchain tests * extcodehash should treat empty accounts as non-existent
1 parent ca0844c commit cf421d1

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

eth/tools/fixtures/helpers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from eth.chains.base import (
2525
BaseChain,
2626
)
27+
from eth.chains.mainnet import (
28+
MainnetDAOValidatorVM,
29+
)
2730
from eth.db.account import (
2831
BaseAccountDB,
2932
)
@@ -141,7 +144,7 @@ def chain_vm_configuration(fixture: Dict[str, Any]) -> Iterable[Tuple[int, Type[
141144
(5, TangerineWhistleVM),
142145
)
143146
elif network == 'HomesteadToDaoAt5':
144-
HomesteadVM = BaseHomesteadVM.configure(
147+
HomesteadVM = MainnetDAOValidatorVM.configure(
145148
support_dao_fork=True,
146149
_dao_fork_block_number=5,
147150
)
@@ -153,6 +156,11 @@ def chain_vm_configuration(fixture: Dict[str, Any]) -> Iterable[Tuple[int, Type[
153156
(0, SpuriousDragonVM),
154157
(5, ByzantiumVM),
155158
)
159+
elif network == 'ByzantiumToConstantinopleAt5':
160+
return (
161+
(0, ByzantiumVM),
162+
(5, ConstantinopleVM),
163+
)
156164
else:
157165
raise ValueError("Network {0} does not match any known VM rules".format(network))
158166

eth/vm/logic/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def extcodehash(computation: BaseComputation) -> None:
151151
account = force_bytes_to_address(computation.stack_pop(type_hint=constants.BYTES))
152152
account_db = computation.state.account_db
153153

154-
if not account_db.account_exists(account):
154+
if account_db.account_is_empty(account):
155155
computation.stack_push(constants.NULL_BYTE)
156156
else:
157157
computation.stack_push(account_db.get_code_hash(account))

fixtures

Submodule fixtures updated 10507 files

tests/core/opcodes/test_opcodes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
ADDRESS_WITH_CODE = ("0xddd722f3947def4cf144679da39c4c32bdc35681", b'pseudocode')
4343
EMPTY_ADDRESS_IN_STATE = NORMALIZED_ADDRESS_A
4444
ADDRESS_NOT_IN_STATE = NORMALIZED_ADDRESS_B
45+
ADDRESS_WITH_JUST_BALANCE = "0x0000000000000000000000000000000000000001"
4546
CANONICAL_ADDRESS_A = to_canonical_address("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6")
4647
CANONICAL_ADDRESS_B = to_canonical_address("0xcd1722f3947def4cf144679da39c4c32bdc35681")
4748
GENESIS_HEADER = BlockHeader(
@@ -86,6 +87,8 @@ def prepare_general_computation(vm_class, create_address=None, code=b''):
8687
computation.state.account_db.touch_account(decode_hex(EMPTY_ADDRESS_IN_STATE))
8788
computation.state.account_db.set_code(decode_hex(ADDRESS_WITH_CODE[0]), ADDRESS_WITH_CODE[1])
8889

90+
computation.state.account_db.set_balance(decode_hex(ADDRESS_WITH_JUST_BALANCE), 1)
91+
8992
return computation
9093

9194

@@ -446,6 +449,11 @@ def test_sar(vm_class, val1, val2, expected):
446449
(
447450
ConstantinopleVM,
448451
EMPTY_ADDRESS_IN_STATE,
452+
'0x0000000000000000000000000000000000000000000000000000000000000000',
453+
),
454+
(
455+
ConstantinopleVM,
456+
ADDRESS_WITH_JUST_BALANCE,
449457
'0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470',
450458
),
451459
(

tests/json-fixtures/test_blockchain.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_blockchain_fixtures(fixture_data, fixture):
226226
try:
227227
chain = new_chain_from_fixture(fixture)
228228
except ValueError as e:
229-
raise AssertionError("could not load chain for %r" % fixture_data) from e
229+
raise AssertionError("could not load chain for {}".format((fixture_data,))) from e
230230

231231
genesis_params = genesis_params_from_fixture(fixture)
232232
expected_genesis_header = BlockHeader(**genesis_params)
@@ -274,7 +274,6 @@ def test_blockchain_fixtures(fixture_data, fixture):
274274
latest_block_hash = chain.get_canonical_block_by_number(chain.get_block().number - 1).hash
275275
if latest_block_hash != fixture['lastblockhash']:
276276
verify_account_db(fixture['postState'], chain.get_vm().state.account_db)
277-
assert False, 'the state must be different if the hashes are'
278277

279278
for block, mined_block in mined_blocks:
280279
assert_mined_block_unchanged(block, mined_block)

0 commit comments

Comments
 (0)