mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
* 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
44 lines
1.6 KiB
Rust
44 lines
1.6 KiB
Rust
use beacon_chain::{BeaconBlockResponse, BeaconBlockResponseWrapper, BlockProductionError};
|
|
use eth2::types::{BlockContents, FullBlockContents, ProduceBlockV3Response};
|
|
use types::{EthSpec, ForkName};
|
|
type Error = warp::reject::Rejection;
|
|
|
|
pub fn build_block_contents<E: EthSpec>(
|
|
fork_name: ForkName,
|
|
block_response: BeaconBlockResponseWrapper<E>,
|
|
) -> Result<ProduceBlockV3Response<E>, Error> {
|
|
match block_response {
|
|
BeaconBlockResponseWrapper::Blinded(block) => {
|
|
Ok(ProduceBlockV3Response::Blinded(block.block))
|
|
}
|
|
BeaconBlockResponseWrapper::Full(block) => match fork_name {
|
|
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => Ok(
|
|
ProduceBlockV3Response::Full(FullBlockContents::Block(block.block)),
|
|
),
|
|
ForkName::Deneb | ForkName::Electra => {
|
|
let BeaconBlockResponse {
|
|
block,
|
|
state: _,
|
|
blob_items,
|
|
execution_payload_value: _,
|
|
consensus_block_value: _,
|
|
} = block;
|
|
|
|
let Some((kzg_proofs, blobs)) = blob_items else {
|
|
return Err(warp_utils::reject::block_production_error(
|
|
BlockProductionError::MissingBlobs,
|
|
));
|
|
};
|
|
|
|
Ok(ProduceBlockV3Response::Full(
|
|
FullBlockContents::BlockContents(BlockContents {
|
|
block,
|
|
kzg_proofs,
|
|
blobs,
|
|
}),
|
|
))
|
|
}
|
|
},
|
|
}
|
|
}
|