Fix recently introduced errors for gRPC block prod

This commit is contained in:
Paul Hauner 2019-06-01 12:36:10 +10:00
parent 7058f62b50
commit 8831db1e0f
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
3 changed files with 8 additions and 2 deletions

View File

@ -371,6 +371,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
} }
*/ */
/// Returns a read-lock guarded `BeaconState` which is the `canonical_head` that has been
/// updated to match the current slot clock.
pub fn current_state(&self) -> RwLockReadGuard<BeaconState<T::EthSpec>> {
self.state.read()
}
/// Returns a read-lock guarded `CheckPoint` struct for reading the head (as chosen by the /// Returns a read-lock guarded `CheckPoint` struct for reading the head (as chosen by the
/// fork-choice rule). /// fork-choice rule).
/// ///

View File

@ -34,7 +34,7 @@ impl<T: BeaconChainTypes> AttestationService for AttestationServiceInstance<T> {
// verify the slot, drop lock on state afterwards // verify the slot, drop lock on state afterwards
{ {
let slot_requested = req.get_slot(); let slot_requested = req.get_slot();
let state = &self.chain.head().beacon_state; let state = &self.chain.current_state();
// Start by performing some checks // Start by performing some checks
// Check that the AttestionData is for the current slot (otherwise it will not be valid) // Check that the AttestionData is for the current slot (otherwise it will not be valid)

View File

@ -30,7 +30,7 @@ impl<T: BeaconChainTypes> ValidatorService for ValidatorServiceInstance<T> {
trace!(self.log, "RPC request"; "endpoint" => "GetValidatorDuties", "epoch" => req.get_epoch()); trace!(self.log, "RPC request"; "endpoint" => "GetValidatorDuties", "epoch" => req.get_epoch());
let spec = T::EthSpec::spec(); let spec = T::EthSpec::spec();
let state = &self.chain.head().beacon_state; let state = &self.chain.current_state();
let epoch = Epoch::from(req.get_epoch()); let epoch = Epoch::from(req.get_epoch());
let mut resp = GetDutiesResponse::new(); let mut resp = GetDutiesResponse::new();
let resp_validators = resp.mut_active_validators(); let resp_validators = resp.mut_active_validators();