mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 22:04:44 +00:00
Only load Kzg in tests if necessary and only load it once (#5555)
* Only load KZG once if necessary in tests.
This commit is contained in:
@@ -25,7 +25,7 @@ use eth1::Config as Eth1Config;
|
||||
use execution_layer::ExecutionLayer;
|
||||
use fork_choice::{ForkChoice, ResetPayloadStatuses};
|
||||
use futures::channel::mpsc::Sender;
|
||||
use kzg::{Kzg, TrustedSetup};
|
||||
use kzg::Kzg;
|
||||
use operation_pool::{OperationPool, PersistedOperationPool};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use proto_array::{DisallowedReOrgOffsets, ReOrgThreshold};
|
||||
@@ -101,7 +101,7 @@ pub struct BeaconChainBuilder<T: BeaconChainTypes> {
|
||||
// Pending I/O batch that is constructed during building and should be executed atomically
|
||||
// alongside `PersistedBeaconChain` storage when `BeaconChainBuilder::build` is called.
|
||||
pending_io_batch: Vec<KeyValueStoreOp>,
|
||||
trusted_setup: Option<TrustedSetup>,
|
||||
kzg: Option<Arc<Kzg>>,
|
||||
task_executor: Option<TaskExecutor>,
|
||||
validator_monitor_config: Option<ValidatorMonitorConfig>,
|
||||
}
|
||||
@@ -142,7 +142,7 @@ where
|
||||
graffiti: Graffiti::default(),
|
||||
slasher: None,
|
||||
pending_io_batch: vec![],
|
||||
trusted_setup: None,
|
||||
kzg: None,
|
||||
task_executor: None,
|
||||
validator_monitor_config: None,
|
||||
}
|
||||
@@ -669,8 +669,8 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn trusted_setup(mut self, trusted_setup: TrustedSetup) -> Self {
|
||||
self.trusted_setup = Some(trusted_setup);
|
||||
pub fn kzg(mut self, kzg: Option<Arc<Kzg>>) -> Self {
|
||||
self.kzg = kzg;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -718,15 +718,6 @@ where
|
||||
slot_clock.now().ok_or("Unable to read slot")?
|
||||
};
|
||||
|
||||
let kzg = if let Some(trusted_setup) = self.trusted_setup {
|
||||
let kzg = Kzg::new_from_trusted_setup(trusted_setup)
|
||||
.map_err(|e| format!("Failed to load trusted setup: {:?}", e))?;
|
||||
let kzg_arc = Arc::new(kzg);
|
||||
Some(kzg_arc)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let initial_head_block_root = fork_choice
|
||||
.get_head(current_slot, &self.spec)
|
||||
.map_err(|e| format!("Unable to get fork choice head: {:?}", e))?;
|
||||
@@ -967,10 +958,10 @@ where
|
||||
validator_monitor: RwLock::new(validator_monitor),
|
||||
genesis_backfill_slot,
|
||||
data_availability_checker: Arc::new(
|
||||
DataAvailabilityChecker::new(slot_clock, kzg.clone(), store, &log, self.spec)
|
||||
DataAvailabilityChecker::new(slot_clock, self.kzg.clone(), store, &log, self.spec)
|
||||
.map_err(|e| format!("Error initializing DataAvailabiltyChecker: {:?}", e))?,
|
||||
),
|
||||
kzg,
|
||||
kzg: self.kzg.clone(),
|
||||
block_production_state: Arc::new(Mutex::new(None)),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user