Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 122 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ reqwest = { version = "0.11", default-features = false, features = [
ring = "0.17"
rpds = "0.11"
rusqlite = { version = "0.28", features = ["bundled"] }
rust_eth_kzg = "0.5.4"
rust_eth_kzg = "0.8.0"
safe_arith = { path = "consensus/safe_arith" }
sensitive_url = { path = "common/sensitive_url" }
serde = { version = "1", features = ["derive"] }
Expand Down
7 changes: 2 additions & 5 deletions beacon_node/beacon_chain/src/kzg_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ mod test {
use bls::Signature;
use eth2::types::BlobsBundle;
use execution_layer::test_utils::generate_blobs;
use kzg::{Kzg, KzgCommitment, TrustedSetup, trusted_setup::get_trusted_setup};
use kzg::{Kzg, KzgCommitment, trusted_setup::get_trusted_setup};
use types::{
BeaconBlock, BeaconBlockFulu, BlobsList, ChainSpec, EmptyBlock, EthSpec, ForkName,
FullPayload, KzgProofs, MainnetEthSpec, SignedBeaconBlock,
Expand Down Expand Up @@ -569,10 +569,7 @@ mod test {
}

fn get_kzg() -> Kzg {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.expect("should have trusted setup");
Kzg::new_from_trusted_setup_das_enabled(trusted_setup).expect("should create kzg")
Kzg::new_from_trusted_setup(&get_trusted_setup()).expect("should create kzg")
}

fn create_test_fulu_block_and_blobs<E: EthSpec>(
Expand Down
23 changes: 4 additions & 19 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ use execution_layer::{
use futures::channel::mpsc::Receiver;
pub use genesis::{DEFAULT_ETH1_BLOCK_HASH, InteropGenesisBuilder};
use int_to_bytes::int_to_bytes32;
use kzg::Kzg;
use kzg::trusted_setup::get_trusted_setup;
use kzg::{Kzg, TrustedSetup};
use logging::create_test_tracing_subscriber;
use merkle_proof::MerkleTree;
use operation_pool::ReceivedPreCapella;
Expand Down Expand Up @@ -81,33 +81,18 @@ pub const TEST_DATA_COLUMN_SIDECARS_SSZ: &[u8] =
pub const DEFAULT_TARGET_AGGREGATORS: u64 = u64::MAX;

static KZG: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.expect("should have trusted setup");
let kzg = Kzg::new_from_trusted_setup(trusted_setup).expect("should create kzg");
Arc::new(kzg)
});

static KZG_PEERDAS: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.expect("should have trusted setup");
let kzg = Kzg::new_from_trusted_setup_das_enabled(trusted_setup).expect("should create kzg");
let kzg = Kzg::new_from_trusted_setup(&get_trusted_setup()).expect("should create kzg");
Arc::new(kzg)
});

static KZG_NO_PRECOMP: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.expect("should have trusted setup");
let kzg = Kzg::new_from_trusted_setup_no_precomp(trusted_setup).expect("should create kzg");
let kzg =
Kzg::new_from_trusted_setup_no_precomp(&get_trusted_setup()).expect("should create kzg");
Arc::new(kzg)
});

pub fn get_kzg(spec: &ChainSpec) -> Arc<Kzg> {
if spec.fulu_fork_epoch.is_some() {
KZG_PEERDAS.clone()
} else if spec.deneb_fork_epoch.is_some() {
KZG.clone()
} else {
KZG_NO_PRECOMP.clone()
Expand Down
7 changes: 2 additions & 5 deletions beacon_node/client/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,10 @@ where
};

let kzg_err_msg = |e| format!("Failed to load trusted setup: {:?}", e);
let trusted_setup = config.trusted_setup.clone();
let kzg = if spec.is_peer_das_scheduled() {
Kzg::new_from_trusted_setup_das_enabled(trusted_setup).map_err(kzg_err_msg)?
} else if spec.deneb_fork_epoch.is_some() {
Kzg::new_from_trusted_setup(trusted_setup).map_err(kzg_err_msg)?
Kzg::new_from_trusted_setup(&config.trusted_setup).map_err(kzg_err_msg)?
} else {
Kzg::new_from_trusted_setup_no_precomp(trusted_setup).map_err(kzg_err_msg)?
Kzg::new_from_trusted_setup_no_precomp(&config.trusted_setup).map_err(kzg_err_msg)?
};

let builder = BeaconChainBuilder::new(eth_spec_instance, Arc::new(kzg))
Expand Down
8 changes: 2 additions & 6 deletions beacon_node/client/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use beacon_chain::TrustedSetup;
use beacon_chain::graffiti_calculator::GraffitiOrigin;
use beacon_chain::validator_monitor::ValidatorMonitorConfig;
use beacon_processor::BeaconProcessorConfig;
Expand Down Expand Up @@ -70,7 +69,7 @@ pub struct Config {
pub network: network::NetworkConfig,
pub chain: beacon_chain::ChainConfig,
pub execution_layer: Option<execution_layer::Config>,
pub trusted_setup: TrustedSetup,
pub trusted_setup: Vec<u8>,
pub http_api: http_api::Config,
pub http_metrics: http_metrics::Config,
pub monitoring_api: Option<monitoring_api::Config>,
Expand All @@ -84,9 +83,6 @@ pub struct Config {

impl Default for Config {
fn default() -> Self {
let trusted_setup: TrustedSetup = serde_json::from_reader(get_trusted_setup().as_slice())
.expect("Unable to read trusted setup file");

Self {
data_dir: PathBuf::from(DEFAULT_ROOT_DIR),
db_name: "chain_db".to_string(),
Expand All @@ -98,7 +94,7 @@ impl Default for Config {
network: NetworkConfig::default(),
chain: <_>::default(),
execution_layer: None,
trusted_setup,
trusted_setup: get_trusted_setup(),
beacon_graffiti: GraffitiOrigin::default(),
http_api: <_>::default(),
http_metrics: <_>::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ pub fn generate_pow_block(
#[cfg(test)]
mod test {
use super::*;
use kzg::{Bytes48, CellRef, KzgBlobRef, TrustedSetup, trusted_setup::get_trusted_setup};
use kzg::{Bytes48, CellRef, KzgBlobRef, trusted_setup::get_trusted_setup};
use types::{MainnetEthSpec, MinimalEthSpec};

#[test]
Expand Down Expand Up @@ -1056,10 +1056,7 @@ mod test {
}

fn load_kzg() -> Result<Kzg, String> {
let trusted_setup: TrustedSetup =
serde_json::from_reader(get_trusted_setup().as_slice())
.map_err(|e| format!("Unable to read trusted setup file: {e:?}"))?;
Kzg::new_from_trusted_setup(trusted_setup)
Kzg::new_from_trusted_setup(&get_trusted_setup())
.map_err(|e| format!("Failed to load trusted setup: {e:?}"))
}
}
21 changes: 4 additions & 17 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use account_utils::{STDIN_INPUTS_FLAG, read_input_from_user};
use beacon_chain::TrustedSetup;
use beacon_chain::chain_config::{
DEFAULT_PREPARE_PAYLOAD_LOOKAHEAD_FACTOR, DEFAULT_RE_ORG_HEAD_THRESHOLD,
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION, DEFAULT_RE_ORG_PARENT_THRESHOLD,
Expand Down Expand Up @@ -349,25 +348,13 @@ pub fn get_config<E: EthSpec>(
// Store the EL config in the client config.
client_config.execution_layer = Some(el_config);

// 4844 params
if let Some(trusted_setup) = context
.eth2_network_config
.as_ref()
.map(|config| serde_json::from_slice(&config.kzg_trusted_setup))
.transpose()
.map_err(|e| format!("Unable to read trusted setup file: {}", e))?
{
client_config.trusted_setup = trusted_setup;
};

// Override default trusted setup file if required
if let Some(trusted_setup_file_path) = cli_args.get_one::<String>("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 = trusted_setup;
client_config.trusted_setup = std::fs::read(trusted_setup_file_path)
.map_err(|e| format!("Failed to read trusted setup file: {}", e))?;
} else if let Some(eth2_network_config) = context.eth2_network_config.as_ref() {
client_config.trusted_setup = eth2_network_config.kzg_trusted_setup.clone();
}

if let Some(freezer_dir) = cli_args.get_one::<String>("freezer-dir") {
Expand Down
Loading