From b292f0b7b384ae9690c958b4a219043e75977448 Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Tue, 21 Sep 2021 18:04:39 +0300 Subject: [PATCH 1/4] Remove beacon_block_root field from ShardBlob --- specs/sharding/beacon-chain.md | 8 -------- specs/sharding/p2p-interface.md | 15 --------------- 2 files changed, 23 deletions(-) diff --git a/specs/sharding/beacon-chain.md b/specs/sharding/beacon-chain.md index 2c8e8f20b..8190951b4 100644 --- a/specs/sharding/beacon-chain.md +++ b/specs/sharding/beacon-chain.md @@ -270,8 +270,6 @@ class ShardBlobBody(Container): degree_proof: BLSCommitment # The actual data. Should match the commitment and degree proof. data: List[BLSPoint, POINTS_PER_SAMPLE * MAX_SAMPLES_PER_BLOB] - # Latest block root of the Beacon Chain, before shard_blob.slot - beacon_block_root: Root # fee payment fields (EIP 1559 like) # TODO: express in MWei instead? max_priority_fee_per_sample: Gwei @@ -293,8 +291,6 @@ class ShardBlobBodySummary(Container): degree_proof: BLSCommitment # Hash-tree-root as summary of the data field data_root: Root - # Latest block root of the Beacon Chain, before shard_blob.slot - beacon_block_root: Root # fee payment fields (EIP 1559 like) # TODO: express in MWei instead? max_priority_fee_per_sample: Gwei @@ -695,10 +691,6 @@ def process_shard_header(state: BeaconState, signed_header: SignedShardBlobHeade committees_per_slot = get_committee_count_per_slot(state, header_epoch) assert committee_index <= committees_per_slot - # Verify that the block root matches, - # to ensure the header will only be included in this specific Beacon Chain sub-tree. - assert header.body_summary.beacon_block_root == get_block_root_at_slot(state, slot - 1) - # Check that this data is still pending committee_work = state.shard_buffer[slot % SHARD_STATE_MEMORY_SLOTS][shard] assert committee_work.status.selector == SHARD_WORK_PENDING diff --git a/specs/sharding/p2p-interface.md b/specs/sharding/p2p-interface.md index c47d2ee07..76a806635 100644 --- a/specs/sharding/p2p-interface.md +++ b/specs/sharding/p2p-interface.md @@ -97,11 +97,6 @@ on the horizontal subnet or creating samples for it. Alias `blob = signed_blob.m - _[REJECT]_ The blob builder defined by `blob.builder_index` exists and has sufficient balance to back the fee payment. - _[REJECT]_ The blob signature, `signed_blob.signature`, is valid for the aggregate of proposer and builder -- i.e. `bls.FastAggregateVerify([builder_pubkey, proposer_pubkey], blob_signing_root, signed_blob.signature)`. -- _[REJECT]_ The blob is proposed by the expected `proposer_index` for the blob's `slot` and `shard`, - in the context of the current shuffling (defined by `blob.body.beacon_block_root`/`slot`). - If the `proposer_index` cannot immediately be verified against the expected shuffling, - the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- - in such a case _do not_ `REJECT`, instead `IGNORE` this message. #### Global topics @@ -132,11 +127,6 @@ The following validations MUST pass before forwarding the `signed_blob_header` o - _[REJECT]_ The blob builder defined by `blob.builder_index` exists and has sufficient balance to back the fee payment. - _[REJECT]_ The header signature, `signed_blob_header.signature`, is valid for the aggregate of proposer and builder -- i.e. `bls.FastAggregateVerify([builder_pubkey, proposer_pubkey], blob_signing_root, signed_blob_header.signature)`. -- _[REJECT]_ The header is proposed by the expected `proposer_index` for the blob's `header.slot` and `header.shard` - in the context of the current shuffling (defined by `header.body_summary.beacon_block_root`/`slot`). - If the `proposer_index` cannot immediately be verified against the expected shuffling, - the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- - in such a case _do not_ `REJECT`, instead `IGNORE` this message. ##### `shard_blob_tx` @@ -160,11 +150,6 @@ The following validations MUST pass before forwarding the `signed_blob_header` o Propagating nodes MAY increase fee increments in case of spam. - _[REJECT]_ The header signature, `signed_blob_header.signature`, is valid for ONLY the builder -- i.e. `bls.Verify(builder_pubkey, blob_signing_root, signed_blob_header.signature)`. The signature is not an aggregate with the proposer. -- _[REJECT]_ The header is designated for proposal by the expected `proposer_index` for the blob's `header.slot` and `header.shard` - in the context of the current shuffling (defined by `header.body_summary.beacon_block_root`/`slot`). - If the `proposer_index` cannot immediately be verified against the expected shuffling, - the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- - in such a case _do not_ `REJECT`, instead `IGNORE` this message. ##### `shard_proposer_slashing` From 41c12bfcb2e7b97d3e371ecbd8987bd5e549d6e7 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Wed, 22 Sep 2021 14:15:07 +0200 Subject: [PATCH 2/4] improve grammar in BLS test comments The comments for the PRIVKEYS definition in the BLS test generator were a bit difficult to read. Improved by rewording them slightly. --- tests/generators/bls/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generators/bls/main.py b/tests/generators/bls/main.py index 75468b162..6fc86d10f 100644 --- a/tests/generators/bls/main.py +++ b/tests/generators/bls/main.py @@ -45,8 +45,8 @@ MESSAGES = [ SAMPLE_MESSAGE = b'\x12' * 32 PRIVKEYS = [ - # Curve order is 256 so private keys are 32 bytes at most. - # Also not all integers is a valid private key, so using pre-generated keys + # Curve order is 256, so private keys use 32 bytes at most. + # Also, not all integers are valid private keys. Therefore, using pre-generated keys. hex_to_int('0x00000000000000000000000000000000263dbd792f5b1be47ed85f8938c0f29586af0d3ac7b977f21c278fe1462040e3'), hex_to_int('0x0000000000000000000000000000000047b8192d77bf871b62e87859d653922725724a5c031afeabc60bcef5ff665138'), hex_to_int('0x00000000000000000000000000000000328388aff0d4a5b7dc9205abd374e7e98f3cd9f3418edb4eafda5fb16473d216'), From df01588464b2663bb0adf647c5f5e3a85283442c Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Wed, 22 Sep 2021 18:40:10 +0300 Subject: [PATCH 3/4] Return back `proposer_index` validation for Gossip messages --- specs/sharding/p2p-interface.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/specs/sharding/p2p-interface.md b/specs/sharding/p2p-interface.md index 76a806635..ab32c37fa 100644 --- a/specs/sharding/p2p-interface.md +++ b/specs/sharding/p2p-interface.md @@ -97,6 +97,11 @@ on the horizontal subnet or creating samples for it. Alias `blob = signed_blob.m - _[REJECT]_ The blob builder defined by `blob.builder_index` exists and has sufficient balance to back the fee payment. - _[REJECT]_ The blob signature, `signed_blob.signature`, is valid for the aggregate of proposer and builder -- i.e. `bls.FastAggregateVerify([builder_pubkey, proposer_pubkey], blob_signing_root, signed_blob.signature)`. +- _[REJECT]_ The blob is proposed by the expected `proposer_index` for the blob's `slot` and `shard`, + in the context of the current shuffling (defined by the current node head state and `blob.slot`). + If the `proposer_index` cannot immediately be verified against the expected shuffling, + the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- + in such a case _do not_ `REJECT`, instead `IGNORE` this message. #### Global topics @@ -127,6 +132,11 @@ The following validations MUST pass before forwarding the `signed_blob_header` o - _[REJECT]_ The blob builder defined by `blob.builder_index` exists and has sufficient balance to back the fee payment. - _[REJECT]_ The header signature, `signed_blob_header.signature`, is valid for the aggregate of proposer and builder -- i.e. `bls.FastAggregateVerify([builder_pubkey, proposer_pubkey], blob_signing_root, signed_blob_header.signature)`. +- _[REJECT]_ The header is proposed by the expected `proposer_index` for the blob's `header.slot` and `header.shard` + in the context of the current shuffling (defined by the current node head state and `header.slot`). + If the `proposer_index` cannot immediately be verified against the expected shuffling, + the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- + in such a case _do not_ `REJECT`, instead `IGNORE` this message. ##### `shard_blob_tx` @@ -150,6 +160,11 @@ The following validations MUST pass before forwarding the `signed_blob_header` o Propagating nodes MAY increase fee increments in case of spam. - _[REJECT]_ The header signature, `signed_blob_header.signature`, is valid for ONLY the builder -- i.e. `bls.Verify(builder_pubkey, blob_signing_root, signed_blob_header.signature)`. The signature is not an aggregate with the proposer. +- _[REJECT]_ The header is designated for proposal by the expected `proposer_index` for the blob's `header.slot` and `header.shard` + in the context of the current shuffling (defined by the current node head state and `header.slot`). + If the `proposer_index` cannot immediately be verified against the expected shuffling, + the blob MAY be queued for later processing while proposers for the blob's branch are calculated -- + in such a case _do not_ `REJECT`, instead `IGNORE` this message. ##### `shard_proposer_slashing` From 0c65f79d824065606b5854002f37891f573b048e Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Thu, 23 Sep 2021 15:20:18 +0200 Subject: [PATCH 4/4] fix merkle proof test for mainnet The `test_next_sync_committee_tree` currently only supports the minimal preset, as it incorrectly initializes the `next_sync_committee`. On the mainnet preset, `SYNC_COMMITTEE_SIZE` is 512, but the default states use only 256 validators, leading to an IndexError during the test execution. `next_sync_committee` is already initialized correctly prior to the test run using the spec's `get_next_sync_committee` function, which fills up extra committee slots with duplicate validators in this scenario. This makes it unnecessary to manually initialize the `next_sync_committee`. Removed the incorrect initialization to allow testing on mainnet preset. --- .../core/pyspec/eth2spec/test/altair/unittests/test_helpers.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/altair/unittests/test_helpers.py b/tests/core/pyspec/eth2spec/test/altair/unittests/test_helpers.py index c837f06c3..137539113 100644 --- a/tests/core/pyspec/eth2spec/test/altair/unittests/test_helpers.py +++ b/tests/core/pyspec/eth2spec/test/altair/unittests/test_helpers.py @@ -9,9 +9,6 @@ from eth2spec.test.helpers.merkle import build_proof @with_phases([ALTAIR]) @spec_state_test def test_next_sync_committee_tree(spec, state): - state.next_sync_committee: object = spec.SyncCommittee( - pubkeys=[state.validators[i]for i in range(spec.SYNC_COMMITTEE_SIZE)] - ) next_sync_committee_branch = build_proof(state.get_backing(), spec.NEXT_SYNC_COMMITTEE_INDEX) assert spec.is_valid_merkle_branch( leaf=state.next_sync_committee.hash_tree_root(),