Skip to content

Commit

Permalink
add devnet-wasm and wallaby networks with associated features to buil…
Browse files Browse the repository at this point in the history
…d scripts (filecoin-project#504)

* add devnet-m2-native network with associated features to build scripts

* transitively activate m2-native on runtime

* add devnet-m2-native bundle build target

* fix output target for m2-native bundle

* pacify clippy.

* runtime: Cargo.toml sort dependencies.

* Cargo.toml: point patches to master.

* fix devnet-m2-bundle by propagating Cargo features.

* 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.

Co-authored-by: vyzo <vyzo@hackzen.org>
  • Loading branch information
2 people authored and shamb0 committed Oct 3, 2022
1 parent 463b76e commit c11c7eb
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ubuntu-latest
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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ target
*.wasm
.idea/
**/.DS_Store
output/builtin-actors.car
output/*.car
8 changes: 4 additions & 4 deletions Cargo.lock

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

15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,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.
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ bundle-calibrationnet: deps-build
bundle-devnet: deps-build
BUILD_FIL_NETWORK=devnet cargo run -- -o output/builtin-actors-devnet.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
BUILD_FIL_NETWORK=testing-fake-proofs cargo run -- -o output/builtin-actors-testing-fake-proofs.car
Expand Down
2 changes: 1 addition & 1 deletion actors/init/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
}

#[cfg(feature = "m2-native")]
fn can_exec<BS, RT>(rt: &RT, caller: &Cid, exec: &Cid) -> bool
fn can_exec<BS, RT>(_rt: &RT, _caller: &Cid, _exec: &Cid) -> bool
where
BS: Blockstore,
RT: Runtime<BS>,
Expand Down
6 changes: 5 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fn network_name() -> String {
Some("calibrationnet")
} else if cfg!(feature = "devnet") {
Some("devnet")
} 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") {
Expand Down Expand Up @@ -110,7 +114,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.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(NETWORK_ENV, network_name)
.stdout(Stdio::piped())
Expand Down
31 changes: 22 additions & 9 deletions runtime/build.rs
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -11,11 +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"]),
(
"testing",
&["devnet", "devnet-wasm" /*devnet-fevm*/],
&["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"],
),
(
&["testing"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -29,7 +32,7 @@ static NETWORKS: &[(&str, &[&str])] = &[
],
),
(
"testing-fake-proofs",
&["testing-fake-proofs"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -46,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);
}
Expand Down

0 comments on commit c11c7eb

Please sign in to comment.