From 053348ff0ebbd3f320c96529b75b15cff8d2c0e3 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 23 Jul 2022 22:42:44 +0300 Subject: [PATCH 1/9] add devnet-m2-native network with associated features to build scripts --- actors/init/build.rs | 22 ++++++++++++++++++++++ build.rs | 2 ++ runtime/build.rs | 4 ++++ 3 files changed, 28 insertions(+) create mode 100644 actors/init/build.rs diff --git a/actors/init/build.rs b/actors/init/build.rs new file mode 100644 index 000000000..733bb1f52 --- /dev/null +++ b/actors/init/build.rs @@ -0,0 +1,22 @@ +static NETWORKS: &[(&str, &[&str])] = &[ + ("mainnet", &[]), + ("caterpillarnet", &[]), + ("butterflynet", &[]), + ("calibrationnet", &[]), + ("devnet", &[]), + ("devnet-m2-native", &["m2-native"]), + ("testing", &[]), + ("testing-fake-proofs", &[]), +]; +const NETWORK_ENV: &str = "BUILD_FIL_NETWORK"; + +fn main() { + let network = std::env::var(NETWORK_ENV).ok(); + println!("cargo:rerun-if-env-changed={}", NETWORK_ENV); + + let network = network.as_deref().unwrap_or("mainnet"); + let features = NETWORKS.iter().find(|(k, _)| k == &network).expect("unknown network").1; + for feature in features { + println!("cargo:rustc-cfg=feature=\"{}\"", feature); + } +} diff --git a/build.rs b/build.rs index 067f6a328..e7c14342c 100644 --- a/build.rs +++ b/build.rs @@ -43,6 +43,8 @@ fn network_name() -> String { Some("calibrationnet") } else if cfg!(feature = "devnet") { Some("devnet") + } else if cfg!(feature = "devnet-m2-native") { + Some("devnet-m2-native") } else if cfg!(feature = "testing") { Some("testing") } else if cfg!(feature = "testing-fake-proofs") { diff --git a/runtime/build.rs b/runtime/build.rs index 767b810bf..54fbf7b5d 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -14,6 +14,10 @@ static NETWORKS: &[(&str, &[&str])] = &[ ("butterflynet", &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]), ("calibrationnet", &["sector-32g", "sector-64g", "min-power-32g"]), ("devnet", &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"]), + ( + "devnet-m2-native", + &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k", "m2-native"], + ), ( "testing", &[ From 151550e30a4e6fc87788a78aa1682d54595079d1 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 23 Jul 2022 22:48:07 +0300 Subject: [PATCH 2/9] transitively activate m2-native on runtime --- actors/init/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actors/init/Cargo.toml b/actors/init/Cargo.toml index 8663e105d..1f3e88a94 100644 --- a/actors/init/Cargo.toml +++ b/actors/init/Cargo.toml @@ -31,4 +31,4 @@ fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime", featur [features] fil-actor = [] -m2-native = [] +m2-native = ["fil_actors_runtime/m2-native"] From 2fcfe20aefc4058e0a45498d366a91d85dfefe0b Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 23 Jul 2022 22:48:30 +0300 Subject: [PATCH 3/9] add devnet-m2-native bundle build target --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 82cda1b9e..ba9b56313 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,9 @@ bundle-calibrationnet: deps-build bundle-devnet: deps-build BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.car +bundle-devnet-m2-native: deps-build + BUILD_FIL_NETWORK=devnet-m2-native cargo run -- -o output/builtin-actors-devnet.car + bundle-testing: deps-build BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car BUILD_FIL_NETWORK=testing-fake-proofs cargo run -- -o output/builtin-actors-testing-fake-proofs.car From 7aafaf8ddf66b4926c4de20d6d7b161f0693dc22 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 23 Jul 2022 22:55:33 +0300 Subject: [PATCH 4/9] fix output target for m2-native bundle --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ba9b56313..7336b03dc 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ bundle-devnet: deps-build BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.car bundle-devnet-m2-native: deps-build - BUILD_FIL_NETWORK=devnet-m2-native cargo run -- -o output/builtin-actors-devnet.car + BUILD_FIL_NETWORK=devnet-m2-native cargo run -- -o output/builtin-actors-devnet-m2-native.car bundle-testing: deps-build BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car From 2d02a08cef6ff2b82b3c72b8a60722f8e09c2d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 28 Jul 2022 13:08:34 +0100 Subject: [PATCH 5/9] pacify clippy. --- actors/init/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actors/init/src/lib.rs b/actors/init/src/lib.rs index 10e597ee7..26b2ddce2 100644 --- a/actors/init/src/lib.rs +++ b/actors/init/src/lib.rs @@ -205,7 +205,7 @@ where } #[cfg(feature = "m2-native")] -fn can_exec(rt: &RT, caller: &Cid, exec: &Cid) -> bool +fn can_exec(_rt: &RT, _caller: &Cid, _exec: &Cid) -> bool where BS: Blockstore, RT: Runtime, From 877e1f754f2722ed44c4aa5c920e19fed002fd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 28 Jul 2022 13:10:52 +0100 Subject: [PATCH 6/9] runtime: Cargo.toml sort dependencies. --- runtime/Cargo.toml | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index bbe9ca297..aac3941b5 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -8,34 +8,33 @@ edition = "2021" repository = "https://github.com/filecoin-project/builtin-actors" [dependencies] -fvm_ipld_hamt = "0.5.1" -fvm_ipld_amt = { version = "0.4.2", features = ["go-interop"] } -fvm_shared = { version = "0.8.0", default-features = false } -num-traits = "0.2.14" -num-derive = "0.3.3" -serde = { version = "1.0.136", features = ["derive"] } -lazy_static = "1.4.0" -unsigned-varint = "0.7.1" -integer-encoding = { version = "3.0.3", default-features = false } -byteorder = "1.4.3" -cid = { version = "0.8.3", default-features = false, features = ["serde-codec"] } -base64 = "0.13.0" -log = "0.4.14" -indexmap = { version = "1.8.0", features = ["serde-1"] } -thiserror = "1.0.30" -# enforce wasm compat -getrandom = { version = "0.2.5", features = ["js"] } -hex = { version = "0.4.3", optional = true } anyhow = "1.0.56" -fvm_sdk = { version = "2.0.0-alpha.1", optional = true } +base64 = "0.13.0" blake2b_simd = "1.0" +byteorder = "1.4.3" +cid = { version = "0.8.3", default-features = false, features = ["serde-codec"] } +fvm_ipld_amt = { version = "0.4.2", features = ["go-interop"] } fvm_ipld_blockstore = "0.1.1" fvm_ipld_encoding = "0.2.2" +fvm_ipld_hamt = "0.5.1" +fvm_sdk = { version = "2.0.0-alpha.1", optional = true } +fvm_shared = { version = "0.8.0", default-features = false } +getrandom = { version = "0.2.5", features = ["js"] } +hex = { version = "0.4.3", optional = true } +indexmap = { version = "1.8.0", features = ["serde-1"] } +integer-encoding = { version = "3.0.3", default-features = false } +itertools = "0.10" +lazy_static = "1.4.0" +log = "0.4.14" multihash = { version = "0.16.1", default-features = false } +num-derive = "0.3.3" +num-traits = "0.2.14" rand = "0.8.5" -serde_repr = "0.1.8" regex = "1" -itertools = "0.10" +serde = { version = "1.0.136", features = ["derive"] } +serde_repr = "0.1.8" +thiserror = "1.0.30" +unsigned-varint = "0.7.1" [dependencies.sha2] version = "0.10" From 4e94e26ff664b959c4e27024c1b90b58f3a822e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 28 Jul 2022 13:11:50 +0100 Subject: [PATCH 7/9] Cargo.toml: point patches to master. --- Cargo.lock | 14 +++++++------- Cargo.toml | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1eba62fa..d9cf4357e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -973,7 +973,7 @@ dependencies = [ [[package]] name = "fvm_ipld_amt" version = "0.4.2" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "ahash", "anyhow", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "fvm_ipld_bitfield" version = "0.5.2" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "cs_serde_bytes", "fvm_ipld_encoding", @@ -1001,7 +1001,7 @@ dependencies = [ [[package]] name = "fvm_ipld_blockstore" version = "0.1.1" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "anyhow", "cid", @@ -1026,7 +1026,7 @@ dependencies = [ [[package]] name = "fvm_ipld_encoding" version = "0.2.2" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "anyhow", "cid", @@ -1043,7 +1043,7 @@ dependencies = [ [[package]] name = "fvm_ipld_hamt" version = "0.5.1" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "anyhow", "byteorder", @@ -1063,7 +1063,7 @@ dependencies = [ [[package]] name = "fvm_sdk" version = "2.0.0-alpha.1" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "cid", "fvm_ipld_encoding", @@ -1077,7 +1077,7 @@ dependencies = [ [[package]] name = "fvm_shared" version = "0.8.0" -source = "git+https://github.com/filecoin-project/ref-fvm#cfbb6b11878afc90afde964da6b22c4709db5123" +source = "git+https://github.com/filecoin-project/ref-fvm?branch=master#e9657a7d1927f154d3020024229fc1122e0b947b" dependencies = [ "anyhow", "bimap", diff --git a/Cargo.toml b/Cargo.toml index ba5cf24a8..c79b4dd98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,14 +49,13 @@ members = [ ] [patch.crates-io] -## TODO point this to master -fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_sdk = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_ipld_hamt = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_ipld_amt = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_ipld_bitfield = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_ipld_encoding = { git = "https://github.com/filecoin-project/ref-fvm" } -fvm_ipld_blockstore = { git = "https://github.com/filecoin-project/ref-fvm" } +fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_sdk = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_ipld_hamt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_ipld_amt = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_ipld_bitfield = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_ipld_encoding = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } +fvm_ipld_blockstore = { git = "https://github.com/filecoin-project/ref-fvm", branch = "master" } ## Uncomment when working locally on ref-fvm and this repo simultaneously. ## Assumes the ref-fvm checkout is in a sibling directory with the same name. From fea998eb15931f8ed833a623093f032367d1bd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 28 Jul 2022 14:35:55 +0100 Subject: [PATCH 8/9] fix devnet-m2-bundle by propagating Cargo features. --- actors/init/build.rs | 22 ---------------------- build.rs | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 actors/init/build.rs diff --git a/actors/init/build.rs b/actors/init/build.rs deleted file mode 100644 index 733bb1f52..000000000 --- a/actors/init/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -static NETWORKS: &[(&str, &[&str])] = &[ - ("mainnet", &[]), - ("caterpillarnet", &[]), - ("butterflynet", &[]), - ("calibrationnet", &[]), - ("devnet", &[]), - ("devnet-m2-native", &["m2-native"]), - ("testing", &[]), - ("testing-fake-proofs", &[]), -]; -const NETWORK_ENV: &str = "BUILD_FIL_NETWORK"; - -fn main() { - let network = std::env::var(NETWORK_ENV).ok(); - println!("cargo:rerun-if-env-changed={}", NETWORK_ENV); - - let network = network.as_deref().unwrap_or("mainnet"); - let features = NETWORKS.iter().find(|(k, _)| k == &network).expect("unknown network").1; - for feature in features { - println!("cargo:rustc-cfg=feature=\"{}\"", feature); - } -} diff --git a/build.rs b/build.rs index e7c14342c..d552a9ad6 100644 --- a/build.rs +++ b/build.rs @@ -27,6 +27,14 @@ const ACTORS: &[(&Package, &ID)] = &[ const WASM_FEATURES: &[&str] = &["+bulk-memory", "+crt-static"]; +/// Default Cargo features to activate during the build. +const DEFAULT_CARGO_FEATURES: &[&str] = &["fil-actor"]; + +/// Extra Cargo-level features to enable per network. +const EXTRA_CARGO_FEATURES: &[(&str, &[&str])] = &[ + ("wallaby", &["m2-native"]), +]; + const NETWORK_ENV: &str = "BUILD_FIL_NETWORK"; /// Returns the configured network name, checking both the environment and feature flags. @@ -108,6 +116,12 @@ fn main() -> Result<(), Box> { WASM_FEATURES.iter().flat_map(|flag| ["-Ctarget-feature=", *flag, " "]).collect::() + "-Clink-arg=--export-table"; + // Compute Cargo features to apply. + let features = { + let extra = EXTRA_CARGO_FEATURES.iter().find(|(k, _)| k == &network_name).map(|f| f.1).unwrap_or_default(); + [DEFAULT_CARGO_FEATURES, extra].concat() + }; + // Cargo build command for all actors at once. let mut cmd = Command::new(&cargo); cmd.arg("build") @@ -115,7 +129,7 @@ fn main() -> Result<(), Box> { .arg("--target=wasm32-unknown-unknown") .arg("--profile=wasm") .arg("--locked") - .arg("--features=fil-actor") + .arg("--features=".to_owned() + &features.join(",")) .arg("--manifest-path=".to_owned() + manifest_path.to_str().unwrap()) .env("RUSTFLAGS", rustflags) .env(NETWORK_ENV, network_name) From 5f76d967564b29e528aaa3bdcc45c6ca940f6829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 28 Jul 2022 14:54:03 +0100 Subject: [PATCH 9/9] add build preset / bundle configurations for wallaby and devnet-wasm. QoL finishing touches: - The 1:N network/features mapping in runtime/build.rs wasn't cutting it any longer. I expanded this data structure to M:N. - Added docs to runtime/build.rs. --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- .gitignore | 2 +- Makefile | 7 +++++-- actors/init/Cargo.toml | 4 ++-- build.rs | 14 +++++++++++--- runtime/build.rs | 31 ++++++++++++++++++++----------- 7 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b791772e0..5fd84c2ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }} strategy: matrix: - network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ] + network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs', 'wallaby', 'devnet-wasm' ] steps: - name: Checking out uses: actions/checkout@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb112fa25..355743475 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: CACHE_SKIP_SAVE: ${{ matrix.push == '' || matrix.push == 'false' }} strategy: matrix: - network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs' ] + network: [ 'mainnet', 'caterpillarnet', 'butterflynet', 'calibrationnet', 'devnet', 'testing', 'testing-fake-proofs', 'wallaby', 'devnet-wasm' ] steps: - name: Checking out uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 609dd565a..5b6079d6c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ target *.wasm .idea/ **/.DS_Store -output/builtin-actors.car +output/*.car diff --git a/Makefile b/Makefile index 7336b03dc..6496b0bfe 100644 --- a/Makefile +++ b/Makefile @@ -72,8 +72,11 @@ bundle-calibrationnet: deps-build bundle-devnet: deps-build BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.car -bundle-devnet-m2-native: deps-build - BUILD_FIL_NETWORK=devnet-m2-native cargo run -- -o output/builtin-actors-devnet-m2-native.car +bundle-wallaby: deps-build + BUILD_FIL_NETWORK=wallaby cargo run -- -o output/builtin-actors-wallaby.car + +bundle-devnet-wasm: deps-build + BUILD_FIL_NETWORK=devnet-wasm cargo run -- -o output/builtin-actors-devnet-wasm.car bundle-testing: deps-build BUILD_FIL_NETWORK=testing cargo run -- -o output/builtin-actors-testing.car diff --git a/actors/init/Cargo.toml b/actors/init/Cargo.toml index 1f3e88a94..4aa90ce4d 100644 --- a/actors/init/Cargo.toml +++ b/actors/init/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["filecoin", "web3", "wasm"] crate-type = ["cdylib", "lib"] [dependencies] -fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime", features = ["fil-actor"] } +fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime" } fvm_shared = { version = "0.8.0", default-features = false } fvm_ipld_hamt = "0.5.1" serde = { version = "1.0.136", features = ["derive"] } @@ -30,5 +30,5 @@ fvm_ipld_encoding = "0.2.2" fil_actors_runtime = { version = "9.0.0-alpha.1", path = "../../runtime", features = ["test_utils", "sector-default"] } [features] -fil-actor = [] +fil-actor = ["fil_actors_runtime/fil-actor"] m2-native = ["fil_actors_runtime/m2-native"] diff --git a/build.rs b/build.rs index d552a9ad6..80dd9d872 100644 --- a/build.rs +++ b/build.rs @@ -32,6 +32,8 @@ const DEFAULT_CARGO_FEATURES: &[&str] = &["fil-actor"]; /// Extra Cargo-level features to enable per network. const EXTRA_CARGO_FEATURES: &[(&str, &[&str])] = &[ + ("devnet-wasm", &["m2-native"]), + /*("devnet-evm", &["m2-fevm"]),*/ ("wallaby", &["m2-native"]), ]; @@ -51,8 +53,10 @@ fn network_name() -> String { Some("calibrationnet") } else if cfg!(feature = "devnet") { Some("devnet") - } else if cfg!(feature = "devnet-m2-native") { - Some("devnet-m2-native") + } else if cfg!(feature = "devnet-wasm") { + Some("devnet-wasm") + } else if cfg!(feature = "wallaby") { + Some("wallaby") } else if cfg!(feature = "testing") { Some("testing") } else if cfg!(feature = "testing-fake-proofs") { @@ -118,7 +122,11 @@ fn main() -> Result<(), Box> { // Compute Cargo features to apply. let features = { - let extra = EXTRA_CARGO_FEATURES.iter().find(|(k, _)| k == &network_name).map(|f| f.1).unwrap_or_default(); + let extra = EXTRA_CARGO_FEATURES + .iter() + .find(|(k, _)| k == &network_name) + .map(|f| f.1) + .unwrap_or_default(); [DEFAULT_CARGO_FEATURES, extra].concat() }; diff --git a/runtime/build.rs b/runtime/build.rs index 54fbf7b5d..7f7324e11 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -1,7 +1,7 @@ -static NETWORKS: &[(&str, &[&str])] = &[ - ("mainnet", &["sector-32g", "sector-64g"]), +static NETWORKS: &[(&[&str], &[&str])] = &[ + (&["mainnet"], &["sector-32g", "sector-64g"]), ( - "caterpillarnet", + &["caterpillarnet"], &[ "sector-512m", "sector-32g", @@ -11,15 +11,14 @@ static NETWORKS: &[(&str, &[&str])] = &[ "min-power-2k", ], ), - ("butterflynet", &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]), - ("calibrationnet", &["sector-32g", "sector-64g", "min-power-32g"]), - ("devnet", &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"]), + (&["butterflynet", "wallaby"], &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]), + (&["calibrationnet"], &["sector-32g", "sector-64g", "min-power-32g"]), ( - "devnet-m2-native", - &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k", "m2-native"], + &["devnet", "devnet-wasm" /*devnet-fevm*/], + &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"], ), ( - "testing", + &["testing"], &[ "sector-2k", "sector-8m", @@ -33,7 +32,7 @@ static NETWORKS: &[(&str, &[&str])] = &[ ], ), ( - "testing-fake-proofs", + &["testing-fake-proofs"], &[ "sector-2k", "sector-8m", @@ -50,12 +49,22 @@ static NETWORKS: &[(&str, &[&str])] = &[ ]; const NETWORK_ENV: &str = "BUILD_FIL_NETWORK"; +/// This build script enables _local_ compile features. These features do not +/// affect the dependency graph (they are not processed by Cargo). They are only +/// in effect for conditional compilation _in this crate_. +/// +/// The reason we can't set these features as Cargo features from the root build +/// is that this crate is only ever used as a _transitive_ dependency from actor +/// crates. +/// +/// So the only two options are: (a) actors crates set the features when +/// importing us as a dependency (super repetitive), or (b) this. fn main() { let network = std::env::var(NETWORK_ENV).ok(); println!("cargo:rerun-if-env-changed={}", NETWORK_ENV); let network = network.as_deref().unwrap_or("mainnet"); - let features = NETWORKS.iter().find(|(k, _)| k == &network).expect("unknown network").1; + let features = NETWORKS.iter().find(|(k, _)| k.contains(&network)).expect("unknown network").1; for feature in features { println!("cargo:rustc-cfg=feature=\"{}\"", feature); }