Merge branch 'master' into block-processing-times
This commit is contained in:
commit
072eb82fe4
@ -25,3 +25,4 @@ lmd_ghost = { path = "../../eth2/lmd_ghost" }
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.5.5"
|
rand = "0.5.5"
|
||||||
|
lazy_static = "1.3.0"
|
||||||
|
@ -558,31 +558,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
.store
|
.store
|
||||||
.get::<BeaconBlock<T::EthSpec>>(&attestation.data.beacon_block_root)?
|
.get::<BeaconBlock<T::EthSpec>>(&attestation.data.beacon_block_root)?
|
||||||
{
|
{
|
||||||
let finalized_epoch = self.head().beacon_state.finalized_checkpoint.epoch;
|
|
||||||
|
|
||||||
if attestation_head_block.slot
|
|
||||||
<= finalized_epoch.start_slot(T::EthSpec::slots_per_epoch())
|
|
||||||
{
|
|
||||||
// Ignore any attestation where the slot of `data.beacon_block_root` is equal to or
|
|
||||||
// prior to the finalized epoch.
|
|
||||||
//
|
|
||||||
// For any valid attestation if the `beacon_block_root` is prior to finalization, then
|
|
||||||
// all other parameters (source, target, etc) must all be prior to finalization and
|
|
||||||
// therefore no longer interesting.
|
|
||||||
return Ok(AttestationProcessingOutcome::FinalizedSlot {
|
|
||||||
attestation: attestation_head_block.epoch(),
|
|
||||||
finalized: finalized_epoch,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to process the attestation using the `self.head()` state.
|
// Attempt to process the attestation using the `self.head()` state.
|
||||||
//
|
//
|
||||||
// This is purely an effort to avoid loading a `BeaconState` unnecessarily from the DB.
|
// This is purely an effort to avoid loading a `BeaconState` unnecessarily from the DB.
|
||||||
let optional_outcome: Option<Result<AttestationProcessingOutcome, Error>> = {
|
|
||||||
// Take a read lock on the head beacon state.
|
// Take a read lock on the head beacon state.
|
||||||
//
|
|
||||||
// The purpose of this whole `let processed ...` block is to ensure that the read
|
|
||||||
// lock is dropped if we don't end up using the head beacon state.
|
|
||||||
let state = &self.head().beacon_state;
|
let state = &self.head().beacon_state;
|
||||||
|
|
||||||
// If it turns out that the attestation was made using the head state, then there
|
// If it turns out that the attestation was made using the head state, then there
|
||||||
@ -605,20 +584,19 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
{
|
{
|
||||||
// The head state is able to be used to validate this attestation. No need to load
|
// The head state is able to be used to validate this attestation. No need to load
|
||||||
// anything from the database.
|
// anything from the database.
|
||||||
Some(self.process_attestation_for_state_and_block(
|
return self.process_attestation_for_state_and_block(
|
||||||
attestation.clone(),
|
attestation.clone(),
|
||||||
state,
|
state,
|
||||||
&attestation_head_block,
|
&attestation_head_block,
|
||||||
))
|
);
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(outcome) = optional_outcome {
|
// Ensure the read-lock from `self.head()` is dropped.
|
||||||
// Verification was already completed with an in-memory state. Return that result.
|
//
|
||||||
outcome
|
// This is likely unnecessary, however it remains as a reminder to ensure this lock
|
||||||
} else {
|
// isn't hogged.
|
||||||
|
std::mem::drop(state);
|
||||||
|
|
||||||
// Use the `data.beacon_block_root` to load the state from the latest non-skipped
|
// Use the `data.beacon_block_root` to load the state from the latest non-skipped
|
||||||
// slot preceding the attestation's creation.
|
// slot preceding the attestation's creation.
|
||||||
//
|
//
|
||||||
@ -669,7 +647,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
&attestation_head_block,
|
&attestation_head_block,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Drop any attestation where we have not processed `attestation.data.beacon_block_root`.
|
// Drop any attestation where we have not processed `attestation.data.beacon_block_root`.
|
||||||
//
|
//
|
||||||
@ -737,7 +714,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
result
|
result
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = if block.slot <= finalized_epoch.start_slot(T::EthSpec::slots_per_epoch()) {
|
if block.slot <= finalized_epoch.start_slot(T::EthSpec::slots_per_epoch()) {
|
||||||
// Ignore any attestation where the slot of `data.beacon_block_root` is equal to or
|
// Ignore any attestation where the slot of `data.beacon_block_root` is equal to or
|
||||||
// prior to the finalized epoch.
|
// prior to the finalized epoch.
|
||||||
//
|
//
|
||||||
@ -774,9 +751,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
metrics::inc_counter(&metrics::ATTESTATION_PROCESSING_SUCCESSES);
|
metrics::inc_counter(&metrics::ATTESTATION_PROCESSING_SUCCESSES);
|
||||||
|
|
||||||
Ok(AttestationProcessingOutcome::Processed)
|
Ok(AttestationProcessingOutcome::Processed)
|
||||||
};
|
}
|
||||||
|
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some deposit and queue it for inclusion in an appropriate block.
|
/// Accept some deposit and queue it for inclusion in an appropriate block.
|
||||||
|
Loading…
Reference in New Issue
Block a user