Shift networking configuration (#4426)

## Issue Addressed
Addresses [#4401](https://github.com/sigp/lighthouse/issues/4401)

## Proposed Changes
Shift some constants into ```ChainSpec``` and remove the constant values from code space.

## Additional Info

I mostly used ```MainnetEthSpec::default_spec()``` for getting ```ChainSpec```. I wonder Did I make a mistake about that.


Co-authored-by: armaganyildirak <armaganyildirak@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
Co-authored-by: Age Manning <Age@AgeManning.com>
Co-authored-by: Diva M <divma@protonmail.com>
This commit is contained in:
Armağan Yıldırak
2023-08-03 01:51:47 +00:00
parent 7399a54ca3
commit 3397612160
36 changed files with 523 additions and 213 deletions

View File

@@ -1634,6 +1634,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
attestation_verification::verify_propagation_slot_range(
seen_clock,
failed_att.attestation(),
&self.chain.spec,
);
// Only penalize the peer if it would have been invalid at the moment we received
@@ -2182,6 +2183,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
sync_committee_verification::verify_propagation_slot_range(
seen_clock,
&sync_committee_message_slot,
&self.chain.spec,
);
hindsight_verification.is_err()
};
@@ -2494,6 +2496,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
let is_timely = attestation_verification::verify_propagation_slot_range(
&self.chain.slot_clock,
attestation,
&self.chain.spec,
)
.is_ok();

View File

@@ -577,14 +577,3 @@ impl<E: EthSpec> NetworkBeaconProcessor<TestBeaconChainType<E>> {
(network_beacon_processor, beacon_processor_receive)
}
}
#[cfg(test)]
mod test {
#[test]
fn queued_block_delay_is_sane() {
assert!(
beacon_processor::work_reprocessing_queue::ADDITIONAL_QUEUED_BLOCK_DELAY
< beacon_chain::MAXIMUM_GOSSIP_CLOCK_DISPARITY
);
}
}

View File

@@ -11,7 +11,7 @@ use crate::{
use beacon_chain::test_utils::{
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
};
use beacon_chain::{BeaconChain, ChainConfig, MAXIMUM_GOSSIP_CLOCK_DISPARITY};
use beacon_chain::{BeaconChain, ChainConfig};
use beacon_processor::{work_reprocessing_queue::*, *};
use lighthouse_network::{
discv5::enr::{CombinedKey, EnrBuilder},
@@ -215,7 +215,7 @@ impl TestRig {
};
let network_beacon_processor = Arc::new(network_beacon_processor);
BeaconProcessor {
let beacon_processor = BeaconProcessor {
network_globals,
executor,
max_workers: cmp::max(1, num_cpus::get()),
@@ -229,8 +229,11 @@ impl TestRig {
work_reprocessing_rx,
Some(work_journal_tx),
harness.chain.slot_clock.clone(),
chain.spec.maximum_gossip_clock_disparity(),
);
assert!(!beacon_processor.is_err());
Self {
chain,
next_block: Arc::new(next_block),
@@ -505,7 +508,7 @@ async fn import_gossip_block_acceptably_early() {
rig.chain
.slot_clock
.set_current_time(slot_start - MAXIMUM_GOSSIP_CLOCK_DISPARITY);
.set_current_time(slot_start - rig.chain.spec.maximum_gossip_clock_disparity());
assert_eq!(
rig.chain.slot().unwrap(),
@@ -552,9 +555,9 @@ async fn import_gossip_block_unacceptably_early() {
.start_of(rig.next_block.slot())
.unwrap();
rig.chain
.slot_clock
.set_current_time(slot_start - MAXIMUM_GOSSIP_CLOCK_DISPARITY - Duration::from_millis(1));
rig.chain.slot_clock.set_current_time(
slot_start - rig.chain.spec.maximum_gossip_clock_disparity() - Duration::from_millis(1),
);
assert_eq!(
rig.chain.slot().unwrap(),