mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-21 13:54:44 +00:00
Add kzg trusted setup file cli param and load into beacon chain
This commit is contained in:
@@ -21,12 +21,14 @@ use eth1::Config as Eth1Config;
|
||||
use execution_layer::ExecutionLayer;
|
||||
use fork_choice::{ForkChoice, ResetPayloadStatuses};
|
||||
use futures::channel::mpsc::Sender;
|
||||
use kzg::Kzg;
|
||||
use operation_pool::{OperationPool, PersistedOperationPool};
|
||||
use parking_lot::RwLock;
|
||||
use slasher::Slasher;
|
||||
use slog::{crit, error, info, Logger};
|
||||
use slot_clock::{SlotClock, TestingSlotClock};
|
||||
use std::marker::PhantomData;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use store::{Error as StoreError, HotColdDB, ItemStore, KeyValueStoreOp};
|
||||
@@ -94,6 +96,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_path: Option<PathBuf>,
|
||||
task_executor: Option<TaskExecutor>,
|
||||
}
|
||||
|
||||
@@ -133,6 +136,7 @@ where
|
||||
slasher: None,
|
||||
validator_monitor: None,
|
||||
pending_io_batch: vec![],
|
||||
trusted_setup_path: None,
|
||||
task_executor: None,
|
||||
}
|
||||
}
|
||||
@@ -572,6 +576,11 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn trusted_setup(mut self, trusted_setup_file_path: PathBuf) -> Self {
|
||||
self.trusted_setup_path = Some(trusted_setup_file_path);
|
||||
self
|
||||
}
|
||||
|
||||
/// Consumes `self`, returning a `BeaconChain` if all required parameters have been supplied.
|
||||
///
|
||||
/// An error will be returned at runtime if all required parameters have not been configured.
|
||||
@@ -613,6 +622,14 @@ where
|
||||
slot_clock.now().ok_or("Unable to read slot")?
|
||||
};
|
||||
|
||||
let kzg = if let Some(trusted_setup_file) = self.trusted_setup_path {
|
||||
let kzg = Kzg::new_from_file(trusted_setup_file)
|
||||
.map_err(|e| format!("Failed to load trusted setup: {:?}", e))?;
|
||||
Some(Arc::new(kzg))
|
||||
} 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))?;
|
||||
@@ -814,6 +831,7 @@ where
|
||||
slasher: self.slasher.clone(),
|
||||
validator_monitor: RwLock::new(validator_monitor),
|
||||
blob_cache: BlobCache::default(),
|
||||
kzg,
|
||||
};
|
||||
|
||||
let head = beacon_chain.head_snapshot();
|
||||
|
||||
Reference in New Issue
Block a user