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

feat: incorporate noosphere_car enhancements #6

Merged
merged 7 commits into from
Jun 29, 2023
Merged

Conversation

b5
Copy link
Member

@b5 b5 commented Jun 27, 2023

Pulls in streaming support & WASM from noosphere-car

@dignifiedquire, this also incorporates the crate updates from #5. Adds a WASM test suite based on noosphere CI

@b5 b5 self-assigned this Jun 27, 2023
@b5 b5 requested a review from dignifiedquire June 27, 2023 13:53
@@ -1,4 +1,3 @@
/target
/iroh_gateway/test_files/*
.env
Cargo.lock
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding Cargo.lock b/c the WASM CI job depends on this file existing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems odd, we can just generate it in CI

Cargo.toml Show resolved Hide resolved
src/error.rs Outdated Show resolved Hide resolved
src/reader.rs Outdated Show resolved Hide resolved
src/varint.rs Outdated
@@ -0,0 +1,89 @@
//! This module has been adapted from the [integer_encoding] crate. The
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try asking them to entirely remove the Send bound? I don't think it is needed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: Send bound not required. I think we had added the conditional bound to avoid removing this one in the upstream implementation but I'm not sure.

Copy link
Collaborator

@cdata cdata Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yah, I think the integer-encoding crate enforces a Send bound that can't be met under Wasm. That's why we forked this module.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try asking them

If by "them" you mean integer-encoding maintainers, then: no! We didn't try. We should. Someone should do that. It would be the right thing to do....

😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yah, I think the integer-encoding crate enforces a Send bound that can't be met under Wasm. That's why we forked this module.

Yeah that's likely because of async_traits Send requirements by default. But using https://docs.rs/async-trait/latest/async_trait/#non-threadsafe-futures it should be possible to avoid that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does a git branch ref prevent us from publishing an updated version of this crate?

It does. It is currently unclear if integer-encoding is still maintained unfortunately. @flub you reviewed various varint implementations, any suggestions to what we could switch?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly compared to a multiformat's varint with a dead simple re-implementation of QUIC's varint format (which was faster). Sadly I don't think any crate tidily exports QUIC's varint but it's super simple to write by hand: https://github.com/n0-computer/varint-bench/blob/main/src/lib.rs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well we need to use the speced format, which I believe is the one from multiformats unfortunately.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humble suggestion: you can file an issue to address this in the future and commit the change as-is. In the mean time if there are any problems with it, you can always throw your hands up and rightly claim it was my choice to partially fork integer-encoding.

Alternatively: you can publish your patched crate and use that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaalright, found a much cleaner version, we now use unsigned-varint which is the same dependency that multihash and friends already use.

#[cfg(target_arch = "wasm32")]
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);

const TEST_V1_CAR: &[u8] = include_bytes!("testv1.car");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment why these are using include_bytes instead of reading from disk at runtime

@b5
Copy link
Member Author

b5 commented Jun 28, 2023

drops integer-encoding, avoiding the dep and using the same dep that multihash already uses
@b5
Copy link
Member Author

b5 commented Jun 28, 2023

@cdata, what do you think, are you willing to approve this? I want to make sure this still fits @subconsciousnetwork's needs, and if so we can cut a release & set to work on making sure the @banyancomputer team's needs are met

@dignifiedquire dignifiedquire merged commit c30b163 into main Jun 29, 2023
@dignifiedquire dignifiedquire deleted the noosphere-car branch June 29, 2023 16:30
@dignifiedquire
Copy link
Contributor

I just released this as [email protected]. If there is sth that needs changing, we can just make a new version :)

Copy link
Collaborator

@cdata cdata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants