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

add no-std #25

Merged
merged 46 commits into from
Jan 23, 2023
Merged

add no-std #25

merged 46 commits into from
Jan 23, 2023

Conversation

claravanstaden
Copy link
Contributor

@ralexstokes
Copy link
Owner

it looks like some of the changes in here were done in #29; please rebase main when you get a chance -- very excited to dig into this PR :)

Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

this is amazing! nice work :)

I left some questions/comments on an initial pass

At a high-level, I think this direction makes sense -- the only thing I'd suggest is to take inspiration from the serde library which also supports std vs no-std in this way but they have a central lib that does the import logic once and then can simply use lib::*; everywhere else

see here: https://github.com/serde-rs/serde/blob/master/serde/src/lib.rs#L151

and here for usage: https://github.com/serde-rs/serde/blob/master/serde/src/ser/mod.rs#L110

I'll want to make another pass to look more deeply into the thiserror issue and also investigate some of the dependency changes but I like the direction this is going in and think no-std is a great addition to this library

ssz-rs/Cargo.toml Outdated Show resolved Hide resolved
ssz-rs/Cargo.toml Outdated Show resolved Hide resolved
ssz-rs/src/lib.rs Outdated Show resolved Hide resolved
ssz-rs/src/std.rs Outdated Show resolved Hide resolved
ssz-rs/src/uint.rs Outdated Show resolved Hide resolved
@claravanstaden
Copy link
Contributor Author

@ralexstokes thanks for the review! I have made the requested individual changes as well as the std lib imports as modelled by the serde crate in f29b3fe. Let me know if this is what you've had in mind. I can also move the crate std mod into lib, if you prefer (but I guess then the import would just be crate::*, which is less clear)? Or rename it something else. 😄

@claravanstaden claravanstaden marked this pull request as ready for review November 23, 2022 12:33
Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

nice updates!

things are looking good, I left a few questions

.github/workflows/rust.yml Outdated Show resolved Hide resolved
ssz-rs/examples/another_container.rs Outdated Show resolved Hide resolved
ssz-rs/src/bitlist.rs Outdated Show resolved Hide resolved
ssz-rs/src/bitvector.rs Outdated Show resolved Hide resolved
ssz-rs/src/lib.rs Outdated Show resolved Hide resolved
ssz-rs/src/lib.rs Show resolved Hide resolved
ssz-rs/src/uint.rs Outdated Show resolved Hide resolved
@ralexstokes
Copy link
Owner

Or rename it something else.

I like how serde does it and just calls it lib

can you update the mod name and then the imports so that it is crate::lib::* etc? thank you!

@ralexstokes
Copy link
Owner

also the fact that the tests are passing even though we are 'ignoring' some errors suggests the code coverage is not ideal -- I'll leave a note here to investigate further

ssz-rs/src/lib.rs Outdated Show resolved Hide resolved
@claravanstaden
Copy link
Contributor Author

I like how serde does it and just calls it lib

can you update the mod name and then the imports so that it is crate::lib::* etc? thank you!

Done in d776326. I removed the std mod and created a lib mod in lib.rs, since lib.rs exists already.

@claravanstaden
Copy link
Contributor Author

also the fact that the tests are passing even though we are 'ignoring' some errors suggests the code coverage is not ideal -- I'll leave a note here to investigate further

This is a little worrying. The dropped error check I introduced was in pack_bytes, used by hash_tree_root, which the individual mod tests don't cover. But it is still concerning that the container tests didn't pick them up.

I had a quick look but must admit I couldn't quickly see how to add test cases that would trigger those error conditions.

@dharjeezy
Copy link

Is this still being worked on? Is there any way i can contribute to this?

@claravanstaden
Copy link
Contributor Author

Is this still being worked on? Is there any way i can contribute to this?

@dharjeezy it's ready for review! @ralexstokes will probably get to it as soon as he can. 😄 You are welcome to also review and test if you are keen.

Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

a few comments to resolve, but I think we are only a round or two of back/forth before we can merge :)

.github/workflows/rust.yml Outdated Show resolved Hide resolved
ssz-rs/src/bitlist.rs Outdated Show resolved Hide resolved
ssz-rs/src/bitvector.rs Outdated Show resolved Hide resolved
ssz-rs/src/list.rs Outdated Show resolved Hide resolved
ssz-rs/src/merkleization/mod.rs Outdated Show resolved Hide resolved
ssz-rs/src/ser.rs Outdated Show resolved Hide resolved
@claravanstaden
Copy link
Contributor Author

@ralexstokes thanks for the review! 😄 Comments actioned.

Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

reviewed the Cargo manifest and I think we can tighten it up some

I'd like to get to a point where the default thing is the status quo and only if you do --no-default-features will you get a no_std compatible library

ssz-rs/Cargo.toml Outdated Show resolved Hide resolved
ssz-rs/Cargo.toml Outdated Show resolved Hide resolved
ssz-rs/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Owner

@ralexstokes ralexstokes left a comment

Choose a reason for hiding this comment

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

another round of questions/comments :)

ssz-rs/examples/container_with_some_types.rs Outdated Show resolved Hide resolved
ssz-rs/src/de.rs Outdated Show resolved Hide resolved
ssz-rs/src/de.rs Outdated Show resolved Hide resolved
ssz-rs/src/de.rs Outdated Show resolved Hide resolved
ssz-rs/src/lib.rs Show resolved Hide resolved
ssz-rs/src/merkleization/mod.rs Outdated Show resolved Hide resolved
ssz-rs/src/merkleization/mod.rs Outdated Show resolved Hide resolved
ssz-rs/src/ser.rs Outdated Show resolved Hide resolved
ssz-rs/src/ser.rs Outdated Show resolved Hide resolved
ssz-rs/src/vector.rs Outdated Show resolved Hide resolved
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.

5 participants