Add committee_len to attestation data

This commit is contained in:
Age Manning 2019-03-30 17:20:33 +11:00
commit a952acb86f
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93
5 changed files with 14 additions and 11 deletions

View File

@ -475,11 +475,7 @@ where
/// Produce an `AttestationData` that is valid for the present `slot` and given `shard`. /// Produce an `AttestationData` that is valid for the present `slot` and given `shard`.
pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> { pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> {
trace!("BeaconChain::produce_attestation: shard: {}", shard); trace!("BeaconChain::produce_attestation: shard: {}", shard);
let source_epoch = self.state.read().current_justified_epoch; let state = self.state.read();
let source_root = *self.state.read().get_block_root(
source_epoch.start_slot(self.spec.slots_per_epoch),
&self.spec,
)?;
let target_root = *self.state.read().get_block_root( let target_root = *self.state.read().get_block_root(
self.state self.state
@ -500,8 +496,8 @@ where
epoch: self.state.read().slot.epoch(self.spec.slots_per_epoch), epoch: self.state.read().slot.epoch(self.spec.slots_per_epoch),
crosslink_data_root: Hash256::zero(), crosslink_data_root: Hash256::zero(),
}, },
source_epoch, source_epoch: state.current_justified_epoch,
source_root, 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)?; per_block_processing_without_verifying_block_signature(&mut state, &block, &self.spec)?;

View File

@ -6,5 +6,5 @@ pub struct AttestationDuty {
pub slot: Slot, pub slot: Slot,
pub shard: Shard, pub shard: Shard,
pub committee_index: usize, pub committee_index: usize,
pub comittee_size: usize, pub committee_len: usize,
} }

View File

@ -92,6 +92,7 @@ impl EpochCache {
slot, slot,
shard, shard,
committee_index: k, committee_index: k,
committee_len: crosslink_committee.committee.len(),
}; };
attestation_duties[*validator_index] = Some(attestation_duty) attestation_duties[*validator_index] = Some(attestation_duty)
} }

View File

@ -33,9 +33,11 @@ impl BooleanBitfield {
} }
/// Create a new bitfield with the given length `initial_len` and all values set to `bit`. /// 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 { Self {
0: BitVec::from_elem(inital_len, bit), 0: BitVec::from_elem(len, bit),
} }
} }

View File

@ -3,6 +3,7 @@ mod beacon_node_attestation;
use std::sync::Arc; use std::sync::Arc;
use types::{BeaconBlock, ChainSpec, Domain, Fork, Slot}; use types::{BeaconBlock, ChainSpec, Domain, Fork, Slot};
use super::block_proposer::beacon_node_block::BeaconNodeError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum Error { pub enum Error {