Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update addresses used in tests #553

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Test fixtures for use by clients are available for each release on the [Github r

### 🧪 Test Cases

- 🔀 Change addresses used in tests to not use 0x100 ([#553](https://github.com/ethereum/execution-spec-tests/pull/553)).
- ✨ Add `test_double_kill` and `test_recreate` which test resurrection of accounts killed with `SELFDESTRUCT` ([#488](https://github.com/ethereum/execution-spec-tests/pull/488)).
- ✨ Add eof example valid invalid tests from ori, fetch EOF Container implementation ([#535](https://github.com/ethereum/execution-spec-tests/pull/535)).

Expand All @@ -33,7 +34,7 @@ Test fixtures for use by clients are available for each release on the [Github r
- ✨ Port entry point scripts to use [click](https://click.palletsprojects.com) and add tests ([#483](https://github.com/ethereum/execution-spec-tests/pull/483)).
- 💥 As part of the pydantic conversion, the fixtures have the following (possibly breaking) changes ([#486](https://github.com/ethereum/execution-spec-tests/pull/486)):
- State test field `transaction` now uses the proper zero-padded hex number format for fields `maxPriorityFeePerGas`, `maxFeePerGas`, and `maxFeePerBlobGas`
- Fixtures' hashes (in the `_info` field) are now calculated by removing the "_info" field entirely instead of it being set to an empty dict.
- Fixtures' hashes (in the `_info` field) are now calculated by removing the "\_info" field entirely instead of it being set to an empty dict.
- 🐞 Relax minor and patch dependency requirements to avoid conflicting package dependencies ([#510](https://github.com/ethereum/execution-spec-tests/pull/510)).
- 🔀 Update all CI actions to use their respective Node.js 20 versions, ahead of their Node.js 16 version deprecations ([#527](https://github.com/ethereum/execution-spec-tests/pull/527)).

Expand All @@ -53,8 +54,8 @@ Test fixtures for use by clients are available for each release on the [Github r

- ✨ Adds two `consume` commands [#339](https://github.com/ethereum/execution-spec-tests/pull/339):

1. `consume direct` - Execute a test fixture directly against a client using a `blocktest`-like command (currently only geth supported).
2. `consume rlp` - Execute a test fixture in a hive simulator against a client that imports the test's genesis config and blocks as RLP upon startup. This is a re-write of the [ethereum/consensus](https://github.com/ethereum/hive/tree/master/simulators/ethereum/consensus) Golang simulator.
1. `consume direct` - Execute a test fixture directly against a client using a `blocktest`-like command (currently only geth supported).
2. `consume rlp` - Execute a test fixture in a hive simulator against a client that imports the test's genesis config and blocks as RLP upon startup. This is a re-write of the [ethereum/consensus](https://github.com/ethereum/hive/tree/master/simulators/ethereum/consensus) Golang simulator.

- ✨ Add Prague to forks ([#419](https://github.com/ethereum/execution-spec-tests/pull/419)).
- ✨ Improve handling of the argument passed to `solc --evm-version` when compiling Yul code ([#418](https://github.com/ethereum/execution-spec-tests/pull/418)).
Expand Down Expand Up @@ -196,9 +197,9 @@ The fixture renaming provides a more consistent naming scheme between the pytest
1. Previous fixture file name: `fixtures/frontier/opcodes/dup/dup.json` (`BlockChainTest` format).
2. New fixture file names (all present within the release tarball):

- `fixtures/state_tests/frontier/opcodes/dup/dup.json` (`StateTest` format).
- `fixtures/blockchain_tests/frontier/opcodes/dup/dup.json` (`BlockChainTest` format).
- `fixtures/blockchain_tests_hive/frontier/opcodes/dup/dup.json` (a blockchain test in `HiveFixture` format).
- `fixtures/state_tests/frontier/opcodes/dup/dup.json` (`StateTest` format).
- `fixtures/blockchain_tests/frontier/opcodes/dup/dup.json` (`BlockChainTest` format).
- `fixtures/blockchain_tests_hive/frontier/opcodes/dup/dup.json` (a blockchain test in `HiveFixture` format).

## [v1.0.6](https://github.com/ethereum/execution-spec-tests/releases/tag/v1.0.6) - 2023-10-19: 🐍🏖️ Cancun Devnet 10

Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_test_tools/tests/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def test_switch(tx_data: bytes, switch_bytecode: bytes, expected_storage: Mappin
"""
Test that the switch opcode macro gets executed as using the t8n tool.
"""
code_address = 0x100
code_address = 0xC0DE
pre = {
TestAddress: Account(balance=10_000_000, nonce=0),
code_address: Account(code=switch_bytecode),
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_test_tools/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ def test_transaction_post_init_defaults(tx_args, expected_attributes_and_values)
Withdrawal(
index=0,
validator_index=0,
address=0x100,
address=0x1000,
amount=0,
),
Withdrawal(
Expand Down
1 change: 0 additions & 1 deletion stubs/trie/hexary.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Dict


class HexaryTrie:
db: Dict
root_hash: bytes
Expand Down
2 changes: 1 addition & 1 deletion tests/byzantium/eip198_modexp_precompile/test_modexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_modexp(state_test: StateTestFiller, input: ModExpInput, output: Expecte
env = Environment()
pre = {TestAddress: Account(balance=1000000000000000000000)}

account = Address(0x100)
account = Address(0x1000)

pre[account] = Account(
code=(
Expand Down
2 changes: 1 addition & 1 deletion tests/cancun/eip1153_tstore/test_tstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

pytestmark = [pytest.mark.valid_from("Cancun")]

code_address = 0x100
code_address = 0xC0DE


def test_transient_storage_unset_values(state_test: StateTestFiller):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
pytestmark = [pytest.mark.valid_from("Cancun")]

# the address that creates the contract with create/create2
creator_address = 0x100
creator_address = 0x1000


@unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
pytestmark = [pytest.mark.valid_from("Cancun")]

# Address used to call the test bytecode on every test case.
caller_address = 0x100
caller_address = 0x1000

# Address of the callee contract
callee_address = 0x200
callee_address = 0x2000

PUSH_OPCODE_COST = 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pytestmark = [pytest.mark.valid_from("Cancun")]

# Address of the callee contract
callee_address = 0x200
callee_address = 0x2000

SETUP_CONDITION: bytes = Op.EQ(Op.CALLDATALOAD(0), 0x01)
REENTRANT_CALL: bytes = Op.MSTORE(0, 2) + Op.SSTORE(
Expand Down
4 changes: 2 additions & 2 deletions tests/cancun/eip1153_tstore/test_tstorage_selfdestruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
pytestmark = [pytest.mark.valid_from("Cancun")]

# Addresses
caller_address = 0x100
copy_from_initcode_address = 0x200
caller_address = 0x1000
copy_from_initcode_address = 0x2000
callee_address = compute_create_address(caller_address, 1)

CREATE_CODE = Op.EXTCODECOPY(
Expand Down
2 changes: 1 addition & 1 deletion tests/cancun/eip4788_beacon_root/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def call_gas() -> int: # noqa: D103

@pytest.fixture
def caller_address() -> Address: # noqa: D103
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down
8 changes: 4 additions & 4 deletions tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def test_multi_block_beacon_root_timestamp_calls(

current_call_account_code = bytes()
current_call_account_expected_storage = Storage()
current_call_account_address = Address(0x100 + i)
current_call_account_address = Address(0x1000 + i)

# We are going to call the beacon roots contract once for every timestamp of the current
# and all previous blocks, and check that the returned beacon root is still correct only
Expand Down Expand Up @@ -421,7 +421,7 @@ def test_multi_block_beacon_root_timestamp_calls(
txs=[
tx.copy(
nonce=i,
to=Address(0x100 + i),
to=Address(0x1000 + i),
data=Hash(timestamp),
)
],
Expand Down Expand Up @@ -503,7 +503,7 @@ def test_beacon_root_transition(

current_call_account_code = bytes()
current_call_account_expected_storage = Storage()
current_call_account_address = Address(0x100 + i)
current_call_account_address = Address(0x1000 + i)

# We are going to call the beacon roots contract once for every timestamp of the current
# and all previous blocks, and check that the returned beacon root is correct only
Expand Down Expand Up @@ -546,7 +546,7 @@ def test_beacon_root_transition(
txs=[
tx.copy(
nonce=i,
to=Address(0x100 + i),
to=Address(0x1000 + i),
data=Hash(timestamp),
)
],
Expand Down
21 changes: 11 additions & 10 deletions tests/cancun/eip4844_blobs/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common constants, classes & functions local to EIP-4844 tests.
"""

from dataclasses import dataclass
from typing import List, Literal, Tuple, Union

Expand Down Expand Up @@ -100,14 +101,14 @@ class BlobhashContext:

yul_compiler: Union[YulCompiler, None] = None
addresses = {
"blobhash_sstore": Address(0x100),
"blobhash_return": Address(0x600),
"call": Address(0x200),
"delegatecall": Address(0x300),
"callcode": Address(0x800),
"staticcall": Address(0x700),
"create": Address(0x400),
"create2": Address(0x500),
"blobhash_sstore": Address(0x1000),
"blobhash_return": Address(0x6000),
"call": Address(0x2000),
"delegatecall": Address(0x3000),
"callcode": Address(0x8000),
"staticcall": Address(0x7000),
"create": Address(0x4000),
"create2": Address(0x5000),
}

@staticmethod
Expand Down Expand Up @@ -173,15 +174,15 @@ def code(cls, context_name):
"""
{
calldatacopy(0, 0, calldatasize())
pop(call(gas(), 0x100, 0, 0, calldatasize(), 0, 0))
pop(call(gas(), 0x1000, 0, 0, calldatasize(), 0, 0))
}
""" # noqa: E272, E201, E202
),
"delegatecall": cls.yul_compiler(
"""
{
calldatacopy(0, 0, calldatasize())
pop(delegatecall(gas(), 0x100, 0, calldatasize(), 0, 0))
pop(delegatecall(gas(), 0x1000, 0, calldatasize(), 0, 0))
}
""" # noqa: E272, E201, E202
),
Expand Down
3 changes: 2 additions & 1 deletion tests/cancun/eip4844_blobs/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Pytest (plugin) definitions local to EIP-4844 tests.
"""

import pytest

from ethereum_test_tools import Address, Block, Hash, TestPrivateKey2, Transaction, add_kzg_version
Expand Down Expand Up @@ -41,7 +42,7 @@ def non_zero_blob_gas_used_genesis_block(
Transaction(
ty=Spec.BLOB_TX_TYPE,
nonce=0,
to=Address(0x200),
to=Address(0x2000),
value=1,
gas_limit=21000,
max_fee_per_gas=tx_max_fee_per_gas,
Expand Down
2 changes: 1 addition & 1 deletion tests/cancun/eip4844_blobs/test_blob_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
@pytest.fixture
def destination_account() -> Address:
"""Default destination account for the blob transactions."""
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion tests/cancun/eip4844_blobs/test_blob_txs_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Test full blob type transactions for [EIP-4844: Shard Blob Transactions](https://eips.ethereum.org/EIPS/eip-4844).

""" # noqa: E501

from typing import Dict, List, Optional

import pytest
Expand Down Expand Up @@ -30,7 +31,7 @@
@pytest.fixture
def destination_account() -> Address:
"""Default destination account for the blob transactions."""
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down
24 changes: 12 additions & 12 deletions tests/cancun/eip4844_blobs/test_blobhash_opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_blobhash_gas_cost(
for i in blobhash_index_values
]
for i, gas_code in enumerate(gas_measures_code):
address = Address(0x100 + i * 0x100)
address = Address(0x1000 + i * 0x1000)
pre[address] = Account(code=gas_code)
blocks.append(
Block(
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_blobhash_scenarios(
b_hashes_list = BlobhashScenario.create_blob_hashes_list(length=TOTAL_BLOCKS)
blobhash_calls = BlobhashScenario.generate_blobhash_bytecode(scenario)
for i in range(TOTAL_BLOCKS):
address = Address(0x100 + i * 0x100)
address = Address(0x1000 + i * 0x1000)
pre[address] = Account(code=blobhash_calls)
blocks.append(
Block(
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_blobhash_invalid_blob_index(
TOTAL_BLOCKS = 5
blobhash_calls = BlobhashScenario.generate_blobhash_bytecode(scenario)
for i in range(TOTAL_BLOCKS):
address = Address(0x100 + i * 0x100)
address = Address(0x1000 + i * 0x1000)
pre[address] = Account(code=blobhash_calls)
blob_per_block = (i % SpecHelpers.max_blobs_per_block()) + 1
blobs = [random_blob_hashes[blob] for blob in range(blob_per_block)]
Expand Down Expand Up @@ -287,36 +287,36 @@ def test_blobhash_multiple_txs_in_block(
**pre,
**{
Address(address): Account(code=blobhash_bytecode)
for address in range(0x100, 0x500, 0x100)
for address in range(0x1000, 0x5000, 0x1000)
},
}
blocks = [
Block(
txs=[
blob_tx(address=Address(0x100), type=3, nonce=0),
blob_tx(address=Address(0x100), type=2, nonce=1),
blob_tx(address=Address(0x1000), type=3, nonce=0),
blob_tx(address=Address(0x1000), type=2, nonce=1),
]
),
Block(
txs=[
blob_tx(address=Address(0x200), type=2, nonce=2),
blob_tx(address=Address(0x200), type=3, nonce=3),
blob_tx(address=Address(0x2000), type=2, nonce=2),
blob_tx(address=Address(0x2000), type=3, nonce=3),
]
),
Block(
txs=[
blob_tx(address=Address(0x300), type=2, nonce=4),
blob_tx(address=Address(0x400), type=3, nonce=5),
blob_tx(address=Address(0x3000), type=2, nonce=4),
blob_tx(address=Address(0x4000), type=3, nonce=5),
],
),
]
post = {
Address(address): Account(
storage={i: random_blob_hashes[i] for i in range(SpecHelpers.max_blobs_per_block())}
)
if address in (0x200, 0x400)
if address in (0x2000, 0x4000)
else Account(storage={i: 0 for i in range(SpecHelpers.max_blobs_per_block())})
for address in range(0x100, 0x500, 0x100)
for address in range(0x1000, 0x5000, 0x1000)
}
blockchain_test(
pre=pre,
Expand Down
2 changes: 1 addition & 1 deletion tests/cancun/eip4844_blobs/test_excess_blob_gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def destination_account_bytecode() -> bytes: # noqa: D103

@pytest.fixture
def destination_account() -> Address: # noqa: D103
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def blob_count_per_block() -> int:

@pytest.fixture
def destination_account() -> Address: # noqa: D103
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
cases.

""" # noqa: E501

import glob
import json
import os
Expand Down Expand Up @@ -157,7 +158,7 @@ def precompile_caller_address() -> Address:
"""
Address of the precompile caller account.
"""
return Address(0x100)
return Address(0x1000)


@pytest.fixture
Expand Down Expand Up @@ -589,7 +590,7 @@ def test_point_evaluation_precompile_before_fork(
0,
),
)
precompile_caller_address = Address(0x100)
precompile_caller_address = Address(0x1000)

pre = {
TestAddress: Account(
Expand Down Expand Up @@ -648,7 +649,7 @@ def test_point_evaluation_precompile_during_fork(
0,
),
)
precompile_caller_address = Address(0x100)
precompile_caller_address = Address(0x1000)

pre = {
TestAddress: Account(
Expand Down
Loading