Skip to content

Commit 0697db6

Browse files
mskrzypkowsCopilot
andauthored
Update shasta/src/l2/tools.rs
Co-authored-by: Copilot <[email protected]>
1 parent 276eaef commit 0697db6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shasta/src/l2/tools.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ pub fn encode_extra_data(basefee_sharing_pctg: u8, proposal_id: u64) -> Bytes {
1010
Bytes::from(data.to_vec())
1111
}
1212

13+
/// Decode the extra data field of a Shasta block header.
14+
///
15+
/// The expected format of `extra_data` is exactly 7 bytes:
16+
/// - byte 0: `basefee_sharing_pctg` (the base fee sharing percentage)
17+
/// - bytes 1..7: the most significant 6 bytes of the big-endian `proposal_id`
18+
///
19+
/// On success, returns a tuple `(basefee_sharing_pctg, proposal_id)`.
20+
/// Returns an error if `extra_data` is not exactly 7 bytes long.
1321
pub fn decode_extra_data(extra_data: &[u8]) -> Result<(u8, u64), Error> {
1422
if extra_data.len() != 7 {
1523
return Err(anyhow::anyhow!(

0 commit comments

Comments
 (0)