Embed trusted setup in network config (#3851)
* Load trusted setup in network config * Fix trusted setup serialize and deserialize * Load trusted setup from hardcoded preset instead of a file * Truncate after deserialising trusted setup * Fix beacon node script * Remove hardcoded setup file * Add length checks
This commit is contained in:
@@ -39,6 +39,7 @@ eth2_network_config = { path = "../common/eth2_network_config" }
|
||||
execution_layer = { path = "execution_layer" }
|
||||
lighthouse_network = { path = "./lighthouse_network" }
|
||||
serde = "1.0.116"
|
||||
serde_json = "1.0.58"
|
||||
clap_utils = { path = "../common/clap_utils" }
|
||||
hyper = "0.14.4"
|
||||
lighthouse_version = { path = "../common/lighthouse_version" }
|
||||
|
||||
@@ -21,7 +21,7 @@ use eth1::Config as Eth1Config;
|
||||
use execution_layer::ExecutionLayer;
|
||||
use fork_choice::{ForkChoice, ResetPayloadStatuses};
|
||||
use futures::channel::mpsc::Sender;
|
||||
use kzg::Kzg;
|
||||
use kzg::{Kzg, TrustedSetup};
|
||||
use operation_pool::{OperationPool, PersistedOperationPool};
|
||||
use parking_lot::RwLock;
|
||||
use proto_array::ReOrgThreshold;
|
||||
@@ -29,7 +29,6 @@ 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};
|
||||
@@ -97,7 +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>,
|
||||
trusted_setup: Option<TrustedSetup>,
|
||||
task_executor: Option<TaskExecutor>,
|
||||
}
|
||||
|
||||
@@ -137,7 +136,7 @@ where
|
||||
slasher: None,
|
||||
validator_monitor: None,
|
||||
pending_io_batch: vec![],
|
||||
trusted_setup_path: None,
|
||||
trusted_setup: None,
|
||||
task_executor: None,
|
||||
}
|
||||
}
|
||||
@@ -594,8 +593,8 @@ where
|
||||
self
|
||||
}
|
||||
|
||||
pub fn trusted_setup(mut self, trusted_setup_file_path: PathBuf) -> Self {
|
||||
self.trusted_setup_path = Some(trusted_setup_file_path);
|
||||
pub fn trusted_setup(mut self, trusted_setup: TrustedSetup) -> Self {
|
||||
self.trusted_setup = Some(trusted_setup);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -640,8 +639,8 @@ 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)
|
||||
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))?;
|
||||
Some(Arc::new(kzg))
|
||||
} else {
|
||||
|
||||
@@ -70,6 +70,7 @@ pub use events::ServerSentEventHandler;
|
||||
pub use execution_layer::EngineState;
|
||||
pub use execution_payload::NotifyExecutionLayer;
|
||||
pub use fork_choice::{ExecutionStatus, ForkchoiceUpdateParameters};
|
||||
pub use kzg::TrustedSetup;
|
||||
pub use metrics::scrape_for_metrics;
|
||||
pub use parking_lot;
|
||||
pub use slot_clock;
|
||||
|
||||
@@ -185,8 +185,8 @@ where
|
||||
builder
|
||||
};
|
||||
|
||||
let builder = if let Some(trusted_setup_file) = config.trusted_setup_file {
|
||||
builder.trusted_setup(trusted_setup_file)
|
||||
let builder = if let Some(trusted_setup) = config.trusted_setup {
|
||||
builder.trusted_setup(trusted_setup)
|
||||
} else {
|
||||
builder
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use beacon_chain::TrustedSetup;
|
||||
use directory::DEFAULT_ROOT_DIR;
|
||||
use environment::LoggerConfig;
|
||||
use network::NetworkConfig;
|
||||
@@ -68,7 +69,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 trusted_setup: Option<TrustedSetup>,
|
||||
pub http_api: http_api::Config,
|
||||
pub http_metrics: http_metrics::Config,
|
||||
pub monitoring_api: Option<monitoring_api::Config>,
|
||||
@@ -91,7 +92,7 @@ impl Default for Config {
|
||||
sync_eth1_chain: false,
|
||||
eth1: <_>::default(),
|
||||
execution_layer: None,
|
||||
trusted_setup_file: None,
|
||||
trusted_setup: None,
|
||||
graffiti: Graffiti::default(),
|
||||
http_api: <_>::default(),
|
||||
http_metrics: <_>::default(),
|
||||
|
||||
@@ -513,13 +513,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
)
|
||||
/* 4844 settings */
|
||||
.arg(
|
||||
Arg::with_name("trusted-setup-file")
|
||||
.long("trusted-setup-file")
|
||||
Arg::with_name("trusted-setup-file-override")
|
||||
.long("trusted-setup-file-override")
|
||||
.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")
|
||||
.help("Path to a json file containing the trusted setup params. \
|
||||
NOTE: This will override the trusted setup that is generated \
|
||||
from the mainnet kzg ceremony. Use with caution")
|
||||
.takes_value(true)
|
||||
)
|
||||
/*
|
||||
|
||||
@@ -2,6 +2,7 @@ use beacon_chain::chain_config::{
|
||||
ReOrgThreshold, DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR,
|
||||
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_THRESHOLD,
|
||||
};
|
||||
use beacon_chain::TrustedSetup;
|
||||
use clap::ArgMatches;
|
||||
use clap_utils::flags::DISABLE_MALLOC_TUNING_FLAG;
|
||||
use client::{ClientConfig, ClientGenesis};
|
||||
@@ -371,8 +372,19 @@ pub fn get_config<E: EthSpec>(
|
||||
}
|
||||
|
||||
// 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));
|
||||
client_config.trusted_setup = context
|
||||
.eth2_network_config
|
||||
.as_ref()
|
||||
.and_then(|config| config.kzg_trusted_setup.clone());
|
||||
|
||||
// Override default trusted setup file if required
|
||||
// TODO: consider removing this when we get closer to launch
|
||||
if let Some(trusted_setup_file_path) = cli_args.value_of("trusted-setup-file-override") {
|
||||
let file = std::fs::File::open(trusted_setup_file_path)
|
||||
.map_err(|e| format!("Failed to open trusted setup file: {}", e))?;
|
||||
let trusted_setup: TrustedSetup = serde_json::from_reader(file)
|
||||
.map_err(|e| format!("Unable to read trusted setup file: {}", e))?;
|
||||
client_config.trusted_setup = Some(trusted_setup);
|
||||
}
|
||||
|
||||
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
||||
|
||||
Reference in New Issue
Block a user