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

fillers/eips/eip4844/blobhash_opcode.py: Pytest port of Blobhash Opcode Tests #15

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
709cd4d
fillers/eips/eip4844/blobhash_opcode_contexts.py: Start pytest port f…
spencer-tb May 19, 2023
19e7199
fillers/eips/eip4844/blobhash_opcode_contexts.py: Add all contexts.
spencer-tb May 19, 2023
2c5bbb8
fillers/eips/eip4844/blobhash_opcode_contexts.py: Make it more pytest…
spencer-tb May 23, 2023
fcad4fa
fillers/eip4844/opcode_contexts: Refactor with util file.
spencer-tb May 25, 2023
df5c4c5
fillers/eip4844/opcode_contexts: Add comments & small tweaks.
spencer-tb May 26, 2023
859dd04
fillers/eip4844/opcode_contexts: Update after call with Dan.
spencer-tb Jun 1, 2023
d0fbe5d
fillers/eip4844/blobhash_opcode: Port over more tests.
spencer-tb Jun 2, 2023
fea6666
fillers/eip4844/blobhash_opcode_util: Add junk to util function.
spencer-tb Jun 2, 2023
f6f1b7f
fillers/eip4844/blobhash_util: Rename util file.
spencer-tb Jun 2, 2023
6aea674
fillers/eip4844/blobhash: Update to use util function.
spencer-tb Jun 2, 2023
e60c0e5
fillers/eip4844/blobhash_util: Quick text fix.
spencer-tb Jun 2, 2023
91362c6
fillers/eip4844/blobhash_opcode: Final changes.
spencer-tb Jun 2, 2023
f78c1cc
fillers/eip4844/blobhash_opcode_contexts: Remove excessive BLOBHASH.
spencer-tb Jun 2, 2023
fc256d1
fillers/eip4844/blobhash_opcode: Line clean up.
spencer-tb Jun 2, 2023
39bdffc
fillers/eip4844/blobhash_opcode: Pre-emptive validFrom(Cancun).
spencer-tb Jun 2, 2023
d6ef0d2
fillers/point_eval_precompile.py: Update y/z vectors to be big endian…
spencer-tb May 15, 2023
caace59
fillers/point_eval_precompile.py: Fix y/z vectors to be big endian in…
spencer-tb May 15, 2023
e56f14e
fillers/point_eval_precompile.py: Update script to take endian input.
spencer-tb May 30, 2023
8361c93
Minor changes/refactoring.
spencer-tb Jun 6, 2023
00bf2b0
Run with blobhash with pytest, update excessDataGas test case to use …
spencer-tb Jun 6, 2023
fb0c18b
Run with blobhash with pytest, update excessDataGas test case to use …
spencer-tb Jun 6, 2023
9d3d749
Delete old blobhash tests.
spencer-tb Jun 6, 2023
7b77648
Rename blobhash utility file.
spencer-tb Jun 6, 2023
fac62b8
fillers/4844: update precompile vectors from source
marioevz Jun 6, 2023
939cb69
src/helpers: proper typing on add_kzg_version
marioevz Jun 6, 2023
10e43aa
fillers/eip4844: tox fixes
marioevz Jun 6, 2023
9268288
pytest: add 4844 folder
marioevz Jun 6, 2023
351c984
Merge pull request #2 from marioevz/pytest-eip-4844-blobhash-tests
spencer-tb Jun 6, 2023
84428dd
Update/fix test_blobhash_scenarios.
spencer-tb Jun 7, 2023
81ef102
Merge branch 'pytest-eip-4844-blobhash-tests' of https://github.com/s…
spencer-tb Jun 7, 2023
471f464
Update test_blobhash_gas_cost.
spencer-tb Jun 7, 2023
a5b66e7
Formatting.
spencer-tb Jun 7, 2023
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
38 changes: 19 additions & 19 deletions docs/test_case_descriptions/eip4844.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@

**Note:** *This is still a WIP but the tests can still be used by any client team. The priority levels (🔴, 🟠, 🟡, 🟢) represent very high, high, medium, low priorities respectively.*

## 📖 Datahash Opcode
## 📖 Blobhash Opcode

Test Module - `eip4844/datahash_opcode.py`
Test Module - `eip4844/blobhash_opcode.py`

Verifies that the `DATAHASH` opcode, works as intended for a variety of contexts, retrieves the blob versioned hash correctly for a given index, returns the correct zeroed `bytes32` value for out-of-range indices, and consumes the correct amount of gas.
Verifies that the `BLOBHASH` opcode, works as intended for a variety of contexts, retrieves the blob versioned hash correctly for a given index, returns the correct zeroed `bytes32` value for out-of-range indices, and consumes the correct amount of gas.

**1) 🔴 test_datahash_opcode_contexts():**
**1) 🔴 test_blobhash_opcode_contexts():**

Tests that the `DATAHASH` opcode functions correctly when called in different contexts including:
- `DATAHASH` opcode on the top level of the call stack.
- `DATAHASH` opcode on the max value.
- `DATAHASH` opcode on `CALL`, `DELEGATECALL`, `STATICCALL`, and `CALLCODE`.
- `DATAHASH` opcode on Initcode.
- `DATAHASH` opcode on `CREATE` and `CREATE2`.
- `DATAHASH` opcode on transaction types 0, 1 and 2.
Tests that the `BLOBHASH` opcode functions correctly when called in different contexts including:
- `BLOBHASH` opcode on the top level of the call stack.
- `BLOBHASH` opcode on the max value.
- `BLOBHASH` opcode on `CALL`, `DELEGATECALL`, `STATICCALL`, and `CALLCODE`.
- `BLOBHASH` opcode on Initcode.
- `BLOBHASH` opcode on `CREATE` and `CREATE2`.
- `BLOBHASH` opcode on transaction types 0, 1 and 2.

**2) 🔴 test_datahash_blob_versioned_hash():**
**2) 🔴 test_blobhash_blob_versioned_hash():**

Tests that the `DATAHASH` opcode returns the correct versioned hash for various valid indexes. This test covers various scenarios with random `blob_versioned_hash` values within the valid range `[0, 2**256-1]`.
Tests that the `BLOBHASH` opcode returns the correct versioned hash for various valid indexes. This test covers various scenarios with random `blob_versioned_hash` values within the valid range `[0, 2**256-1]`.

**3) 🔴 test_datahash_invalid_blob_index():**
**3) 🔴 test_blobhash_invalid_blob_index():**

Tests that the `DATAHASH` opcode returns a zeroed `bytes32` value for invalid indexes. This test includes cases where the index is negative (`index < 0`) or exceeds the maximum number of `blob_versioned_hash` values stored (`index >= len(tx.message.blob_versioned_hashes)`). It confirms that the returned value is a zeroed `bytes32` value for these cases.
Tests that the `BLOBHASH` opcode returns a zeroed `bytes32` value for invalid indexes. This test includes cases where the index is negative (`index < 0`) or exceeds the maximum number of `blob_versioned_hash` values stored (`index >= len(tx.message.blob_versioned_hashes)`). It confirms that the returned value is a zeroed `bytes32` value for these cases.

**4) 🟠 test_datahash_gas_cost():**
**4) 🟠 test_blobhash_gas_cost():**

Asserts the gas consumption of the `DATAHASH` opcode is correct by ensuring it matches `HASH_OPCODE_GAS = 3`. It includes both valid and invalid random index sizes from the range `[0, 2**256-1]`, for tx types 2 and 3.
Asserts the gas consumption of the `BLOBHASH` opcode is correct by ensuring it matches `HASH_OPCODE_GAS = 3`. It includes both valid and invalid random index sizes from the range `[0, 2**256-1]`, for tx types 2 and 3.

**5) 🟡 test_datahash_multiple_txs_in_block():**
**5) 🟡 test_blobhash_multiple_txs_in_block():**

Tests that the `DATAHASH` opcode returns the appropriate values when there is more than one blob tx type within a block (for tx types 2 and 3). Scenarios involve tx type 3 followed by tx type 2 running the same code within a block. In this case `DATAHASH` returns 0, but for the opposite scenario `DATAHASH` returns the correct `blob_versioned_hash`.
Tests that the `BLOBHASH` opcode returns the appropriate values when there is more than one blob tx type within a block (for tx types 2 and 3). Scenarios involve tx type 3 followed by tx type 2 running the same code within a block. In this case `BLOBHASH` returns 0, but for the opposite scenario `BLOBHASH` returns the correct `blob_versioned_hash`.


## 💽⛽💸 Excess Data Gas
Expand Down
2 changes: 1 addition & 1 deletion docs/writing_tests/adding_a_new_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All test cases are located in the `fillers` directory, which is composed of many
├─╴📁 fillers/ # test cases
│ ├── 📁 eips/
│ | ├── 📁 eip4844/
| | | ├── 📄 datahash_opcode.py
| | | ├── 📄 blobhash_opcode.py
| | | └── 📄 excess_data_gas.py
| | ├── 📄 eip3855.py
| | └── 📄 eip3860.py
Expand Down
38 changes: 19 additions & 19 deletions fillers/eips/eip4844/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@

**Note:** *This is still a WIP but the tests can still be used by any client team. The priority levels (🔴, 🟠, 🟡, 🟢) represent very high, high, medium, low priorities respectively.*

## 📖 Datahash Opcode
## 📖 Blobhash Opcode

Test Module - `eip4844/datahash_opcode.py`
Test Module - `eip4844/blobhash_opcode.py`

Verifies that the `DATAHASH` opcode, works as intended for a variety of contexts, retrieves the blob versioned hash correctly for a given index, returns the correct zeroed `bytes32` value for out-of-range indices, and consumes the correct amount of gas.
Verifies that the `BLOBHASH` opcode, works as intended for a variety of contexts, retrieves the blob versioned hash correctly for a given index, returns the correct zeroed `bytes32` value for out-of-range indices, and consumes the correct amount of gas.

**1) 🔴 test_datahash_opcode_contexts():**
**1) 🔴 test_blobhash_opcode_contexts():**

Tests that the `DATAHASH` opcode functions correctly when called in different contexts including:
- `DATAHASH` opcode on the top level of the call stack.
- `DATAHASH` opcode on the max value.
- `DATAHASH` opcode on `CALL`, `DELEGATECALL`, `STATICCALL`, and `CALLCODE`.
- `DATAHASH` opcode on Initcode.
- `DATAHASH` opcode on `CREATE` and `CREATE2`.
- `DATAHASH` opcode on transaction types 0, 1 and 2.
Tests that the `BLOBHASH` opcode functions correctly when called in different contexts including:
- `BLOBHASH` opcode on the top level of the call stack.
- `BLOBHASH` opcode on the max value.
- `BLOBHASH` opcode on `CALL`, `DELEGATECALL`, `STATICCALL`, and `CALLCODE`.
- `BLOBHASH` opcode on Initcode.
- `BLOBHASH` opcode on `CREATE` and `CREATE2`.
- `BLOBHASH` opcode on transaction types 0, 1 and 2.

**2) 🔴 test_datahash_blob_versioned_hash():**
**2) 🔴 test_blobhash_blob_versioned_hash():**

Tests that the `DATAHASH` opcode returns the correct versioned hash for various valid indexes. This test covers various scenarios with random `blob_versioned_hash` values within the valid range `[0, 2**256-1]`.
Tests that the `BLOBHASH` opcode returns the correct versioned hash for various valid indexes. This test covers various scenarios with random `blob_versioned_hash` values within the valid range `[0, 2**256-1]`.

**3) 🔴 test_datahash_invalid_blob_index():**
**3) 🔴 test_blobhash_invalid_blob_index():**

Tests that the `DATAHASH` opcode returns a zeroed `bytes32` value for invalid indexes. This test includes cases where the index is negative (`index < 0`) or exceeds the maximum number of `blob_versioned_hash` values stored (`index >= len(tx.message.blob_versioned_hashes)`). It confirms that the returned value is a zeroed `bytes32` value for these cases.
Tests that the `BLOBHASH` opcode returns a zeroed `bytes32` value for invalid indexes. This test includes cases where the index is negative (`index < 0`) or exceeds the maximum number of `blob_versioned_hash` values stored (`index >= len(tx.message.blob_versioned_hashes)`). It confirms that the returned value is a zeroed `bytes32` value for these cases.

**4) 🟠 test_datahash_gas_cost():**
**4) 🟠 test_blobhash_gas_cost():**

Asserts the gas consumption of the `DATAHASH` opcode is correct by ensuring it matches `HASH_OPCODE_GAS = 3`. It includes both valid and invalid random index sizes from the range `[0, 2**256-1]`, for tx types 2 and 3.
Asserts the gas consumption of the `BLOBHASH` opcode is correct by ensuring it matches `HASH_OPCODE_GAS = 3`. It includes both valid and invalid random index sizes from the range `[0, 2**256-1]`, for tx types 2 and 3.

**5) 🟡 test_datahash_multiple_txs_in_block():**
**5) 🟡 test_blobhash_multiple_txs_in_block():**

Tests that the `DATAHASH` opcode returns the appropriate values when there is more than one blob tx type within a block (for tx types 2 and 3). Scenarios involve tx type 3 followed by tx type 2 running the same code within a block. In this case `DATAHASH` returns 0, but for the opposite scenario `DATAHASH` returns the correct `blob_versioned_hash`.
Tests that the `BLOBHASH` opcode returns the appropriate values when there is more than one blob tx type within a block (for tx types 2 and 3). Scenarios involve tx type 3 followed by tx type 2 running the same code within a block. In this case `BLOBHASH` returns 0, but for the opposite scenario `BLOBHASH` returns the correct `blob_versioned_hash`.


## 💽⛽💸 Excess Data Gas
Expand Down
2 changes: 1 addition & 1 deletion fillers/eips/eip4844/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""
Cross-client Ethereum EIP-4844 Tests
Cross-client EIP-4844 Tests
"""
2 changes: 1 addition & 1 deletion fillers/eips/eip4844/blob_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
REFERENCE_SPEC_VERSION = "b33e063530f0a114635dd4f89d3cca90f8cac28f"

BLOB_COMMITMENT_VERSION_KZG = 1
DATAHASH_GAS_COST = 3
BLOBHASH_GAS_COST = 3
MIN_DATA_GASPRICE = 1
DATA_GAS_PER_BLOB = 2**17
MAX_DATA_GAS_PER_BLOCK = 2**19
Expand Down
Loading