mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-19 21:04:41 +00:00
Fix timing issue in obtaining the Fork (#2158)
## Issue Addressed
Related PR: https://github.com/sigp/lighthouse/pull/2137#issuecomment-754712492
The Fork is required for VC to perform signing. Currently, it is not guaranteed that the Fork has been obtained at the point of the signing as the Fork is obtained at after ForkService starts. We will see the [error](851a4dca3c/validator_client/src/validator_store.rs (L127)) if VC could not perform the signing due to the timing issue.
> Unable to get Fork for signing
## Proposed Changes
Obtain the Fork on `init_from_beacon_node` to fix the timing issue.
This commit is contained in:
@@ -120,13 +120,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
self.validators.read().num_enabled()
|
||||
}
|
||||
|
||||
fn fork(&self) -> Option<Fork> {
|
||||
if self.fork_service.fork().is_none() {
|
||||
error!(
|
||||
self.log,
|
||||
"Unable to get Fork for signing";
|
||||
);
|
||||
}
|
||||
fn fork(&self) -> Fork {
|
||||
self.fork_service.fork()
|
||||
}
|
||||
|
||||
@@ -134,16 +128,16 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
self.validators
|
||||
.read()
|
||||
.voting_keypair(validator_pubkey)
|
||||
.and_then(|voting_keypair| {
|
||||
.map(|voting_keypair| {
|
||||
let domain = self.spec.get_domain(
|
||||
epoch,
|
||||
Domain::Randao,
|
||||
&self.fork()?,
|
||||
&self.fork(),
|
||||
self.genesis_validators_root,
|
||||
);
|
||||
let message = epoch.signing_root(domain);
|
||||
|
||||
Some(voting_keypair.sk.sign(message))
|
||||
voting_keypair.sk.sign(message)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -165,7 +159,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
}
|
||||
|
||||
// Check for slashing conditions.
|
||||
let fork = self.fork()?;
|
||||
let fork = self.fork();
|
||||
let domain = self.spec.get_domain(
|
||||
block.epoch(),
|
||||
Domain::BeaconProposer,
|
||||
@@ -237,7 +231,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
}
|
||||
|
||||
// Checking for slashing conditions.
|
||||
let fork = self.fork()?;
|
||||
let fork = self.fork();
|
||||
|
||||
let domain = self.spec.get_domain(
|
||||
attestation.data.target.epoch,
|
||||
@@ -339,7 +333,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
aggregate,
|
||||
Some(selection_proof),
|
||||
&voting_keypair.sk,
|
||||
&self.fork()?,
|
||||
&self.fork(),
|
||||
self.genesis_validators_root,
|
||||
&self.spec,
|
||||
))
|
||||
@@ -360,7 +354,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
Some(SelectionProof::new::<E>(
|
||||
slot,
|
||||
&voting_keypair.sk,
|
||||
&self.fork()?,
|
||||
&self.fork(),
|
||||
self.genesis_validators_root,
|
||||
&self.spec,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user