From 56954ec5089eaaa08423a453c6a44db3d8ce1457 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Fri, 23 Aug 2019 12:16:57 -0600 Subject: [PATCH] fix adding fields to phase 1 ssz objects --- specs/core/0_beacon-chain.md | 2 -- specs/core/1_beacon-chain-misc.md | 37 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 5ddceebc1..90c179107 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -480,7 +480,6 @@ class BeaconBlockBody(Container): deposits: List[Deposit, MAX_DEPOSITS] voluntary_exits: List[VoluntaryExit, MAX_VOLUNTARY_EXITS] transfers: List[Transfer, MAX_TRANSFERS] - # @shard_receipts ``` #### `BeaconBlock` @@ -534,7 +533,6 @@ class BeaconState(Container): previous_justified_checkpoint: Checkpoint # Previous epoch snapshot current_justified_checkpoint: Checkpoint finalized_checkpoint: Checkpoint - # @persistent_committee_fields ``` ## Helper functions diff --git a/specs/core/1_beacon-chain-misc.md b/specs/core/1_beacon-chain-misc.md index b6f23a00e..65c4cdbbc 100644 --- a/specs/core/1_beacon-chain-misc.md +++ b/specs/core/1_beacon-chain-misc.md @@ -182,17 +182,32 @@ def process_shard_receipt_proof(state: BeaconState, receipt_proof: ShardReceiptP ## Changes -### Persistent committees +### Phase 0 container updates -Add to the beacon state the following fields: +Add the following fields to the end of the specified container objects. + +#### `BeaconState` ```python -# begin insert @persistent_committee_fields +class BeaconState(Container): + # Persistent committees persistent_committee_roots: Vector[Hash, PERSISTENT_COMMITTEE_ROOT_LENGTH] next_shard_receipt_period: Vector[uint64, SHARD_COUNT] -# end insert @persistent_committee_fields ``` -`next_shard_receipt_period` values initialized to `PHASE_1_FORK_SLOT // SLOTS_PER_EPOCH // EPOCHS_PER_SHARD_PERIOD` + +`persistent_committee_roots` values are initialized to `Bytes32()` (empty bytes value). +`next_shard_receipt_period` values are initialized to `PHASE_1_FORK_SLOT // SLOTS_PER_EPOCH // EPOCHS_PER_SHARD_PERIOD`. + +#### `BeaconBlockBody` + +```python +class BeaconBlockBody(Container): + shard_receipt_proofs: List[ShardReceiptProof, MAX_SHARD_RECEIPT_PROOFS] +``` + +`shard_receipt_proofs` is initialized to `[]`. + +### Persistent committees Run `update_persistent_committee` immediately before `process_final_updates`: @@ -215,18 +230,10 @@ def update_persistent_committee(state: BeaconState) -> None: ### Shard receipt processing -Add the `shard_receipt_proofs` operation to `BeaconBlockBody`: - -```python -# begin insert @shard_receipts - shard_receipt_proofs: List[ShardReceiptProof, MAX_SHARD_RECEIPT_PROOFS] -# end insert @shard_receipts -``` - -Use `process_shard_receipt_proof` to process each receipt. +Run `process_shard_receipt_proof` on each `ShardReceiptProof` during block processing. ```python # begin insert @process_shard_receipts - (body.shard_receipt_proofs, process_shard_receipt_proofs), + (body.shard_receipt_proofs, process_shard_receipt_proof), # end insert @process_shard_receipts ```