mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 03:30:38 +00:00
Add kzg trusted setup file cli param and load into beacon chain
This commit is contained in:
parent
3c9e1abcb7
commit
3075b82ea0
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -712,7 +712,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "c-kzg"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pawanjay176/c-kzg-4844?rev=cb3745d26b728ee526dc41912e3e1bc6f17a5eeb#cb3745d26b728ee526dc41912e3e1bc6f17a5eeb"
|
||||
source = "git+https://github.com/pawanjay176/c-kzg-4844?rev=669a13800a8a0d094c5387db58e06936ef194a25#669a13800a8a0d094c5387db58e06936ef194a25"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"libc",
|
||||
|
@ -399,6 +399,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
|
||||
/// Provides monitoring of a set of explicitly defined validators.
|
||||
pub validator_monitor: RwLock<ValidatorMonitor<T::EthSpec>>,
|
||||
pub blob_cache: BlobCache<T::EthSpec>,
|
||||
pub kzg: Option<Arc<kzg::Kzg>>,
|
||||
}
|
||||
|
||||
type BeaconBlockAndState<T, Payload> = (BeaconBlock<T, Payload>, BeaconState<T>);
|
||||
|
@ -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();
|
||||
|
@ -188,6 +188,12 @@ where
|
||||
builder
|
||||
};
|
||||
|
||||
let builder = if let Some(trusted_setup_file) = config.trusted_setup_file {
|
||||
builder.trusted_setup(trusted_setup_file)
|
||||
} else {
|
||||
builder
|
||||
};
|
||||
|
||||
let chain_exists = builder.store_contains_beacon_chain().unwrap_or(false);
|
||||
|
||||
// If the client is expect to resume but there's no beacon chain in the database,
|
||||
|
@ -68,6 +68,7 @@ pub struct Config {
|
||||
pub chain: beacon_chain::ChainConfig,
|
||||
pub eth1: eth1::Config,
|
||||
pub execution_layer: Option<execution_layer::Config>,
|
||||
pub trusted_setup_file: Option<PathBuf>,
|
||||
pub http_api: http_api::Config,
|
||||
pub http_metrics: http_metrics::Config,
|
||||
pub monitoring_api: Option<monitoring_api::Config>,
|
||||
@ -90,6 +91,7 @@ impl Default for Config {
|
||||
sync_eth1_chain: false,
|
||||
eth1: <_>::default(),
|
||||
execution_layer: None,
|
||||
trusted_setup_file: None,
|
||||
graffiti: Graffiti::default(),
|
||||
http_api: <_>::default(),
|
||||
http_metrics: <_>::default(),
|
||||
|
@ -511,6 +511,17 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
.default_value("1")
|
||||
.takes_value(true)
|
||||
)
|
||||
/* 4844 settings */
|
||||
.arg(
|
||||
Arg::with_name("trusted-setup-file")
|
||||
.long("trusted-setup-file")
|
||||
.value_name("FILE")
|
||||
.help("File containing the trusted setup parameters. \
|
||||
NOTE: This is only for the devnet, the trusted setup params \
|
||||
must be embedded into the ethspec once parameter loading \
|
||||
is supported in the ckzg library")
|
||||
.takes_value(true)
|
||||
)
|
||||
/*
|
||||
* Database purging and compaction.
|
||||
*/
|
||||
|
@ -360,6 +360,11 @@ pub fn get_config<E: EthSpec>(
|
||||
client_config.execution_layer = Some(el_config);
|
||||
}
|
||||
|
||||
// 4844 params
|
||||
if let Some(trusted_setup_file) = cli_args.value_of("trusted-setup-file") {
|
||||
client_config.trusted_setup_file = Some(PathBuf::from(trusted_setup_file));
|
||||
}
|
||||
|
||||
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
||||
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
||||
}
|
||||
|
@ -18,4 +18,5 @@ eth2_serde_utils = "0.1.1"
|
||||
hex = "0.4.2"
|
||||
eth2_hashing = "0.3.0"
|
||||
ethereum-types = "0.12.1"
|
||||
c-kzg = {git = "https://github.com/pawanjay176/c-kzg-4844", rev = "cb3745d26b728ee526dc41912e3e1bc6f17a5eeb" }
|
||||
c-kzg = {git = "https://github.com/pawanjay176/c-kzg-4844", rev = "669a13800a8a0d094c5387db58e06936ef194a25" }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user