mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 04:44:28 +00:00
Fix bug with epoch of attestation votes
This commit is contained in:
@@ -1057,10 +1057,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
{
|
{
|
||||||
// Provide the attestation to fork choice, updating the validator latest messages but
|
// Provide the attestation to fork choice, updating the validator latest messages but
|
||||||
// _without_ finding and updating the head.
|
// _without_ finding and updating the head.
|
||||||
if let Err(e) = self
|
if let Err(e) = self.fork_choice.process_attestation(&state, &attestation) {
|
||||||
.fork_choice
|
|
||||||
.process_attestation(&state, &attestation, block)
|
|
||||||
{
|
|
||||||
error!(
|
error!(
|
||||||
self.log,
|
self.log,
|
||||||
"Add attestation to fork choice failed";
|
"Add attestation to fork choice failed";
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
.backend
|
.backend
|
||||||
.contains_block(&attestation.data.beacon_block_root)
|
.contains_block(&attestation.data.beacon_block_root)
|
||||||
{
|
{
|
||||||
self.process_attestation(state, attestation, block)?;
|
self.process_attestation(state, attestation)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +311,6 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
&self,
|
&self,
|
||||||
state: &BeaconState<T::EthSpec>,
|
state: &BeaconState<T::EthSpec>,
|
||||||
attestation: &Attestation<T::EthSpec>,
|
attestation: &Attestation<T::EthSpec>,
|
||||||
block: &BeaconBlock<T::EthSpec>,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let timer = metrics::start_timer(&metrics::FORK_CHOICE_PROCESS_ATTESTATION_TIMES);
|
let timer = metrics::start_timer(&metrics::FORK_CHOICE_PROCESS_ATTESTATION_TIMES);
|
||||||
|
|
||||||
@@ -340,7 +339,7 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
|
|||||||
self.backend.process_attestation(
|
self.backend.process_attestation(
|
||||||
validator_index,
|
validator_index,
|
||||||
block_hash,
|
block_hash,
|
||||||
block.slot.epoch(T::EthSpec::slots_per_epoch()),
|
attestation.data.target.epoch,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,14 +130,14 @@ impl ProtoArrayForkChoice {
|
|||||||
&self,
|
&self,
|
||||||
validator_index: usize,
|
validator_index: usize,
|
||||||
block_root: Hash256,
|
block_root: Hash256,
|
||||||
block_epoch: Epoch,
|
target_epoch: Epoch,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let mut votes = self.votes.write();
|
let mut votes = self.votes.write();
|
||||||
let vote = votes.get_mut(validator_index);
|
let vote = votes.get_mut(validator_index);
|
||||||
|
|
||||||
if block_epoch > vote.next_epoch || *vote == VoteTracker::default() {
|
if target_epoch > vote.next_epoch || *vote == VoteTracker::default() {
|
||||||
vote.next_root = block_root;
|
vote.next_root = block_root;
|
||||||
vote.next_epoch = block_epoch;
|
vote.next_epoch = target_epoch;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user