Skip to content

Commit

Permalink
block v3 flow
Browse files Browse the repository at this point in the history
  • Loading branch information
eserilev committed Aug 14, 2023
1 parent cd36be5 commit 6515ce4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
pub enum BeaconBlockAndStateResponse<T: EthSpec> {
Full((BeaconBlock<T, FullPayload<T>>, BeaconState<T>)),
Blinded((BeaconBlock<T, BlindedPayload<T>>, BeaconState<T>)),
BeaconBlockError()
BeaconBlockError(),
}

type BeaconBlockAndState<T, Payload> = (BeaconBlock<T, Payload>, BeaconState<T>);
Expand Down Expand Up @@ -4347,7 +4347,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
//
// Perform the final steps of combining all the parts and computing the state root.
let chain = self.clone();
let result = self.task_executor
let result = self
.task_executor
.spawn_blocking_handle(
move || {
chain.complete_partial_beacon_block(
Expand All @@ -4362,14 +4363,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.await
.map_err(BlockProductionError::TokioJoin)?;

return Ok(BeaconBlockAndStateResponse::Full(result?))
return Ok(BeaconBlockAndStateResponse::Full(result?));
}
execution_layer::BlockProposalContentsType::Blinded(block_contents) => {
// Part 3/3 (blocking)
//
// Perform the final steps of combining all the parts and computing the state root.
let chain = self.clone();
let result = self.task_executor
let chain = self.clone();
let result = self
.task_executor
.spawn_blocking_handle(
move || {
chain.complete_partial_beacon_block(
Expand All @@ -4384,7 +4386,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.await
.map_err(BlockProductionError::TokioJoin)?;

return Ok(BeaconBlockAndStateResponse::Blinded(result?))
return Ok(BeaconBlockAndStateResponse::Blinded(result?));
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub enum BlockProductionError {
TokioJoin(tokio::task::JoinError),
BeaconChain(BeaconChainError),
InvalidPayloadFork,
FailedToFetchBlock
FailedToFetchBlock,
}

easy_from_to!(BlockProcessingError, BlockProductionError);
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
&metrics::EXECUTION_LAYER_GET_PAYLOAD_SOURCE,
&[metrics::LOCAL],
);
return Ok(BlockProposalContentsType::Full(block_proposal_contents));
Ok(BlockProposalContentsType::Full(block_proposal_contents))
}
BlockProposalContentsType::Blinded(block_proposal_contents) => {
metrics::inc_counter_vec(
Expand All @@ -699,7 +699,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
&metrics::EXECUTION_LAYER_GET_PAYLOAD_SOURCE,
&[metrics::BUILDER],
);
return Ok(BlockProposalContentsType::Blinded(block_proposal_contents));
Ok(BlockProposalContentsType::Blinded(block_proposal_contents))
}
}
}
Expand Down

0 comments on commit 6515ce4

Please sign in to comment.