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

refactor: No Std support in zeth-lib & primitives #83

Closed
wants to merge 28 commits into from

Conversation

CeciliaZ030
Copy link

@CeciliaZ030 CeciliaZ030 commented Jan 25, 2024

This PR stipped off std from Zeth's lib and primitives packages which builds a block. The purpose is to allow Zeth to run on other ZkVMs which mostly requires no_std.

  • add #![cfg_attr(not(feature = "std"), no_std)] in lib & primitives with default feature containing std
  • move the lib/host module to host/src/util which means all RPC and file-caching utilities are with the host
  • only dependency that doesn't support no_std is thiserror, hence replaced with thiserror-no-std, which requires some work arounds since we lost the blanket impl from std::error::Error

The core component revm now is also no_std with bluealloy/revm#987

checksum

fmt & clippy

fix util import

 #![feature(build_hasher_simple_hash_one)]

clear comments

fmt
@CeciliaZ030
Copy link
Author

Hi @Wollac 😊 would appreciate if you take a look and consider merging it.
no-std is important for cross-platform support. Although Risc0 can do std, stripping off IO from lib makes the block builder cleaner.

@Wollac
Copy link
Contributor

Wollac commented Jan 31, 2024

I think you are right that thiserror and std::io are the only real std requirements we have:

  • thiserror-no-std doesn't seem to be the solution, as that crate doesn't seem to be well maintained and doesn't even have a readme. Probably implementing the errors without derive (i.e. implementing display and some from) is the much better solution.
  • core2 is in even worse shape, so getting rid of all io would be required.
  • Mapping errors just to be able to use context is useless, and they should be mapped directly into an anyhow.

stripping off IO from lib makes the block builder cleaner.

I am not sure I understand what you are saying.

In general, I have to admit that I am very skeptical about going no-std. std simplifies certain things significantly and has no real drawbacks on the R0 zkVM. I do believe that eventually other zkVMs will (have to) add std support.

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