Add untested attestation validation logic

This commit is contained in:
Paul Hauner
2018-12-05 16:08:03 +11:00
parent d4b6d81c9d
commit 3533b8b892
14 changed files with 704 additions and 18 deletions

View File

@@ -37,6 +37,12 @@ impl AttestationData {
justified_block_hash: Hash256::zero(),
}
}
// TODO: Implement this as a merkle root, once tree_ssz is implemented.
// https://github.com/sigp/lighthouse/issues/92
pub fn canonical_root(&self) -> Hash256 {
Hash256::zero()
}
}
impl Encodable for AttestationData {

View File

@@ -2,6 +2,7 @@ use super::ValidatorRegistration;
#[derive(Debug, Clone, PartialEq)]
pub struct ChainConfig {
// Old, potentially outdated constants
pub cycle_length: u8,
pub deposit_size_gwei: u64,
pub shard_count: u16,
@@ -10,6 +11,10 @@ pub struct ChainConfig {
pub genesis_time: u64,
pub slot_duration_millis: u64,
pub initial_validators: Vec<ValidatorRegistration>,
// New constants
pub epoch_length: u64,
pub min_attestation_inclusion_delay: u64,
}
/*
@@ -28,6 +33,10 @@ impl ChainConfig {
genesis_time: TEST_GENESIS_TIME,
slot_duration_millis: 16 * 1000,
initial_validators: vec![],
// New
epoch_length: 64,
min_attestation_inclusion_delay: 4,
}
}
@@ -54,6 +63,10 @@ impl ChainConfig {
genesis_time: TEST_GENESIS_TIME, // arbitrary
slot_duration_millis: 16 * 1000,
initial_validators: vec![],
// New constants
epoch_length: 64,
min_attestation_inclusion_delay: 4,
}
}
}

View File

@@ -2,31 +2,16 @@ use super::Hash256;
#[derive(Clone, Debug, PartialEq)]
pub struct CrosslinkRecord {
pub recently_changed: bool,
pub slot: u64,
pub hash: Hash256,
pub shard_block_hash: Hash256,
}
impl CrosslinkRecord {
/// Generates a new instance where `dynasty` and `hash` are both zero.
pub fn zero() -> Self {
Self {
recently_changed: false,
slot: 0,
hash: Hash256::zero(),
shard_block_hash: Hash256::zero(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_crosslink_record_zero() {
let c = CrosslinkRecord::zero();
assert_eq!(c.recently_changed, false);
assert_eq!(c.slot, 0);
assert!(c.hash.is_zero());
}
}