Add flag for paranoid block production

This commit is contained in:
Michael Sproul
2022-08-11 17:13:48 +10:00
parent 32969500d0
commit 8d757bb319
6 changed files with 38 additions and 14 deletions

View File

@@ -3403,18 +3403,14 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
)
.map_err(BlockProductionError::OpPoolError)?;
let paranoid = false;
let ultra_paranoid = true;
if paranoid {
let verify_sigs = if ultra_paranoid {
VerifySignatures::True
} else {
VerifySignatures::False
};
if self.config.paranoid_block_proposal {
attestations.retain(|att| {
let res =
verify_attestation_for_block_inclusion(&state, att, verify_sigs, &self.spec);
let res = verify_attestation_for_block_inclusion(
&state,
att,
VerifySignatures::True,
&self.spec,
);
if let Err(e) = res {
error!(
self.log,
@@ -3422,8 +3418,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
"err" => ?e,
"block_slot" => state.slot(),
);
panic!("Attempted to include an invalid attestation");
// false
false
} else {
true
}

View File

@@ -35,6 +35,8 @@ pub struct ChainConfig {
/// Whether any chain health checks should be considered when deciding whether to use the builder API.
pub builder_fallback_disable_checks: bool,
pub count_unrealized: bool,
/// Whether to apply paranoid checks to blocks proposed by this beacon node.
pub paranoid_block_proposal: bool,
}
impl Default for ChainConfig {
@@ -52,6 +54,7 @@ impl Default for ChainConfig {
builder_fallback_epochs_since_finalization: 3,
builder_fallback_disable_checks: false,
count_unrealized: true,
paranoid_block_proposal: false,
}
}
}

View File

@@ -23,7 +23,6 @@ pub fn upgrade_to_v12<T: BeaconChainTypes>(
"count" => v5.attestations_v5.len(),
);
// FIXME(sproul): work out whether it's worth trying to carry across the attestations
let v12 = PersistedOperationPool::V12(PersistedOperationPoolV12 {
attestations: vec![],
sync_contributions: v5.sync_contributions,