From 95dea4c165971c39c2a4a2e5cd70b00aa74106dd Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Mon, 1 Jul 2019 12:16:53 +0200 Subject: [PATCH] mark get_attestation_data_slot(...), ProposerSlashing, AttesterSlashing, DepositData, BeaconBlock, Eth1Data, AttestationDataAndCustodyBit, and is_slashable_attestation_data(...) as 0.8.0; add Checkpoint object type --- beacon_chain/spec/beaconstate.nim | 7 ++++--- beacon_chain/spec/datatypes.nim | 22 +++++++++++++------- beacon_chain/spec/state_transition_block.nim | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 919012869..a602c107b 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -253,15 +253,16 @@ func get_initial_beacon_block*(state: BeaconState): BeaconBlock = # initialized to default values. ) -# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#get_attestation_data_slot +# https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#get_attestation_data_slot func get_attestation_data_slot*(state: BeaconState, data: AttestationData, committee_count: uint64): Slot = + # Return the slot corresponding to the attestation ``data``. let offset = (data.crosslink.shard + SHARD_COUNT - get_start_shard(state, data.target_epoch)) mod SHARD_COUNT - compute_start_slot_of_epoch(data.target_epoch) + offset div - (committee_count div SLOTS_PER_EPOCH) + (compute_start_slot_of_epoch(data.target_epoch) + offset div + (committee_count div SLOTS_PER_EPOCH)).Slot # This is the slower (O(n)), spec-compatible signature. func get_attestation_data_slot*(state: BeaconState, diff --git a/beacon_chain/spec/datatypes.nim b/beacon_chain/spec/datatypes.nim index 3da4d9584..ca0a7e08d 100644 --- a/beacon_chain/spec/datatypes.nim +++ b/beacon_chain/spec/datatypes.nim @@ -74,7 +74,7 @@ type Gwei* = uint64 Domain* = uint64 - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#proposerslashing + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#proposerslashing ProposerSlashing* = object proposer_index*: uint64 ##\ ## Proposer index @@ -85,7 +85,7 @@ type header_2*: BeaconBlockHeader ##\ # Second block header - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#attesterslashing + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#attesterslashing AttesterSlashing* = object attestation_1*: IndexedAttestation ## \ ## First attestation @@ -118,6 +118,11 @@ type signature*: ValidatorSig ##\ ## BLS aggregate signature + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#checkpoint + Checkpoint* = object + epoch*: Epoch + root*: Eth2Digest + # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#attestationdata AttestationData* = object # LMD GHOST vote @@ -132,10 +137,12 @@ type # Crosslink vote crosslink*: Crosslink - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#attestationdataandcustodybit + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#attestationdataandcustodybit AttestationDataAndCustodyBit* = object data*: AttestationData - custody_bit*: bool + + custody_bit*: bool ##\ + ## Challengeable bit (SSZ-bool, 1 byte) for the custody of crosslink data # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#deposit Deposit* = object @@ -144,7 +151,7 @@ type data*: DepositData - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#depositdata + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#depositdata DepositData* = object pubkey*: ValidatorPubKey ##\ ## BLS pubkey @@ -155,6 +162,7 @@ type amount*: uint64 ##\ ## Amount in Gwei + # TODO remove, not in spec dummy*: uint64 signature*: ValidatorSig ##\ @@ -192,7 +200,7 @@ type signature*: ValidatorSig ##\ ## Signature checked against withdrawal pubkey - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#beaconblock + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#beaconblock BeaconBlock* = object ## For each slot, a proposer is chosen from the validator pool to propose ## a new block. Once the block as been proposed, it is transmitted to @@ -343,7 +351,7 @@ type epoch*: Epoch ##\ ## Fork epoch number - # https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#eth1data + # https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#eth1data Eth1Data* = object deposit_root*: Eth2Digest ##\ ## Root of the deposit tree diff --git a/beacon_chain/spec/state_transition_block.nim b/beacon_chain/spec/state_transition_block.nim index e36553820..6e0790d9e 100644 --- a/beacon_chain/spec/state_transition_block.nim +++ b/beacon_chain/spec/state_transition_block.nim @@ -177,7 +177,7 @@ proc processProposerSlashings( true -# https://github.com/ethereum/eth2.0-specs/blob/v0.7.1/specs/core/0_beacon-chain.md#is_slashable_attestation_data +# https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#is_slashable_attestation_data func is_slashable_attestation_data( data_1: AttestationData, data_2: AttestationData): bool = ## Check if ``data_1`` and ``data_2`` are slashable according to Casper FFG