feat: pass parent beacon block root to payload builder (#4425)

This commit is contained in:
Alessandro Mazza
2023-09-04 16:51:33 +02:00
committed by GitHub
parent b32562f4ea
commit d9334ee6cf
2 changed files with 8 additions and 2 deletions

View File

@ -129,6 +129,8 @@ pub struct PayloadBuilderAttributes {
pub prev_randao: H256,
/// Withdrawals for the generated payload
pub withdrawals: Vec<Withdrawal>,
/// Root of the parent beacon block
pub parent_beacon_block_root: Option<H256>,
}
// === impl PayloadBuilderAttributes ===
@ -146,6 +148,7 @@ impl PayloadBuilderAttributes {
suggested_fee_recipient: attributes.suggested_fee_recipient,
prev_randao: attributes.prev_randao,
withdrawals: attributes.withdrawals.unwrap_or_default(),
parent_beacon_block_root: attributes.parent_beacon_block_root,
}
}
@ -204,6 +207,9 @@ pub(crate) fn payload_id(parent: &H256, attributes: &PayloadAttributes) -> Paylo
withdrawals.encode(&mut buf);
hasher.update(buf);
}
if let Some(parent_beacon_block) = attributes.parent_beacon_block_root {
hasher.update(parent_beacon_block);
}
let out = hasher.finalize();
PayloadId::new(out.as_slice()[..8].try_into().expect("sufficient length"))
}