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: partial wasm32-wasi compilation #9430

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 0 additions & 33 deletions .github/assets/check_no_std.sh

This file was deleted.

32 changes: 32 additions & 0 deletions .github/assets/check_wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -eo pipefail

wasm_packages=(
reth-codecs
reth-consensus
reth-db
reth-db-api
reth-ethereum-forks
reth-evm
reth-evm-ethereum
reth-network-peers
reth-primitives
reth-primitives-traits
reth-revm
)

for package in "${wasm_packages[@]}"; do
cmd="cargo +stable build -p $package --target wasm32-wasi --no-default-features --ignore-rust-version --features std"

if [ -n "$CI" ]; then
echo "::group::$cmd1 || $cmd2"
else
printf "\n%s:\n %s\n" "$package" "$cmd"
fi

$cmd

if [ -n "$CI" ]; then
echo "::endgroup::"
fi
done
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
env:
RUSTFLAGS: -D warnings

no-std:
wasm:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand All @@ -57,7 +57,7 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Run no_std checks
- name: Run wasm checks
run: .github/assets/check_no_std.sh

crate-checks:
Expand Down
74 changes: 62 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions Cargo.toml
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you submit this separately?

Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ reth-evm = { path = "crates/evm" }
reth-evm-ethereum = { path = "crates/ethereum/evm" }
reth-evm-optimism = { path = "crates/optimism/evm" }
reth-execution-errors = { path = "crates/evm/execution-errors" }
reth-execution-types = { path = "crates/evm/execution-types" }
reth-execution-types = { path = "crates/evm/execution-types", default-features = false }
reth-exex = { path = "crates/exex/exex" }
reth-exex-test-utils = { path = "crates/exex/test-utils" }
reth-exex-types = { path = "crates/exex/types" }
Expand All @@ -326,7 +326,7 @@ reth-network-api = { path = "crates/net/network-api" }
reth-network-types = { path = "crates/net/network-types" }
reth-network-peers = { path = "crates/net/peers", default-features = false }
reth-network-p2p = { path = "crates/net/p2p" }
reth-nippy-jar = { path = "crates/storage/nippy-jar" }
reth-nippy-jar = { path = "crates/storage/nippy-jar", default-features = false }
reth-node-api = { path = "crates/node/api" }
reth-node-builder = { path = "crates/node/builder" }
reth-node-core = { path = "crates/node/core" }
Expand All @@ -341,12 +341,12 @@ reth-optimism-rpc = { path = "crates/optimism/rpc" }
reth-payload-builder = { path = "crates/payload/builder" }
reth-payload-primitives = { path = "crates/payload/primitives" }
reth-payload-validator = { path = "crates/payload/validator" }
reth-primitives = { path = "crates/primitives" }
reth-primitives = { path = "crates/primitives", default-features = false }
reth-primitives-traits = { path = "crates/primitives-traits" }
reth-provider = { path = "crates/storage/provider" }
reth-prune = { path = "crates/prune/prune" }
reth-prune-types = { path = "crates/prune/types" }
reth-revm = { path = "crates/revm" }
reth-revm = { path = "crates/revm", default-features = false }
reth-rpc = { path = "crates/rpc/rpc" }
reth-rpc-api = { path = "crates/rpc/rpc-api" }
reth-rpc-api-testing-util = { path = "crates/rpc/rpc-testing-util" }
Expand All @@ -363,27 +363,26 @@ reth-stages-api = { path = "crates/stages/api" }
reth-stages-types = { path = "crates/stages/types" }
reth-static-file = { path = "crates/static-file/static-file" }
reth-static-file-types = { path = "crates/static-file/types" }
reth-storage-api = { path = "crates/storage/storage-api" }
reth-storage-api = { path = "crates/storage/storage-api", default-features = false }
reth-storage-errors = { path = "crates/storage/errors" }
reth-tasks = { path = "crates/tasks" }
reth-testing-utils = { path = "testing/testing-utils" }
reth-tokio-util = { path = "crates/tokio-util" }
reth-tracing = { path = "crates/tracing" }
reth-transaction-pool = { path = "crates/transaction-pool" }
reth-trie = { path = "crates/trie/trie" }
reth-trie = { path = "crates/trie/trie", default-features = false }
reth-trie-common = { path = "crates/trie/common" }
reth-trie-parallel = { path = "crates/trie/parallel" }

# revm
revm = { version = "11.0.0", features = [
Copy link
Author

Choose a reason for hiding this comment

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

TODO: Update once bluealloy/revm#1601 merged into revm and revm-inspectors is also updated.

revm = { path = "../bluealloy-revm/crates/revm", features = [
"std",
"secp256k1",
"blst",
"kzg-rs",
], default-features = false }
revm-primitives = { version = "6.0.0", features = [
"std",
revm-primitives = { path = "../bluealloy-revm/crates/primitives", features = [
"std"
], default-features = false }
revm-inspectors = "0.4"
revm-inspectors = { path = "../revm-inspectors" }

# eth
alloy-chains = "0.1.15"
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ thiserror-no-std = {workspace = true, default-features = false }

[features]
default = ["std"]
std = ["thiserror-no-std/std"]
std = ["thiserror-no-std/std", "reth-primitives/std"]
test-utils = []
4 changes: 4 additions & 0 deletions crates/errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ reth-storage-errors.workspace = true

# misc
thiserror.workspace = true

[features]
default = ["std"]
std = []
2 changes: 1 addition & 1 deletion crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ serde_json.workspace = true

[features]
default = ["std"]
std = []
std = ["reth-revm/std"]
2 changes: 2 additions & 0 deletions crates/net/peers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ serde_json.workspace = true
tokio = { workspace = true, features = ["net", "macros", "rt"] }

[features]
default = ["std"]
std = []
secp256k1 = ["dep:secp256k1", "enr/secp256k1"]
net = ["dep:tokio", "tokio?/net"]
5 changes: 4 additions & 1 deletion crates/primitives-traits/src/constants/gas_units.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::time::Duration;
#[cfg(not(feature = "std"))]
use alloc::{format, string::String};

use core::time::Duration;

/// Represents one Kilogas, or `1_000` gas.
pub const KILOGAS: u64 = 1_000;
Expand Down
3 changes: 3 additions & 0 deletions crates/primitives-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate alloc;

#[cfg(feature = "alloy-compat")]
mod alloy_compat;

Expand Down
Loading