diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 3acca74af..d99d2a8c5 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -16,6 +16,7 @@ use state_processing::{ }; use std::sync::Arc; use store::{Error as DBError, Store}; +use tree_hash::TreeHash; use types::*; #[derive(Debug, PartialEq)] @@ -326,8 +327,7 @@ impl BeaconChain { // If required, transition the new state to the present slot. for _ in state.slot.as_u64()..present_slot.as_u64() { // Ensure the next epoch state caches are built in case of an epoch transition. - state.build_committee_cache(RelativeEpoch::NextWithoutRegistryChange, &self.spec)?; - state.build_committee_cache(RelativeEpoch::NextWithRegistryChange, &self.spec)?; + state.build_committee_cache(RelativeEpoch::Next, &self.spec)?; per_slot_processing(&mut *state, &self.spec)?; } @@ -459,7 +459,7 @@ impl BeaconChain { if let Some(attestation_duty) = self .state .read() - .get_attestation_duties(validator_index, &self.spec)? + .get_attestation_duties(validator_index, RelativeEpoch::Current)? { Ok(Some((attestation_duty.slot, attestation_duty.shard))) } else { @@ -497,15 +497,18 @@ impl BeaconChain { *self.state.read().get_block_root(current_epoch_start_slot)? }; + let previous_crosslink_root = + Hash256::from_slice(&state.get_current_crosslink(shard)?.tree_hash_root()); + Ok(AttestationData { - slot: self.state.read().slot, - shard, beacon_block_root: self.head().beacon_block_root, - target_root, - crosslink_data_root: Hash256::zero(), - previous_crosslink: state.latest_crosslinks[shard as usize].clone(), source_epoch: state.current_justified_epoch, source_root: state.current_justified_root, + target_epoch: state.current_epoch(), + target_root, + shard, + previous_crosslink_root, + crosslink_data_root: Hash256::zero(), }) } @@ -678,14 +681,17 @@ impl BeaconChain { slot: state.slot, previous_block_root, state_root: Hash256::zero(), // Updated after the state is calculated. - signature: self.spec.empty_signature.clone(), // To be completed by a validator. + signature: Signature::empty_signature(), // To be completed by a validator. body: BeaconBlockBody { randao_reveal, eth1_data: Eth1Data { // TODO: replace with real data + deposit_count: 0, deposit_root: Hash256::zero(), block_hash: Hash256::zero(), }, + // TODO: badass Lighthouse graffiti + graffiti: [0; 32], proposer_slashings, attester_slashings, attestations: self diff --git a/beacon_node/rpc/src/validator.rs b/beacon_node/rpc/src/validator.rs index e58c202d6..16437f2a3 100644 --- a/beacon_node/rpc/src/validator.rs +++ b/beacon_node/rpc/src/validator.rs @@ -115,7 +115,9 @@ impl ValidatorService for ValidatorServiceInstance { }; // get attestation duties and check if validator is active - let attestation_duties = match state.get_attestation_duties(val_index, &spec) { + let attestation_duties = match state + .get_attestation_duties(val_index, RelativeEpoch::Current) + { Ok(Some(v)) => v, Ok(_) => { // validator is inactive, go to the next validator diff --git a/eth2/fork_choice/tests/tests.rs b/eth2/fork_choice/tests/tests.rs index 0327e8cb3..1ed4faa8e 100644 --- a/eth2/fork_choice/tests/tests.rs +++ b/eth2/fork_choice/tests/tests.rs @@ -75,6 +75,7 @@ fn test_yaml_vectors( let spec = FoundationEthSpec::spec(); let zero_hash = Hash256::zero(); let eth1_data = Eth1Data { + deposit_count: 0, deposit_root: zero_hash.clone(), block_hash: zero_hash.clone(), }; @@ -83,6 +84,7 @@ fn test_yaml_vectors( let body = BeaconBlockBody { eth1_data, randao_reveal, + graffiti: [0; 32], proposer_slashings: vec![], attester_slashings: vec![], attestations: vec![], diff --git a/eth2/state_processing/src/per_block_processing/tests.rs b/eth2/state_processing/src/per_block_processing/tests.rs index 19418aba1..28ed9c4f0 100644 --- a/eth2/state_processing/src/per_block_processing/tests.rs +++ b/eth2/state_processing/src/per_block_processing/tests.rs @@ -67,7 +67,7 @@ fn invalid_block_signature() { let keypair = Keypair::random(); let message = block.signed_root(); let epoch = block.slot.epoch(spec.slots_per_epoch); - let domain = spec.get_domain(epoch, Domain::BeaconBlock, &state.fork); + let domain = spec.get_domain(epoch, Domain::BeaconProposer, &state.fork); block.signature = Signature::new(&message, domain, &keypair.sk); // process block with invalid block signature diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index 336fcf79a..4e510940f 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -738,11 +738,9 @@ impl BeaconState { /// Returns the `slot`, `shard` and `committee_index` for which a validator must produce an /// attestation. /// - /// Only reads the current epoch. - /// /// Note: Utilizes the cache and will fail if the appropriate cache is not initialized. /// - /// Spec v0.5.1 + /// Spec v0.6.2 pub fn get_attestation_duties( &self, validator_index: usize, diff --git a/validator_client/src/attestation_producer/mod.rs b/validator_client/src/attestation_producer/mod.rs index c8c80f78c..0a65c1f1e 100644 --- a/validator_client/src/attestation_producer/mod.rs +++ b/validator_client/src/attestation_producer/mod.rs @@ -140,7 +140,7 @@ impl<'a, B: BeaconNodeAttestation, S: Signer> AttestationProducer<'a, B, S> { aggregation_bitfield, data: attestation, custody_bitfield, - aggregate_signature, + signature: aggregate_signature, }) } diff --git a/validator_client/src/block_producer/mod.rs b/validator_client/src/block_producer/mod.rs index 61e9d1a08..fc01b8126 100644 --- a/validator_client/src/block_producer/mod.rs +++ b/validator_client/src/block_producer/mod.rs @@ -100,7 +100,9 @@ impl<'a, B: BeaconNodeBlock, S: Signer> BlockProducer<'a, B, S> { .produce_beacon_block(self.slot, &randao_reveal)? { if self.safe_to_produce(&block) { - let domain = self.spec.get_domain(epoch, Domain::BeaconBlock, &self.fork); + let domain = self + .spec + .get_domain(epoch, Domain::BeaconProposer, &self.fork); if let Some(block) = self.sign_block(block, domain) { self.beacon_node.publish_beacon_block(block)?; Ok(ValidatorEvent::BlockProduced(self.slot))