-
Notifications
You must be signed in to change notification settings - Fork 6
fix: building in zkvm guest #457
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,14 +2,18 @@ | |||||
|
|
||||||
| use std::io::Read; | ||||||
|
|
||||||
| use zstd::Decoder; | ||||||
| #[cfg(feature = "zstd")] | ||||||
| use ruzstd as _; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also curious about this?
don't get this, why don't put
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. they also uses other things provided by scroll-codec, so two options:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Does that mean that they don't actually need
Thegaram marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| /// The ZSTD magic number for zstd compressed data header. | ||||||
| const ZSTD_MAGIC_NUMBER: [u8; 4] = [0x28, 0xb5, 0x2f, 0xfd]; | ||||||
|
|
||||||
| /// Uncompress the provided data. | ||||||
| #[cfg(feature = "zstd")] | ||||||
| pub fn decompress_blob_data(data: &[u8]) -> Vec<u8> { | ||||||
| use zstd::Decoder; | ||||||
| let mut header_data = ZSTD_MAGIC_NUMBER.to_vec(); | ||||||
|
|
||||||
| header_data.extend_from_slice(data); | ||||||
|
|
||||||
| // init decoder and owned output data. | ||||||
|
|
@@ -31,3 +35,20 @@ pub fn decompress_blob_data(data: &[u8]) -> Vec<u8> { | |||||
|
|
||||||
| output | ||||||
| } | ||||||
|
|
||||||
| /// Uncompress the provided data. | ||||||
| #[cfg(not(feature = "zstd"))] | ||||||
| pub fn decompress_blob_data(data: &[u8]) -> Vec<u8> { | ||||||
| use ruzstd::decoding::StreamingDecoder; | ||||||
|
|
||||||
| let mut header_data = ZSTD_MAGIC_NUMBER.to_vec(); | ||||||
| header_data.extend_from_slice(data); | ||||||
|
|
||||||
| // init decoder and owned output data. | ||||||
| let mut decoder = StreamingDecoder::new(header_data.as_slice()).unwrap(); | ||||||
| // heuristic: use data length as the allocated output capacity. | ||||||
| let mut output = Vec::with_capacity(header_data.len()); | ||||||
| decoder.read_to_end(&mut output).unwrap(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why it's safe to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, but previous zstd call also
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. returning
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this function is only used inside
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine to update the API. |
||||||
|
|
||||||
| output | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.