perf(OpBuiltPayload): Arc SealedBlock (#12361)

This commit is contained in:
Hai | RISE
2024-11-07 17:51:05 +07:00
committed by GitHub
parent d31e1d601d
commit 037dffeb15
2 changed files with 12 additions and 9 deletions

View File

@ -356,12 +356,12 @@ where
},
};
let sealed_block = block.seal_slow();
let sealed_block = Arc::new(block.seal_slow());
debug!(target: "payload_builder", ?sealed_block, "sealed built block");
// create the executed block data
let executed = ExecutedBlock {
block: Arc::new(sealed_block.clone()),
block: sealed_block.clone(),
senders: Arc::new(info.executed_senders),
execution_output: Arc::new(execution_outcome),
hashed_state: Arc::new(hashed_state),

View File

@ -135,7 +135,7 @@ pub struct OpBuiltPayload {
/// Identifier of the payload
pub(crate) id: PayloadId,
/// The built block
pub(crate) block: SealedBlock,
pub(crate) block: Arc<SealedBlock>,
/// Block execution data for the payload, if any.
pub(crate) executed_block: Option<ExecutedBlock>,
/// The fees of the block
@ -155,7 +155,7 @@ impl OpBuiltPayload {
/// Initializes the payload with the given initial block.
pub const fn new(
id: PayloadId,
block: SealedBlock,
block: Arc<SealedBlock>,
fees: U256,
chain_spec: Arc<OpChainSpec>,
attributes: OpPayloadBuilderAttributes,
@ -170,7 +170,7 @@ impl OpBuiltPayload {
}
/// Returns the built block(sealed)
pub const fn block(&self) -> &SealedBlock {
pub fn block(&self) -> &SealedBlock {
&self.block
}
@ -224,7 +224,7 @@ impl BuiltPayload for &OpBuiltPayload {
// V1 engine_getPayloadV1 response
impl From<OpBuiltPayload> for ExecutionPayloadV1 {
fn from(value: OpBuiltPayload) -> Self {
block_to_payload_v1(value.block)
block_to_payload_v1(Arc::unwrap_or_clone(value.block))
}
}
@ -233,7 +233,10 @@ impl From<OpBuiltPayload> for ExecutionPayloadEnvelopeV2 {
fn from(value: OpBuiltPayload) -> Self {
let OpBuiltPayload { block, fees, .. } = value;
Self { block_value: fees, execution_payload: convert_block_to_payload_field_v2(block) }
Self {
block_value: fees,
execution_payload: convert_block_to_payload_field_v2(Arc::unwrap_or_clone(block)),
}
}
}
@ -248,7 +251,7 @@ impl From<OpBuiltPayload> for OpExecutionPayloadEnvelopeV3 {
B256::ZERO
};
Self {
execution_payload: block_to_payload_v3(block),
execution_payload: block_to_payload_v3(Arc::unwrap_or_clone(block)),
block_value: fees,
// From the engine API spec:
//
@ -275,7 +278,7 @@ impl From<OpBuiltPayload> for OpExecutionPayloadEnvelopeV4 {
B256::ZERO
};
Self {
execution_payload: block_to_payload_v3(block),
execution_payload: block_to_payload_v3(Arc::unwrap_or_clone(block)),
block_value: fees,
// From the engine API spec:
//