From eb5a2c2741aa49ffb545181657780d0e75380c78 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 17 Oct 2022 15:16:38 -0700 Subject: [PATCH 1/7] Couple beacon block and blob sidecar for p2p --- specs/eip4844/p2p-interface.md | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index eab8815a4..7757ed9c2 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -58,6 +58,14 @@ class SignedBlobsSidecar(Container): signature: BLSSignature ``` +### `SignedBeaconBlockAndBlobsSidecar` + +```python +class SignedBeaconBlockAndBlobsSidecar(Container): + beacon_block: SignedBeaconBlock + blobs_sidecar: SignedBlobsSidecar +``` + ## The gossip domain: gossipsub Some gossip meshes are upgraded in the fork of EIP4844 to support upgraded types. @@ -75,33 +83,25 @@ The new topics along with the type of the `data` field of a gossipsub message ar | Name | Message Type | | - | - | -| `beacon_block` | `SignedBeaconBlock` (modified) | -| `blobs_sidecar` | `SignedBlobsSidecar` (new) | +| `beacon_block_and_blob_sidecar` | `SignedBeaconBlockAndBlobsSidecar` (new) | -Note that the `ForkDigestValue` path segment of the topic separates the old and the new `beacon_block` topics. #### Global topics -EIP4844 changes the type of the global beacon block topic and introduces a new global topic for blobs-sidecars. +EIP4844 introduces a new global topic for beacon block and blobs-sidecars. -##### `beacon_block` +##### `beacon_block_and_blob_sidecar` -The *type* of the payload of this topic changes to the (modified) `SignedBeaconBlock` found in EIP4844. +This topic is used to propagate new signed and coupled beacon blocks and blobs sidecars to all nodes on the networks. -In addition to the gossip validations for this topic from prior specifications, -the following validations MUST pass before forwarding the `signed_beacon_block` on the network. -Alias `block = signed_beacon_block.message`, `execution_payload = block.body.execution_payload`. +The following validations MUST pass before forwarding the `signed_beacon_block_and_blobs_sidecar` on the network; +Alias `signed_beacon_block = signed_beacon_block_and_blobs_sidecar.beacon_block`, `block = signed_beacon_block.message`, `execution_payload = block.body.execution_payload`. - _[REJECT]_ The KZG commitments of the blobs are all correctly encoded compressed BLS G1 Points. -- i.e. `all(bls.KeyValidate(commitment) for commitment in block.body.blob_kzg_commitments)` - _[REJECT]_ The KZG commitments correspond to the versioned hashes in the transactions list. -- i.e. `verify_kzg_commitments_against_transactions(block.body.execution_payload.transactions, block.body.blob_kzg_commitments)` -##### `blobs_sidecar` - -This topic is used to propagate data blobs included in any given beacon block. - -The following validations MUST pass before forwarding the `signed_blobs_sidecar` on the network; -Alias `sidecar = signed_blobs_sidecar.message`. +Alias `sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar.message`. - _[IGNORE]_ the `sidecar.beacon_block_slot` is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. `sidecar.beacon_block_slot == current_slot`. - _[REJECT]_ the `sidecar.blobs` are all well formatted, i.e. the `BLSFieldElement` in valid range (`x < BLS_MODULUS`). - _[REJECT]_ The KZG proof is a correctly encoded compressed BLS G1 Point -- i.e. `bls.KeyValidate(blobs_sidecar.kzg_aggregated_proof)` @@ -113,10 +113,9 @@ Alias `sidecar = signed_blobs_sidecar.message`. - _[IGNORE]_ The sidecar is the first sidecar with valid signature received for the `(proposer_index, sidecar.beacon_block_slot)` combination, where `proposer_index` is the validator index of the beacon block proposer of `sidecar.beacon_block_slot` -Note that a sidecar may be propagated before or after the corresponding beacon block. - Once both sidecar and beacon block are received, `validate_blobs_sidecar` can unlock the data-availability fork-choice dependency. + ### Transitioning the gossip See gossip transition details found in the [Altair document](../altair/p2p-interface.md#transitioning-the-gossip) for From 96b90200b79cd4dab7821c544821abb8c197aa26 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 17 Oct 2022 15:59:48 -0700 Subject: [PATCH 2/7] Fix ToC --- specs/eip4844/p2p-interface.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index 7757ed9c2..799370748 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -14,11 +14,11 @@ The specification of these changes continues in the same format as the network s - [Containers](#containers) - [`BlobsSidecar`](#blobssidecar) - [`SignedBlobsSidecar`](#signedblobssidecar) + - [`SignedBeaconBlockAndBlobsSidecar`](#signedbeaconblockandblobssidecar) - [The gossip domain: gossipsub](#the-gossip-domain-gossipsub) - [Topics and messages](#topics-and-messages) - [Global topics](#global-topics) - - [`beacon_block`](#beacon_block) - - [`blobs_sidecar`](#blobs_sidecar) + - [`beacon_block_and_blob_sidecar`](#beacon_block_and_blob_sidecar) - [Transitioning the gossip](#transitioning-the-gossip) - [The Req/Resp domain](#the-reqresp-domain) - [Messages](#messages) @@ -94,14 +94,14 @@ EIP4844 introduces a new global topic for beacon block and blobs-sidecars. This topic is used to propagate new signed and coupled beacon blocks and blobs sidecars to all nodes on the networks. -The following validations MUST pass before forwarding the `signed_beacon_block_and_blobs_sidecar` on the network; +The following validations MUST pass before forwarding the `signed_beacon_block_and_blobs_sidecar` on the network. Alias `signed_beacon_block = signed_beacon_block_and_blobs_sidecar.beacon_block`, `block = signed_beacon_block.message`, `execution_payload = block.body.execution_payload`. - _[REJECT]_ The KZG commitments of the blobs are all correctly encoded compressed BLS G1 Points. -- i.e. `all(bls.KeyValidate(commitment) for commitment in block.body.blob_kzg_commitments)` - _[REJECT]_ The KZG commitments correspond to the versioned hashes in the transactions list. -- i.e. `verify_kzg_commitments_against_transactions(block.body.execution_payload.transactions, block.body.blob_kzg_commitments)` -Alias `sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar.message`. +Alias `signed_blobs_sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar`, `sidecar = signed_blobs_sidecar.message`. - _[IGNORE]_ the `sidecar.beacon_block_slot` is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. `sidecar.beacon_block_slot == current_slot`. - _[REJECT]_ the `sidecar.blobs` are all well formatted, i.e. the `BLSFieldElement` in valid range (`x < BLS_MODULUS`). - _[REJECT]_ The KZG proof is a correctly encoded compressed BLS G1 Point -- i.e. `bls.KeyValidate(blobs_sidecar.kzg_aggregated_proof)` @@ -115,7 +115,6 @@ Alias `sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar.message`. Once both sidecar and beacon block are received, `validate_blobs_sidecar` can unlock the data-availability fork-choice dependency. - ### Transitioning the gossip See gossip transition details found in the [Altair document](../altair/p2p-interface.md#transitioning-the-gossip) for From 779d9be66a3eb1231a35a52299216253b8ed4d6a Mon Sep 17 00:00:00 2001 From: terencechain Date: Tue, 18 Oct 2022 11:22:43 -0700 Subject: [PATCH 3/7] Compare sidecar slot with block slot Co-authored-by: protolambda --- specs/eip4844/p2p-interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index 799370748..4856dd59c 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -102,7 +102,7 @@ Alias `signed_beacon_block = signed_beacon_block_and_blobs_sidecar.beacon_block` -- i.e. `verify_kzg_commitments_against_transactions(block.body.execution_payload.transactions, block.body.blob_kzg_commitments)` Alias `signed_blobs_sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar`, `sidecar = signed_blobs_sidecar.message`. -- _[IGNORE]_ the `sidecar.beacon_block_slot` is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. `sidecar.beacon_block_slot == current_slot`. +- _[IGNORE]_ the `sidecar.beacon_block_slot` is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. `sidecar.beacon_block_slot == block.slot`. - _[REJECT]_ the `sidecar.blobs` are all well formatted, i.e. the `BLSFieldElement` in valid range (`x < BLS_MODULUS`). - _[REJECT]_ The KZG proof is a correctly encoded compressed BLS G1 Point -- i.e. `bls.KeyValidate(blobs_sidecar.kzg_aggregated_proof)` - _[REJECT]_ the beacon proposer signature, `signed_blobs_sidecar.signature`, is valid -- i.e. From cab2e3ef9a5978e87b773894118ab8496c5fc79b Mon Sep 17 00:00:00 2001 From: terencechain Date: Tue, 18 Oct 2022 11:23:19 -0700 Subject: [PATCH 4/7] Describe sidecar and block are recieved together Co-authored-by: protolambda --- specs/eip4844/p2p-interface.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index 4856dd59c..42aa9e907 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -113,7 +113,7 @@ Alias `signed_blobs_sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sideca - _[IGNORE]_ The sidecar is the first sidecar with valid signature received for the `(proposer_index, sidecar.beacon_block_slot)` combination, where `proposer_index` is the validator index of the beacon block proposer of `sidecar.beacon_block_slot` -Once both sidecar and beacon block are received, `validate_blobs_sidecar` can unlock the data-availability fork-choice dependency. +Once the sidecar and beacon block are received together, `validate_blobs_sidecar` can unlock the data-availability fork-choice dependency. ### Transitioning the gossip From dfa5ac80080475e05fc1e9d0c236c719ed853557 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Tue, 18 Oct 2022 11:34:14 -0700 Subject: [PATCH 5/7] @protolambda's feedback, `SignedBlobsSidecar` -> `BlobsSidecar` --- specs/eip4844/p2p-interface.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index 42aa9e907..735230027 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -63,7 +63,7 @@ class SignedBlobsSidecar(Container): ```python class SignedBeaconBlockAndBlobsSidecar(Container): beacon_block: SignedBeaconBlock - blobs_sidecar: SignedBlobsSidecar + blobs_sidecar: BlobsSidecar ``` ## The gossip domain: gossipsub @@ -101,17 +101,10 @@ Alias `signed_beacon_block = signed_beacon_block_and_blobs_sidecar.beacon_block` - _[REJECT]_ The KZG commitments correspond to the versioned hashes in the transactions list. -- i.e. `verify_kzg_commitments_against_transactions(block.body.execution_payload.transactions, block.body.blob_kzg_commitments)` -Alias `signed_blobs_sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar`, `sidecar = signed_blobs_sidecar.message`. +Alias `sidecar = signed_beacon_block_and_blobs_sidecar.blobs_sidecar`. - _[IGNORE]_ the `sidecar.beacon_block_slot` is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance) -- i.e. `sidecar.beacon_block_slot == block.slot`. - _[REJECT]_ the `sidecar.blobs` are all well formatted, i.e. the `BLSFieldElement` in valid range (`x < BLS_MODULUS`). - _[REJECT]_ The KZG proof is a correctly encoded compressed BLS G1 Point -- i.e. `bls.KeyValidate(blobs_sidecar.kzg_aggregated_proof)` -- _[REJECT]_ the beacon proposer signature, `signed_blobs_sidecar.signature`, is valid -- i.e. - - Let `domain = get_domain(state, DOMAIN_BLOBS_SIDECAR, sidecar.beacon_block_slot // SLOTS_PER_EPOCH)` - - Let `signing_root = compute_signing_root(sidecar, domain)` - - Verify `bls.Verify(proposer_pubkey, signing_root, signed_blobs_sidecar.signature) is True`, - where `proposer_pubkey` is the pubkey of the beacon block proposer of `sidecar.beacon_block_slot` -- _[IGNORE]_ The sidecar is the first sidecar with valid signature received for the `(proposer_index, sidecar.beacon_block_slot)` combination, - where `proposer_index` is the validator index of the beacon block proposer of `sidecar.beacon_block_slot` Once the sidecar and beacon block are received together, `validate_blobs_sidecar` can unlock the data-availability fork-choice dependency. From 9f4ae4c6eeb281a76788900ae2552a59a7f55eb1 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Fri, 21 Oct 2022 17:33:55 -0700 Subject: [PATCH 6/7] Update validator spec with `SignedBeaconBlockAndBlobsSidecar` --- specs/eip4844/p2p-interface.md | 6 +++--- specs/eip4844/validator.md | 33 +++++++++++++-------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/specs/eip4844/p2p-interface.md b/specs/eip4844/p2p-interface.md index 735230027..2162ab161 100644 --- a/specs/eip4844/p2p-interface.md +++ b/specs/eip4844/p2p-interface.md @@ -18,7 +18,7 @@ The specification of these changes continues in the same format as the network s - [The gossip domain: gossipsub](#the-gossip-domain-gossipsub) - [Topics and messages](#topics-and-messages) - [Global topics](#global-topics) - - [`beacon_block_and_blob_sidecar`](#beacon_block_and_blob_sidecar) + - [`beacon_block_and_blobs_sidecar`](#beacon_block_and_blobs_sidecar) - [Transitioning the gossip](#transitioning-the-gossip) - [The Req/Resp domain](#the-reqresp-domain) - [Messages](#messages) @@ -83,14 +83,14 @@ The new topics along with the type of the `data` field of a gossipsub message ar | Name | Message Type | | - | - | -| `beacon_block_and_blob_sidecar` | `SignedBeaconBlockAndBlobsSidecar` (new) | +| `beacon_block_and_blobs_sidecar` | `SignedBeaconBlockAndBlobsSidecar` (new) | #### Global topics EIP4844 introduces a new global topic for beacon block and blobs-sidecars. -##### `beacon_block_and_blob_sidecar` +##### `beacon_block_and_blobs_sidecar` This topic is used to propagate new signed and coupled beacon blocks and blobs sidecars to all nodes on the networks. diff --git a/specs/eip4844/validator.md b/specs/eip4844/validator.md index e1bcf9564..18623659a 100644 --- a/specs/eip4844/validator.md +++ b/specs/eip4844/validator.md @@ -192,9 +192,9 @@ def get_blobs_and_kzg_commitments(payload_id: PayloadId) -> Tuple[Sequence[BLSFi ## Beacon chain responsibilities All validator responsibilities remain unchanged other than those noted below. -Namely, the blob handling and the addition of `BlobsSidecar`. +Namely, the blob handling and the addition of `SignedBeaconBlockAndBlobsSidecar`. -### Block proposal +### Block and sidecar proposal #### Constructing the `BeaconBlockBody` @@ -218,13 +218,16 @@ def validate_blobs_and_kzg_commitments(execution_payload: ExecutionPayload, 3. If valid, set `block.body.blob_kzg_commitments = blob_kzg_commitments`. -Note that the `blobs` should be held with the block in preparation of publishing. -Without the `blobs`, the published block will effectively be ignored by honest validators. +#### Constructing the `SignedBeaconBlockAndBlobsSidecar` +To construct a `SignedBeaconBlockAndBlobsSidecar`, a `signed_beacon_block_and_blobs_sidecar` is defined with the necessary context for block and sidecar proposal. -### Beacon Block publishing time +##### Block +Set `signed_beacon_block_and_blobs_sidecar.beacon_block = block` where `block` is obtained above. -Before publishing a prepared beacon block proposal, the corresponding blobs are packaged into a sidecar object for distribution to the network: +##### Sidecar +Coupled with block, the corresponding blobs are packaged into a sidecar object for distribution to the network. +Set `signed_beacon_block_and_blobs_sidecar.blobs_sidecar = sidecar` where `sidecar` is obtained from: ```python def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobsSidecar: return BlobsSidecar( @@ -235,20 +238,10 @@ def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobsSidecar ) ``` -And then signed: +This `signed_beacon_block_and_blobs_sidecar` is then published to the global `beacon_block_and_blobs_sidecar` topic. -```python -def get_signed_blobs_sidecar(state: BeaconState, blobs_sidecar: BlobsSidecar, privkey: int) -> SignedBlobsSidecar: - domain = get_domain(state, DOMAIN_BLOBS_SIDECAR, blobs_sidecar.beacon_block_slot // SLOTS_PER_EPOCH) - signing_root = compute_signing_root(blobs_sidecar, domain) - signature = bls.Sign(privkey, signing_root) - return SignedBlobsSidecar(message=blobs_sidecar, signature=signature) -``` - -This `signed_blobs_sidecar` is then published to the global `blobs_sidecar` topic as soon as the `signed_beacon_block` is published. - -After publishing the sidecar peers on the network may request the sidecar through sync-requests, or a local user may be interested. -The validator MUST hold on to blobs for `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` epochs and serve when capable, +After publishing the peers on the network may request the sidecar through sync-requests, or a local user may be interested. +The validator MUST hold on to sidecars for `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` epochs and serve when capable, to ensure the data-availability of these blobs throughout the network. -After `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` nodes MAY prune the blobs and/or stop serving them. +After `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` nodes MAY prune the sidecars and/or stop serving them. From e2d0a4fa9a64ee5f08e116a2b31f38c30527dab5 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sat, 22 Oct 2022 08:13:14 -0700 Subject: [PATCH 7/7] Fix ToC and test --- specs/eip4844/validator.md | 6 ++++-- .../test/eip4844/unittests/validator/test_validator.py | 3 --- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/specs/eip4844/validator.md b/specs/eip4844/validator.md index 18623659a..0cd420637 100644 --- a/specs/eip4844/validator.md +++ b/specs/eip4844/validator.md @@ -23,10 +23,12 @@ - [`compute_proof_from_blobs`](#compute_proof_from_blobs) - [`get_blobs_and_kzg_commitments`](#get_blobs_and_kzg_commitments) - [Beacon chain responsibilities](#beacon-chain-responsibilities) - - [Block proposal](#block-proposal) + - [Block and sidecar proposal](#block-and-sidecar-proposal) - [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody) - [Blob KZG commitments](#blob-kzg-commitments) - - [Beacon Block publishing time](#beacon-block-publishing-time) + - [Constructing the `SignedBeaconBlockAndBlobsSidecar`](#constructing-the-signedbeaconblockandblobssidecar) + - [Block](#block) + - [Sidecar](#sidecar) diff --git a/tests/core/pyspec/eth2spec/test/eip4844/unittests/validator/test_validator.py b/tests/core/pyspec/eth2spec/test/eip4844/unittests/validator/test_validator.py index d0250f3df..680a0a9c4 100644 --- a/tests/core/pyspec/eth2spec/test/eip4844/unittests/validator/test_validator.py +++ b/tests/core/pyspec/eth2spec/test/eip4844/unittests/validator/test_validator.py @@ -12,7 +12,6 @@ from eth2spec.test.helpers.sharding import ( get_sample_opaque_tx, get_sample_blob, ) -from eth2spec.test.helpers.keys import privkeys @with_eip4844_and_later @@ -38,8 +37,6 @@ def _run_validate_blobs_sidecar_test(spec, state, blob_count): state_transition_and_sign_block(spec, state, block) blobs_sidecar = spec.get_blobs_sidecar(block, blobs) - privkey = privkeys[1] - spec.get_signed_blobs_sidecar(state, blobs_sidecar, privkey) expected_commitments = [spec.blob_to_kzg_commitment(blobs[i]) for i in range(blob_count)] spec.validate_blobs_sidecar(block.slot, block.hash_tree_root(), expected_commitments, blobs_sidecar)