mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Add flag for paranoid block production
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -714,6 +714,16 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.default_value("250")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("paranoid-block-proposal")
|
||||
.long("paranoid-block-proposal")
|
||||
.help("Paranoid enough to be reading the source? Nice. This flag reverts some \
|
||||
block proposal optimisations and forces the node to check every attestation \
|
||||
it includes super thoroughly. This may be useful in an emergency, but not \
|
||||
otherwise.")
|
||||
.hidden(true)
|
||||
.takes_value(false)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("builder-fallback-skips")
|
||||
.long("builder-fallback-skips")
|
||||
|
||||
@@ -640,6 +640,8 @@ pub fn get_config<E: EthSpec>(
|
||||
client_config.chain.count_unrealized =
|
||||
clap_utils::parse_required(cli_args, "count-unrealized")?;
|
||||
|
||||
client_config.chain.paranoid_block_proposal = cli_args.is_present("paranoid-block-proposal");
|
||||
|
||||
/*
|
||||
* Builder fallback configs.
|
||||
*/
|
||||
|
||||
@@ -132,6 +132,21 @@ fn fork_choice_before_proposal_timeout_zero() {
|
||||
.with_config(|config| assert_eq!(config.chain.fork_choice_before_proposal_timeout_ms, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paranoid_block_proposal_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(!config.chain.paranoid_block_proposal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paranoid_block_proposal_on() {
|
||||
CommandLineTest::new()
|
||||
.flag("paranoid-block-proposal", None)
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert!(config.chain.paranoid_block_proposal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn count_unrealized_default() {
|
||||
CommandLineTest::new()
|
||||
|
||||
Reference in New Issue
Block a user