From 2913dfa6fe7be177c11b850ff55d1408ddeeafba Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Wed, 5 Dec 2018 20:03:09 +1100 Subject: [PATCH 1/3] Change `state.crosslinks` to `state.latest_crosslinks` (#236) Change `state.crosslinks` to `state.latest_crosslinks` to match the `BeaconState` definition. --- specs/core/0_beacon-chain.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 3a1a66ea5..fabb325d9 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1216,7 +1216,7 @@ For each `attestation` in `block.attestations`: * Verify that `attestation.data.slot >= max(parent.slot - EPOCH_LENGTH + 1, 0)`. * Verify that `attestation.data.justified_slot` is equal to `state.justified_slot if attestation.data.slot >= state.latest_state_recalculation_slot else state.previous_justified_slot`. * Verify that `attestation.data.justified_block_hash` is equal to `get_block_hash(state, block, attestation.data.justified_slot)`. -* Verify that either `attestation.data.latest_crosslink_hash` or `attestation.data.shard_block_hash` equals `state.crosslinks[shard].shard_block_hash`. +* Verify that either `attestation.data.latest_crosslink_hash` or `attestation.data.shard_block_hash` equals `state.latest_crosslinks[shard].shard_block_hash`. * `aggregate_signature` verification: * Let `participants = get_attestation_participants(state, attestation.data, attestation.participation_bitfield)`. * Let `group_public_key = BLSAddPubkeys([state.validator_registry[v].pubkey for v in participants])`. @@ -1393,7 +1393,7 @@ For any [validator](#dfn-validator) `v`, let `base_reward(v) = get_effective_bal For every `ShardCommittee` object `obj`: -* If `3 * total_attesting_balance(obj) >= 2 * total_balance(obj)`, set `crosslinks[shard] = CrosslinkRecord(slot=state.latest_state_recalculation_slot + EPOCH_LENGTH, hash=winning_hash(obj))`. +* If `3 * total_attesting_balance(obj) >= 2 * total_balance(obj)`, set `latest_crosslinks[shard] = CrosslinkRecord(slot=state.latest_state_recalculation_slot + EPOCH_LENGTH, hash=winning_hash(obj))`. ### Balance recalculations related to FFG rewards @@ -1432,7 +1432,7 @@ If `state.latest_state_recalculation_slot % POW_RECEIPT_ROOT_VOTING_PERIOD == 0` A [validator](#dfn-validator) registry change occurs if all of the following criteria are satisfied: * `state.finalized_slot > state.validator_registry_latest_change_slot` -* For every shard number `shard` in `state.shard_committees_at_slots`, `crosslinks[shard].slot > state.validator_registry_latest_change_slot` +* For every shard number `shard` in `state.shard_committees_at_slots`, `latest_crosslinks[shard].slot > state.validator_registry_latest_change_slot` A helper function is defined as: From 130b8379751b6bb792138643dfff5fdadfacb8cd Mon Sep 17 00:00:00 2001 From: terence tsao Date: Wed, 5 Dec 2018 06:41:11 -0800 Subject: [PATCH 2/3] Fix ZERO_BALANCE_VALIDATOR_TTL and move get_domain --- specs/core/0_beacon-chain.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index fabb325d9..251aae181 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -65,6 +65,7 @@ - [`bytes1`, `bytes2`, ...](#bytes1-bytes2-) - [`get_effective_balance`](#get_effective_balance) - [`get_new_validator_registry_delta_chain_tip`](#get_new_validator_registry_delta_chain_tip) + - [`get_domain`](#get_domain) - [`integer_squareroot`](#integer_squareroot) - [On startup](#on-startup) - [Routine for activating a validator](#routine-for-activating-a-validator) @@ -172,7 +173,7 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted | `POW_RECEIPT_ROOT_VOTING_PERIOD` | `2**10` (= 1,024) | slots | ~1.7 hours | | `SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD` | `2**17` (= 131,072) | slots | ~9 days | | `COLLECTIVE_PENALTY_CALCULATION_PERIOD` | `2**20` (= 1,048,576) | slots | ~73 days | -| `ZERO_BALANCE_VALIDATOR_TTL` | `2**22` (= 16,777,216) | slots | ~290 days | +| `ZERO_BALANCE_VALIDATOR_TTL` | `2**22` (= 4,194,304) | slots | ~291 days | ### Reward and penalty quotients @@ -922,6 +923,18 @@ def get_new_validator_registry_delta_chain_tip(current_validator_registry_delta_ ) ``` +#### `get_domain` + +```python +def get_domain(fork_data: ForkData, + slot: int, + domain_type: int) -> int: + return get_fork_version( + fork_data, + slot + ) * 2**32 + domain_type +``` + #### `integer_squareroot` ```python @@ -1038,14 +1051,6 @@ def get_fork_version(fork_data: ForkData, else: return fork_data.post_fork_version -def get_domain(fork_data: ForkData, - slot: int, - domain_type: int) -> int: - return get_fork_version( - fork_data, - slot - ) * 2**32 + domain_type - def get_new_validators(validators: List[ValidatorRecord], fork_data: ForkData, pubkey: int, From f956135763cbb410a8c28b3a509f14f750ff287c Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 5 Dec 2018 17:17:17 +0000 Subject: [PATCH 3/3] Fix #237 (#238) --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 251aae181..637c7109d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -958,7 +958,7 @@ A valid block with slot `INITIAL_SLOT_NUMBER` (a "genesis block") has the follow { 'slot': INITIAL_SLOT_NUMBER, 'randao_reveal': ZERO_HASH, - 'candidate_pow_receipt_roots': [], + 'candidate_pow_receipt_root': ZERO_HASH, 'ancestor_hashes': [ZERO_HASH for i in range(32)], 'state_root': STARTUP_STATE_ROOT, 'attestations': [],