mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 05:14:35 +00:00
Make BeaconChain::kzg field mandatory (#6267)
* make kzg field required * update todo * always load trusted setup WIP * fmt * use new rust_eth_kzg version * merge conlficts * add kzg fn with trusted setup disabled * as_slice * add kzg with no precomp * ignore udep for kzg * refactor kzg init * fix peerdas kzg schedule * fix * udeps * uuuudeps * merge conflict resolved * merge conflict * merge conflicts * resolve TODO * update * move kzg to a test util fn * remove trusted setup default impl * lint fmt * fix failing test * lint * fix test * Merge branch 'unstable' into beacon-chain-kzg-field-required
This commit is contained in:
@@ -18,7 +18,6 @@ use crate::{
|
||||
};
|
||||
use bls::get_withdrawal_credentials;
|
||||
use eth2::types::SignedBlockContentsTuple;
|
||||
use eth2_network_config::TRUSTED_SETUP_BYTES;
|
||||
use execution_layer::test_utils::generate_genesis_header;
|
||||
use execution_layer::{
|
||||
auth::JwtKey,
|
||||
@@ -31,6 +30,7 @@ use execution_layer::{
|
||||
use futures::channel::mpsc::Receiver;
|
||||
pub use genesis::{interop_genesis_state_with_eth1, DEFAULT_ETH1_BLOCK_HASH};
|
||||
use int_to_bytes::int_to_bytes32;
|
||||
use kzg::trusted_setup::get_trusted_setup;
|
||||
use kzg::{Kzg, TrustedSetup};
|
||||
use merkle_proof::MerkleTree;
|
||||
use operation_pool::ReceivedPreCapella;
|
||||
@@ -75,22 +75,40 @@ pub const FORK_NAME_ENV_VAR: &str = "FORK_NAME";
|
||||
// a different value.
|
||||
pub const DEFAULT_TARGET_AGGREGATORS: u64 = u64::MAX;
|
||||
|
||||
pub static KZG: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
|
||||
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
||||
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)
|
||||
});
|
||||
|
||||
pub static KZG_PEERDAS: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
|
||||
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
||||
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");
|
||||
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");
|
||||
Arc::new(kzg)
|
||||
});
|
||||
|
||||
pub fn get_kzg(spec: &ChainSpec) -> Arc<Kzg> {
|
||||
if spec.eip7594_fork_epoch.is_some() {
|
||||
KZG_PEERDAS.clone()
|
||||
} else if spec.deneb_fork_epoch.is_some() {
|
||||
KZG.clone()
|
||||
} else {
|
||||
KZG_NO_PRECOMP.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub type BaseHarnessType<E, THotStore, TColdStore> =
|
||||
Witness<TestingSlotClock, CachingEth1Backend<E>, E, THotStore, TColdStore>;
|
||||
|
||||
@@ -522,12 +540,13 @@ where
|
||||
let validator_keypairs = self
|
||||
.validator_keypairs
|
||||
.expect("cannot build without validator keypairs");
|
||||
let kzg = spec.deneb_fork_epoch.map(|_| KZG.clone());
|
||||
|
||||
let kzg = get_kzg(&spec);
|
||||
|
||||
let validator_monitor_config = self.validator_monitor_config.unwrap_or_default();
|
||||
|
||||
let chain_config = self.chain_config.unwrap_or_default();
|
||||
let mut builder = BeaconChainBuilder::new(self.eth_spec_instance)
|
||||
let mut builder = BeaconChainBuilder::new(self.eth_spec_instance, kzg.clone())
|
||||
.logger(log.clone())
|
||||
.custom_spec(spec.clone())
|
||||
.store(self.store.expect("cannot build without store"))
|
||||
@@ -546,8 +565,7 @@ where
|
||||
log.clone(),
|
||||
5,
|
||||
)))
|
||||
.validator_monitor_config(validator_monitor_config)
|
||||
.kzg(kzg);
|
||||
.validator_monitor_config(validator_monitor_config);
|
||||
|
||||
builder = if let Some(mutator) = self.initial_mutator {
|
||||
mutator(builder)
|
||||
@@ -602,7 +620,7 @@ pub fn mock_execution_layer_from_parts<E: EthSpec>(
|
||||
HARNESS_GENESIS_TIME + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
|
||||
});
|
||||
|
||||
let kzg_opt = spec.deneb_fork_epoch.map(|_| KZG.clone());
|
||||
let kzg = get_kzg(spec);
|
||||
|
||||
MockExecutionLayer::new(
|
||||
task_executor,
|
||||
@@ -612,7 +630,7 @@ pub fn mock_execution_layer_from_parts<E: EthSpec>(
|
||||
prague_time,
|
||||
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
|
||||
spec.clone(),
|
||||
kzg_opt,
|
||||
Some(kzg),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2842,9 +2860,10 @@ pub fn generate_rand_block_and_data_columns<E: EthSpec>(
|
||||
SignedBeaconBlock<E, FullPayload<E>>,
|
||||
Vec<Arc<DataColumnSidecar<E>>>,
|
||||
) {
|
||||
let kzg = get_kzg(spec);
|
||||
let (block, blobs) = generate_rand_block_and_blobs(fork_name, num_blobs, rng);
|
||||
let blob: BlobsList<E> = blobs.into_iter().map(|b| b.blob).collect::<Vec<_>>().into();
|
||||
let data_columns = blobs_to_data_column_sidecars(&blob, &block, &KZG_PEERDAS, spec).unwrap();
|
||||
let data_columns = blobs_to_data_column_sidecars(&blob, &block, &kzg, spec).unwrap();
|
||||
|
||||
(block, data_columns)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user