mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Add Electra fork boilerplate (#5122)
* Add Electra fork boilerplate * Remove electra from spec tests * Fix tests * Remove sneaky log file * Fix more tests * Fix even more tests and add suggestions * Remove unrelated lcli addition * Update more tests * Merge branch 'unstable' into electra * Add comment for test-suite lcli override * Merge branch 'unstable' into electra * Cleanup * Merge branch 'unstable' into electra * Apply suggestions * Merge branch 'unstable' into electra * Merge sigp/unstable into electra * Merge branch 'unstable' into electra
This commit is contained in:
@@ -458,6 +458,10 @@ where
|
||||
mock.server.execution_block_generator().cancun_time = spec.deneb_fork_epoch.map(|epoch| {
|
||||
genesis_time + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
|
||||
});
|
||||
mock.server.execution_block_generator().prague_time =
|
||||
spec.electra_fork_epoch.map(|epoch| {
|
||||
genesis_time + spec.seconds_per_slot * E::slots_per_epoch() * epoch.as_u64()
|
||||
});
|
||||
|
||||
self
|
||||
}
|
||||
@@ -579,6 +583,9 @@ pub fn mock_execution_layer_from_parts<T: EthSpec>(
|
||||
let cancun_time = spec.deneb_fork_epoch.map(|epoch| {
|
||||
HARNESS_GENESIS_TIME + spec.seconds_per_slot * T::slots_per_epoch() * epoch.as_u64()
|
||||
});
|
||||
let prague_time = spec.electra_fork_epoch.map(|epoch| {
|
||||
HARNESS_GENESIS_TIME + spec.seconds_per_slot * T::slots_per_epoch() * epoch.as_u64()
|
||||
});
|
||||
|
||||
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
||||
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
|
||||
@@ -590,6 +597,7 @@ pub fn mock_execution_layer_from_parts<T: EthSpec>(
|
||||
DEFAULT_TERMINAL_BLOCK,
|
||||
shanghai_time,
|
||||
cancun_time,
|
||||
prague_time,
|
||||
Some(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap()),
|
||||
spec.clone(),
|
||||
Some(kzg),
|
||||
@@ -877,7 +885,9 @@ where
|
||||
| SignedBeaconBlock::Altair(_)
|
||||
| SignedBeaconBlock::Merge(_)
|
||||
| SignedBeaconBlock::Capella(_) => (signed_block, None),
|
||||
SignedBeaconBlock::Deneb(_) => (signed_block, block_response.blob_items),
|
||||
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => {
|
||||
(signed_block, block_response.blob_items)
|
||||
}
|
||||
};
|
||||
|
||||
(block_contents, block_response.state)
|
||||
@@ -939,7 +949,9 @@ where
|
||||
| SignedBeaconBlock::Altair(_)
|
||||
| SignedBeaconBlock::Merge(_)
|
||||
| SignedBeaconBlock::Capella(_) => (signed_block, None),
|
||||
SignedBeaconBlock::Deneb(_) => (signed_block, block_response.blob_items),
|
||||
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => {
|
||||
(signed_block, block_response.blob_items)
|
||||
}
|
||||
};
|
||||
(block_contents, pre_state)
|
||||
}
|
||||
@@ -2497,48 +2509,73 @@ pub fn generate_rand_block_and_blobs<E: EthSpec>(
|
||||
let inner = map_fork_name!(fork_name, BeaconBlock, <_>::random_for_test(rng));
|
||||
let mut block = SignedBeaconBlock::from_block(inner, types::Signature::random_for_test(rng));
|
||||
let mut blob_sidecars = vec![];
|
||||
if let Ok(message) = block.message_deneb_mut() {
|
||||
// Get either zero blobs or a random number of blobs between 1 and Max Blobs.
|
||||
let payload: &mut FullPayloadDeneb<E> = &mut message.body.execution_payload;
|
||||
let num_blobs = match num_blobs {
|
||||
NumBlobs::Random => rng.gen_range(1..=E::max_blobs_per_block()),
|
||||
NumBlobs::None => 0,
|
||||
};
|
||||
let (bundle, transactions) =
|
||||
execution_layer::test_utils::generate_blobs::<E>(num_blobs).unwrap();
|
||||
|
||||
payload.execution_payload.transactions = <_>::default();
|
||||
for tx in Vec::from(transactions) {
|
||||
payload.execution_payload.transactions.push(tx).unwrap();
|
||||
let bundle = match block {
|
||||
SignedBeaconBlock::Deneb(SignedBeaconBlockDeneb {
|
||||
ref mut message, ..
|
||||
}) => {
|
||||
// Get either zero blobs or a random number of blobs between 1 and Max Blobs.
|
||||
let payload: &mut FullPayloadDeneb<E> = &mut message.body.execution_payload;
|
||||
let num_blobs = match num_blobs {
|
||||
NumBlobs::Random => rng.gen_range(1..=E::max_blobs_per_block()),
|
||||
NumBlobs::None => 0,
|
||||
};
|
||||
let (bundle, transactions) =
|
||||
execution_layer::test_utils::generate_blobs::<E>(num_blobs).unwrap();
|
||||
|
||||
payload.execution_payload.transactions = <_>::default();
|
||||
for tx in Vec::from(transactions) {
|
||||
payload.execution_payload.transactions.push(tx).unwrap();
|
||||
}
|
||||
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
||||
bundle
|
||||
}
|
||||
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
||||
SignedBeaconBlock::Electra(SignedBeaconBlockElectra {
|
||||
ref mut message, ..
|
||||
}) => {
|
||||
// Get either zero blobs or a random number of blobs between 1 and Max Blobs.
|
||||
let payload: &mut FullPayloadElectra<E> = &mut message.body.execution_payload;
|
||||
let num_blobs = match num_blobs {
|
||||
NumBlobs::Random => rng.gen_range(1..=E::max_blobs_per_block()),
|
||||
NumBlobs::None => 0,
|
||||
};
|
||||
let (bundle, transactions) =
|
||||
execution_layer::test_utils::generate_blobs::<E>(num_blobs).unwrap();
|
||||
|
||||
let eth2::types::BlobsBundle {
|
||||
commitments,
|
||||
proofs,
|
||||
blobs,
|
||||
} = bundle;
|
||||
|
||||
for (index, ((blob, kzg_commitment), kzg_proof)) in blobs
|
||||
.into_iter()
|
||||
.zip(commitments.into_iter())
|
||||
.zip(proofs.into_iter())
|
||||
.enumerate()
|
||||
{
|
||||
blob_sidecars.push(BlobSidecar {
|
||||
index: index as u64,
|
||||
blob: blob.clone(),
|
||||
kzg_commitment,
|
||||
kzg_proof,
|
||||
signed_block_header: block.signed_block_header(),
|
||||
kzg_commitment_inclusion_proof: block
|
||||
.message()
|
||||
.body()
|
||||
.kzg_commitment_merkle_proof(index)
|
||||
.unwrap(),
|
||||
});
|
||||
payload.execution_payload.transactions = <_>::default();
|
||||
for tx in Vec::from(transactions) {
|
||||
payload.execution_payload.transactions.push(tx).unwrap();
|
||||
}
|
||||
message.body.blob_kzg_commitments = bundle.commitments.clone();
|
||||
bundle
|
||||
}
|
||||
_ => return (block, blob_sidecars),
|
||||
};
|
||||
|
||||
let eth2::types::BlobsBundle {
|
||||
commitments,
|
||||
proofs,
|
||||
blobs,
|
||||
} = bundle;
|
||||
|
||||
for (index, ((blob, kzg_commitment), kzg_proof)) in blobs
|
||||
.into_iter()
|
||||
.zip(commitments.into_iter())
|
||||
.zip(proofs.into_iter())
|
||||
.enumerate()
|
||||
{
|
||||
blob_sidecars.push(BlobSidecar {
|
||||
index: index as u64,
|
||||
blob: blob.clone(),
|
||||
kzg_commitment,
|
||||
kzg_proof,
|
||||
signed_block_header: block.signed_block_header(),
|
||||
kzg_commitment_inclusion_proof: block
|
||||
.message()
|
||||
.body()
|
||||
.kzg_commitment_merkle_proof(index)
|
||||
.unwrap(),
|
||||
});
|
||||
}
|
||||
|
||||
(block, blob_sidecars)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user