Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Fix byte ordering in encoding of aggregation guest state (#410) #411

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/aggregation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ impl MerkleMountainRange {
bitmap.set_bit(peak.max_depth as usize, true);
peaks.push(peak.digest);
}
[&bitmap.as_le_bytes(), bytemuck::cast_slice(&peaks)].concat()
[
&bitmap.to_be_bytes::<{ U256::BYTES }>(),
bytemuck::cast_slice(&peaks),
]
.concat()
}

/// Decode the specialized journal encoding. See [MerkleMountainRange::encode].
Expand All @@ -316,7 +320,7 @@ impl MerkleMountainRange {
.as_ref()
.split_at_checked(U256::BYTES)
.ok_or(DecodingError::UnexpectedEnd)?;
let bitmap = U256::from_le_slice(chunk);
let bitmap = U256::from_be_slice(chunk);
if bitmap > (uint!(1_U256 << u8::MAX)) {
// When the leading bit is set, it must be finalized. Any value above 2^255 is invalid.
return Err(DecodingError::InvalidBitmap);
Expand Down
Loading