Renamed some functions, trying to get beaconnode attestation stuff to work.

This commit is contained in:
Luke Anderson 2019-03-27 14:30:09 +11:00
parent 1584469b7c
commit c9a7977d69
No known key found for this signature in database
GPG Key ID: 44408169EC61E228
4 changed files with 10 additions and 13 deletions

View File

@ -280,7 +280,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(&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 source_epoch = self.state.read().current_justified_epoch;
let source_root = *self.state.read().get_block_root( let source_root = *self.state.read().get_block_root(

View File

@ -9,6 +9,8 @@ use protos::services::{
use protos::services_grpc::BeaconBlockService; use protos::services_grpc::BeaconBlockService;
use slog::{Logger, info, warn, error}; use slog::{Logger, info, warn, error};
const TEST_SHARD_PHASE_ZERO: u8 = 0;
#[derive(Clone)] #[derive(Clone)]
pub struct AttestationServiceInstance { pub struct AttestationServiceInstance {
pub chain: Arc<BeaconChain>, pub chain: Arc<BeaconChain>,
@ -29,9 +31,11 @@ impl AttestationService for AttestationServiceInstance {
let spec = self.chain.get_spec(); let spec = self.chain.get_spec();
let state = self.chain.get_state(); let state = self.chain.get_state();
let slot_requested = req.get_slot();
// Start by performing some checks // Start by performing some checks
// Check that the the AttestionData is for the current slot (otherwise it will not be valid) // Check that the the AttestionData is for the current slot (otherwise it will not be valid)
if req.get_slot() != state.slot { if slot_requested != state.slot {
let f = sink let f = sink
.fail(RpcStatus::new( .fail(RpcStatus::new(
RpcStatusCode::OutOfRange, RpcStatusCode::OutOfRange,
@ -40,15 +44,8 @@ impl AttestationService for AttestationServiceInstance {
.map_err(move |e| error!(&self.log, "Failed to reply with failure {:?}: {:?}", req, e)); .map_err(move |e| error!(&self.log, "Failed to reply with failure {:?}: {:?}", req, e));
} }
// Then collect the data we need for the AttesatationData object // Then get the AttestationData from the beacon chain (for shard 0 for now)
//let beacon_block_root = state.latest_block_roots.first().ok_or_else(|e| ) let attestation_data = self.chain.produce_attestation_data(TEST_SHARD_PHASE_ZERO);
// And finally build the AttestationData object
let mut attestation_data = AttestationDataProto::new();
attestation_data.set_slot(state.slot.as_u64());
attestation_data.set_shard(spec.genesis_start_shard);
attestation_data.set_beacon_block_root(b"cats".to_vec());
//attestation_data.
let mut resp = ProduceAttestationDataResponse::new(); let mut resp = ProduceAttestationDataResponse::new();
resp.set_attestation_data(attestation_data); resp.set_attestation_data(attestation_data);

View File

@ -33,7 +33,7 @@ service ValidatorService {
/// Service that handles validator attestations /// Service that handles validator attestations
service AttestationService { service AttestationService {
rpc ProduceAttestation(ProduceAttestationDataRequest) returns (ProduceAttestationDataResponse); rpc ProduceAttestationData(ProduceAttestationDataRequest) returns (ProduceAttestationDataResponse);
rpc PublishAttestation(PublishAttestationRequest) returns (PublishAttestationResponse); rpc PublishAttestation(PublishAttestationRequest) returns (PublishAttestationResponse);
} }

View File

@ -27,7 +27,7 @@ impl BeaconNode for AttestationGrpcClient {
let reply = self let reply = self
.client .client
.produce_attestation(&req) .produce_attestation_data(&req)
.map_err(|err| BeaconNodeError::RemoteFailure(format!("{:?}", err)))?; .map_err(|err| BeaconNodeError::RemoteFailure(format!("{:?}", err)))?;
// TODO: return correct Attestation // TODO: return correct Attestation