Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Fix wasm & nowasm builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Dec 18, 2023
1 parent 54109e0 commit c6c7926
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 65 deletions.
8 changes: 0 additions & 8 deletions .cargo/config

This file was deleted.

94 changes: 88 additions & 6 deletions Cargo.lock

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

77 changes: 51 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
# anvil
anvil = { git = "https://github.com/foundry-rs/foundry.git", package = "anvil", features = [ "default" ], rev = "dea5405", optional = true }
anvil-core = { git = "https://github.com/foundry-rs/foundry.git", package = "anvil-core", features = [ "default" ], rev = "dea5405", optional = true }
anvil = { git = "https://github.com/foundry-rs/foundry.git", package = "anvil", rev = "dea5405", optional = true }
anvil-core = { git = "https://github.com/foundry-rs/foundry.git", package = "anvil-core", rev = "dea5405", optional = true }
ethers = { git = "https://github.com/gakonst/ethers-rs", optional = true }
partial-mpt = { git = "https://github.com/zemse/partial-mpt", branch = "main", optional = true }

# zkevm
bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits", branch = "main", optional = true }
bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits", branch = "main", default-features = false, optional = true }
eth-types = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits", branch = "main", optional = true }
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits", branch = "main", optional = true }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_04_20", optional = true }
snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark-verifier.git", rev = "a440ff91", optional = true }
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits", branch = "main", default-features = false, optional = true }
halo2_proofs = { git = "https://github.com/privacy-scaling-explorations/halo2.git", tag = "v2023_04_20" }
snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark-verifier.git", rev = "a440ff91", optional = true }
ethers-core = { version = "2.0.7", optional = true }
itertools = { version = "0.10", optional = true }
rand_chacha = { version = "0.3", optional = true }
Expand Down Expand Up @@ -54,28 +54,53 @@ console_error_panic_hook = { version = "0.1.7", optional = true }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.2", features = ["js"], optional = true }

# [patch."https://github.com/privacy-scaling-explorations/zkevm-circuits"]
# bus-mapping = { git = "https://github.com/zemse/zkevm-circuits", rev = "fb284230", features = [ "wasm" ], optional = true }
# eth-types = { git = "https://github.com/zemse/zkevm-circuits", rev = "fb284230", optional = true }
# zkevm-circuits = { git = "https://github.com/zemse/zkevm-circuits", rev = "fb284230", optional = true }
[patch."https://github.com/privacy-scaling-explorations/zkevm-circuits"]
bus-mapping = { git = "https://github.com/zemse/zkevm-circuits", rev = "16507249", default-features = false, optional = true }
eth-types = { git = "https://github.com/zemse/zkevm-circuits", rev = "16507249", optional = true }
zkevm-circuits = { git = "https://github.com/zemse/zkevm-circuits", rev = "16507249", default-features = false, optional = true }

# for local development only
[patch."https://github.com/privacy-scaling-explorations/zkevm-circuits"]
bus-mapping = { path = "../zkevm-circuits/bus-mapping", features = [ "wasm" ], optional = true }
eth-types = { path = "../zkevm-circuits/eth-types", optional = true }
zkevm-circuits = { path = "../zkevm-circuits/zkevm-circuits", optional = true }
# [patch."https://github.com/privacy-scaling-explorations/zkevm-circuits"]
# bus-mapping = { path = "../zkevm-circuits/bus-mapping", default-features = false, optional = true }
# eth-types = { path = "../zkevm-circuits/eth-types", optional = true }
# zkevm-circuits = { path = "../zkevm-circuits/zkevm-circuits", default-features = false }

[features]
default = ["dep_wasm"]
dep_binary = ["dep_mainnet_fork", "dep_zkevm", "dep_misc"]
dep_mainnet_fork = ["anvil", "anvil-core", "ethers", "partial-mpt"]
dep_zkevm = ["bus-mapping", "eth-types", "zkevm-circuits", "halo2_proofs", "snark-verifier", "ethers-core", "itertools", "rand_chacha"]
dep_misc = ["tokio", "futures", "dotenv", "clap", "serde", "serde_json", "regex", "reqwest", "pinata-sdk", "svm-rs", "semver", "home"]
dep_wasm = [
"halo2_proofs", "zkevm-circuits",
default = ["nowasm"]
nowasm = [
"bus-mapping/nowasm",
"zkevm-circuits/nowasm",
"anvil",
"anvil-core",
"ethers",
"partial-mpt",
"eth-types",
"snark-verifier",
"ethers-core",
"itertools",
"rand_chacha",
"tokio",
"futures",
"dotenv",
"clap",
"serde",
"serde_json",
"regex",
"reqwest",
"pinata-sdk",
"svm-rs",
"semver",
"home",
]
wasm = [
"zkevm-circuits/wasm",
"bus-mapping/wasm",
"getrandom",
"wasm-bindgen",
"console_error_panic_hook",
"rayon", "wasm-bindgen-rayon", "web-sys", "wasm-bindgen-futures",
"js-sys"
]
"wasm-bindgen",
"console_error_panic_hook",
"rayon",
"wasm-bindgen-rayon",
"web-sys",
"wasm-bindgen-futures",
"js-sys",
]
16 changes: 0 additions & 16 deletions build_wasm.sh

This file was deleted.

25 changes: 16 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
#![feature(let_chains)]
#![feature(slice_pattern)]

#[cfg(not(feature = "dep_wasm"))]
#[cfg(all(feature = "wasm", feature = "nowasm"))]
compile_error!(
"proof-of-exploit: both wasm & nowasm are enabled, just one of them must be enabled"
);
#[cfg(all(not(feature = "wasm"), not(feature = "nowasm")))]
compile_error!("proof-of-exploit: none of wasm & nowasm are enabled, one of them must be enabled");

#[cfg(not(feature = "wasm"))]
pub mod cli;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod constants;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod env;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod error;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod utils;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod verification;
#[cfg(not(feature = "dep_wasm"))]
#[cfg(not(feature = "wasm"))]
pub mod witness;

#[cfg(feature = "dep_wasm")]
#[cfg(feature = "wasm")]
pub mod wasm;
#[cfg(feature = "dep_wasm")]
#[cfg(feature = "wasm")]
pub use wasm::*;
9 changes: 9 additions & 0 deletions wasm_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' wasm-pack build --target web --no-default-features --features wasm -Z build-std=panic_abort,std

du -h pkg/proof_of_exploit_bg.wasm

rm -rf /Users/sohamzemse/Workspace/opensource/personal/proof-of-exploit-stuff/frontend/pox-frontend/wasm
mkdir /Users/sohamzemse/Workspace/opensource/personal/proof-of-exploit-stuff/frontend/pox-frontend/wasm
cp -r pkg/. /Users/sohamzemse/Workspace/opensource/personal/proof-of-exploit-stuff/frontend/pox-frontend/wasm/
rm /Users/sohamzemse/Workspace/opensource/personal/proof-of-exploit-stuff/frontend/pox-frontend/wasm/.gitignore
rm /Users/sohamzemse/Workspace/opensource/personal/proof-of-exploit-stuff/frontend/pox-frontend/wasm/README.md

0 comments on commit c6c7926

Please sign in to comment.