From 63ab5996f4d19eefdad3dbe1c1e6213aabe7b99d Mon Sep 17 00:00:00 2001 From: protolambda Date: Wed, 5 Oct 2022 03:53:22 +0200 Subject: [PATCH 1/3] eip4844: update tx_peek_blob_versioned_hashes to match tx type as defined in EIP PR 5707 (fee market update) --- specs/eip4844/beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/eip4844/beacon-chain.md b/specs/eip4844/beacon-chain.md index 4cf953593..2fe721a7c 100644 --- a/specs/eip4844/beacon-chain.md +++ b/specs/eip4844/beacon-chain.md @@ -167,10 +167,10 @@ See [the full details of `blob_versioned_hashes` offset calculation](https://gis def tx_peek_blob_versioned_hashes(opaque_tx: Transaction) -> Sequence[VersionedHash]: assert opaque_tx[0] == BLOB_TX_TYPE message_offset = 1 + uint32.decode_bytes(opaque_tx[1:5]) - # field offset: 32 + 8 + 32 + 32 + 8 + 4 + 32 + 4 + 4 = 156 + # field offset: 32 + 8 + 32 + 32 + 8 + 4 + 32 + 4 + 4 + 32 = 188 blob_versioned_hashes_offset = ( message_offset - + uint32.decode_bytes(opaque_tx[(message_offset + 156):(message_offset + 160)]) + + uint32.decode_bytes(opaque_tx[(message_offset + 188):(message_offset + 192)]) ) return [ VersionedHash(opaque_tx[x:(x + 32)]) From c7d88b7ce5b57ea08634ff1c4457fcb430f540ef Mon Sep 17 00:00:00 2001 From: protolambda Date: Wed, 5 Oct 2022 04:01:46 +0200 Subject: [PATCH 2/3] eip4844: update test type definition --- tests/core/pyspec/eth2spec/test/helpers/sharding.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/sharding.py b/tests/core/pyspec/eth2spec/test/helpers/sharding.py index 6c90153fc..bf45eaa0f 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/sharding.py +++ b/tests/core/pyspec/eth2spec/test/helpers/sharding.py @@ -34,13 +34,14 @@ class ECDSASignature(Container): class BlobTransaction(Container): chain_id: uint256 nonce: uint64 - priority_fee_per_gas: uint256 - max_basefee_per_gas: uint256 + max_priority_fee_per_gas: uint256 + max_fee_per_gas: uint256 gas: uint64 to: Union[None, Bytes20] # Address = Bytes20 value: uint256 data: ByteList[MAX_CALLDATA_SIZE] access_list: List[AccessTuple, MAX_ACCESS_LIST_SIZE] + max_fee_per_data_gas: uint256 blob_versioned_hashes: List[Bytes32, MAX_VERSIONED_HASHES_LIST_SIZE] From 2d08dc51c5c10aec6a896a86d872fbce7ca0e084 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 6 Oct 2022 18:10:10 +0200 Subject: [PATCH 3/3] eip-4844: test tx_peek_blob_versioned_hashes --- .../test/eip4844/unittests/test_offset.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/core/pyspec/eth2spec/test/eip4844/unittests/test_offset.py diff --git a/tests/core/pyspec/eth2spec/test/eip4844/unittests/test_offset.py b/tests/core/pyspec/eth2spec/test/eip4844/unittests/test_offset.py new file mode 100644 index 000000000..1702ea7e0 --- /dev/null +++ b/tests/core/pyspec/eth2spec/test/eip4844/unittests/test_offset.py @@ -0,0 +1,23 @@ + +from eth2spec.test.helpers.constants import ( + EIP4844, + MINIMAL, +) +from eth2spec.test.helpers.sharding import ( + get_sample_opaque_tx, +) +from eth2spec.test.context import ( + with_phases, + spec_state_test, + with_presets, +) + + +@with_phases([EIP4844]) +@spec_state_test +@with_presets([MINIMAL]) +def test_tx_peek_blob_versioned_hashes(spec, state): + otx, blobs, commitments = get_sample_opaque_tx(spec) + data_hashes = spec.tx_peek_blob_versioned_hashes(otx) + expected = [spec.kzg_commitment_to_versioned_hash(blob_commitment) for blob_commitment in commitments] + assert expected == data_hashes