feat(builder): ethereum builder config (#13315)

This commit is contained in:
Roman Krasiuk
2024-12-11 22:26:25 +01:00
committed by GitHub
parent 3d12a4eafa
commit c553b1e86d
14 changed files with 120 additions and 69 deletions

View File

@ -163,11 +163,7 @@ where
.ok_or_else(|| PayloadBuilderError::MissingParentHeader(attributes.parent()))?
};
let config = PayloadConfig::new(
Arc::new(parent_header.clone()),
self.config.extradata.clone(),
attributes,
);
let config = PayloadConfig::new(Arc::new(parent_header.clone()), attributes);
let until = self.job_deadline(config.attributes.timestamp());
let deadline = Box::pin(tokio::time::sleep_until(until));
@ -713,30 +709,17 @@ impl Drop for Cancelled {
pub struct PayloadConfig<Attributes> {
/// The parent header.
pub parent_header: Arc<SealedHeader>,
/// Block extra data.
pub extra_data: Bytes,
/// Requested attributes for the payload.
pub attributes: Attributes,
}
impl<Attributes> PayloadConfig<Attributes> {
/// Returns an owned instance of the [`PayloadConfig`]'s `extra_data` bytes.
pub fn extra_data(&self) -> Bytes {
self.extra_data.clone()
}
}
impl<Attributes> PayloadConfig<Attributes>
where
Attributes: PayloadBuilderAttributes,
{
/// Create new payload config.
pub const fn new(
parent_header: Arc<SealedHeader>,
extra_data: Bytes,
attributes: Attributes,
) -> Self {
Self { parent_header, extra_data, attributes }
pub const fn new(parent_header: Arc<SealedHeader>, attributes: Attributes) -> Self {
Self { parent_header, attributes }
}
/// Returns the payload id.

View File

@ -204,7 +204,6 @@ where
cached_reads: args.cached_reads.clone(),
config: PayloadConfig {
parent_header: args.config.parent_header.clone(),
extra_data: args.config.extra_data.clone(),
attributes: left_attr.clone(),
},
cancel: args.cancel.clone(),
@ -226,7 +225,6 @@ where
cached_reads: args.cached_reads.clone(),
config: PayloadConfig {
parent_header: args.config.parent_header.clone(),
extra_data: args.config.extra_data.clone(),
attributes: right_attr.clone(),
},
cancel: args.cancel.clone(),
@ -252,16 +250,14 @@ where
match config.attributes {
Either::Left(left_attr) => {
let left_config = PayloadConfig {
attributes: left_attr,
parent_header: config.parent_header.clone(),
extra_data: config.extra_data.clone(),
attributes: left_attr,
};
self.left.build_empty_payload(client, left_config).map(Either::Left)
}
Either::Right(right_attr) => {
let right_config = PayloadConfig {
parent_header: config.parent_header.clone(),
extra_data: config.extra_data.clone(),
attributes: right_attr,
};
self.right.build_empty_payload(client, right_config).map(Either::Right)