mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Update to spec v0.9.1 (#597)
* Update to spec v0.9.0 * Update to v0.9.1 * Bump spec tags for v0.9.1 * Formatting, fix CI failures * Resolve accidental KeyPair merge conflict * Document new BeaconState functions * Fix incorrect cache drops in `advance_caches` * Update fork choice for v0.9.1 * Clean up some FIXMEs * Fix a few docs/logs
This commit is contained in:
@@ -8,11 +8,11 @@ Node (BN) and fulfils the roles of a validator.
|
||||
The VC is responsible for the following tasks:
|
||||
|
||||
- Requesting validator duties (a.k.a. shuffling) from the BN.
|
||||
- Prompting the BN to produce a new block, when a validators block production
|
||||
- Prompting the BN to produce a new block, when a validator's block production
|
||||
duties require.
|
||||
- Completing all the fields on a new block (e.g., RANDAO reveal, signature) and
|
||||
publishing the block to a BN.
|
||||
- Prompting the BN to produce a new shard attestation as per a validators
|
||||
- Prompting the BN to produce a new attestation as per a validator's
|
||||
duties.
|
||||
- Ensuring that no slashable messages are signed by a validator private key.
|
||||
- Keeping track of the system clock and how it relates to slots/epochs.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//TODO: generalise these enums to the crate
|
||||
use crate::block_producer::{BeaconNodeError, PublishOutcome};
|
||||
use types::{Attestation, AttestationData, EthSpec, Slot};
|
||||
use types::{Attestation, AttestationData, CommitteeIndex, EthSpec, Slot};
|
||||
|
||||
/// Defines the methods required to produce and publish attestations on a Beacon Node. Abstracts the
|
||||
/// actual beacon node.
|
||||
@@ -10,7 +10,7 @@ pub trait BeaconNodeAttestation: Send + Sync {
|
||||
fn produce_attestation_data(
|
||||
&self,
|
||||
slot: Slot,
|
||||
shard: u64,
|
||||
index: CommitteeIndex,
|
||||
) -> Result<AttestationData, BeaconNodeError>;
|
||||
|
||||
/// Request that the node publishes a attestation.
|
||||
|
||||
@@ -6,17 +6,17 @@ use ssz::{Decode, Encode};
|
||||
use protos::services::{
|
||||
Attestation as GrpcAttestation, ProduceAttestationDataRequest, PublishAttestationRequest,
|
||||
};
|
||||
use types::{Attestation, AttestationData, EthSpec, Slot};
|
||||
use types::{Attestation, AttestationData, CommitteeIndex, EthSpec, Slot};
|
||||
|
||||
impl BeaconNodeAttestation for AttestationServiceClient {
|
||||
fn produce_attestation_data(
|
||||
&self,
|
||||
slot: Slot,
|
||||
shard: u64,
|
||||
index: CommitteeIndex,
|
||||
) -> Result<AttestationData, BeaconNodeError> {
|
||||
let mut req = ProduceAttestationDataRequest::new();
|
||||
req.set_slot(slot.as_u64());
|
||||
req.set_shard(shard);
|
||||
req.set_shard(index);
|
||||
|
||||
let reply = self
|
||||
.produce_attestation_data(&req)
|
||||
|
||||
@@ -10,10 +10,7 @@ use beacon_node_attestation::BeaconNodeAttestation;
|
||||
use core::marker::PhantomData;
|
||||
use slog::{error, info, warn};
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
AggregateSignature, Attestation, AttestationData, AttestationDataAndCustodyBit,
|
||||
AttestationDuty, BitList,
|
||||
};
|
||||
use types::{AggregateSignature, Attestation, AttestationData, AttestationDuty, BitList};
|
||||
|
||||
//TODO: Group these errors at a crate level
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -90,9 +87,11 @@ impl<'a, B: BeaconNodeAttestation, S: Signer, E: EthSpec> AttestationProducer<'a
|
||||
|
||||
let attestation = self
|
||||
.beacon_node
|
||||
.produce_attestation_data(self.duty.slot, self.duty.shard)?;
|
||||
.produce_attestation_data(self.duty.slot, self.duty.index)?;
|
||||
if self.safe_to_produce(&attestation) {
|
||||
let domain = self.spec.get_domain(epoch, Domain::Attestation, &self.fork);
|
||||
let domain = self
|
||||
.spec
|
||||
.get_domain(epoch, Domain::BeaconAttester, &self.fork);
|
||||
if let Some(attestation) = self.sign_attestation(attestation, self.duty, domain) {
|
||||
match self.beacon_node.publish_attestation(attestation) {
|
||||
Ok(PublishOutcome::InvalidAttestation(_string)) => {
|
||||
@@ -127,11 +126,7 @@ impl<'a, B: BeaconNodeAttestation, S: Signer, E: EthSpec> AttestationProducer<'a
|
||||
|
||||
// build the aggregate signature
|
||||
let aggregate_signature = {
|
||||
let message = AttestationDataAndCustodyBit {
|
||||
data: attestation.clone(),
|
||||
custody_bit: false,
|
||||
}
|
||||
.tree_hash_root();
|
||||
let message = attestation.tree_hash_root();
|
||||
|
||||
let sig = self.signer.sign_message(&message, domain)?;
|
||||
|
||||
@@ -141,13 +136,11 @@ impl<'a, B: BeaconNodeAttestation, S: Signer, E: EthSpec> AttestationProducer<'a
|
||||
};
|
||||
|
||||
let mut aggregation_bits = BitList::with_capacity(duties.committee_len).ok()?;
|
||||
let custody_bits = BitList::with_capacity(duties.committee_len).ok()?;
|
||||
aggregation_bits.set(duties.committee_index, true).ok()?;
|
||||
aggregation_bits.set(duties.committee_position, true).ok()?;
|
||||
|
||||
Some(Attestation {
|
||||
aggregation_bits,
|
||||
data: attestation,
|
||||
custody_bits,
|
||||
signature: aggregate_signature,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl EpochDuty {
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// if the validator is required to attest to a shard, create the data
|
||||
// if the validator is required to attest to a index, create the data
|
||||
let mut attestation_duty = None;
|
||||
if self.attestation_duty.slot == slot {
|
||||
attestation_duty = Some(self.attestation_duty)
|
||||
@@ -59,8 +59,8 @@ impl fmt::Display for EpochDuty {
|
||||
}
|
||||
write!(
|
||||
f,
|
||||
"produce block slot: {}, attestation slot: {}, attestation shard: {}",
|
||||
display_block, self.attestation_duty.slot, self.attestation_duty.shard
|
||||
"produce block slot: {}, attestation slot: {}, attestation index: {}",
|
||||
display_block, self.attestation_duty.slot, self.attestation_duty.index
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ impl BeaconNodeDuties for ValidatorServiceClient {
|
||||
|
||||
let attestation_duty = AttestationDuty {
|
||||
slot: Slot::from(active_duty.get_attestation_slot()),
|
||||
shard: active_duty.get_attestation_shard(),
|
||||
committee_index: active_duty.get_committee_index() as usize,
|
||||
index: active_duty.get_attestation_shard(),
|
||||
committee_position: active_duty.get_committee_index() as usize,
|
||||
committee_len: active_duty.get_committee_len() as usize,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user