diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 614cc46d81..7c2336a28b 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -475,11 +475,7 @@ where /// Produce an `AttestationData` that is valid for the present `slot` and given `shard`. pub fn produce_attestation_data(&self, shard: u64) -> Result { trace!("BeaconChain::produce_attestation: shard: {}", shard); - let source_epoch = self.state.read().current_justified_epoch; - let source_root = *self.state.read().get_block_root( - source_epoch.start_slot(self.spec.slots_per_epoch), - &self.spec, - )?; + let state = self.state.read(); let target_root = *self.state.read().get_block_root( self.state @@ -500,8 +496,8 @@ where epoch: self.state.read().slot.epoch(self.spec.slots_per_epoch), crosslink_data_root: Hash256::zero(), }, - source_epoch, - source_root, + source_epoch: state.current_justified_epoch, + source_root: state.current_justified_root, }) } @@ -696,7 +692,10 @@ where }, }; - trace!("BeaconChain::produce_block: updating state for new block.",); + debug!( + "Produced block with {} attestations, updating state.", + block.body.attestations.len() + ); per_block_processing_without_verifying_block_signature(&mut state, &block, &self.spec)?; diff --git a/eth2/types/src/attestation_duty.rs b/eth2/types/src/attestation_duty.rs index 9612dd868c..299fdd44cf 100644 --- a/eth2/types/src/attestation_duty.rs +++ b/eth2/types/src/attestation_duty.rs @@ -6,5 +6,5 @@ pub struct AttestationDuty { pub slot: Slot, pub shard: Shard, pub committee_index: usize, - pub comittee_size: usize, + pub committee_len: usize, } diff --git a/eth2/types/src/beacon_state/epoch_cache.rs b/eth2/types/src/beacon_state/epoch_cache.rs index 32d9a643e9..62df902714 100644 --- a/eth2/types/src/beacon_state/epoch_cache.rs +++ b/eth2/types/src/beacon_state/epoch_cache.rs @@ -92,6 +92,7 @@ impl EpochCache { slot, shard, committee_index: k, + committee_len: crosslink_committee.committee.len(), }; attestation_duties[*validator_index] = Some(attestation_duty) } diff --git a/eth2/utils/boolean-bitfield/src/lib.rs b/eth2/utils/boolean-bitfield/src/lib.rs index cdd0bc3d77..d90b28dc5b 100644 --- a/eth2/utils/boolean-bitfield/src/lib.rs +++ b/eth2/utils/boolean-bitfield/src/lib.rs @@ -33,9 +33,11 @@ impl BooleanBitfield { } /// Create a new bitfield with the given length `initial_len` and all values set to `bit`. - pub fn from_elem(inital_len: usize, bit: bool) -> Self { + pub fn from_elem(initial_len: usize, bit: bool) -> Self { + // BitVec can panic if we don't set the len to be a multiple of 8. + let len = ((initial_len + 7) / 8) * 8; Self { - 0: BitVec::from_elem(inital_len, bit), + 0: BitVec::from_elem(len, bit), } } diff --git a/validator_client/src/attester_service/mod.rs b/validator_client/src/attester_service/mod.rs index 7178e28d73..20488b1c19 100644 --- a/validator_client/src/attester_service/mod.rs +++ b/validator_client/src/attester_service/mod.rs @@ -3,6 +3,7 @@ mod beacon_node_attestation; use std::sync::Arc; use types::{BeaconBlock, ChainSpec, Domain, Fork, Slot}; +use super::block_proposer::beacon_node_block::BeaconNodeError; #[derive(Debug, PartialEq)] pub enum Error {