Skip to content

Commit

Permalink
re-add support for hyperspace and wallaby on master.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed Feb 13, 2023
1 parent 138f52f commit dc3c074
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/actions/rust-cargo-run/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ inputs:
cache_name:
description: The name of the cache to save/restore
required: true
default: v2-test
default: test-ntwk-hyperspace

runs:
using: composite
Expand All @@ -41,7 +41,7 @@ runs:
CACHE_SKIP_SAVE: ${{ inputs.save_cache == '' || inputs.save_cache == 'false' }}
with:
version: v0.2.15
shared-key: ${{ inputs.cache_name }} # change this to invalidate sccache for this job
shared-key: ntwk-hyperspace-v1-${{ inputs.cache_name }} # change this to invalidate sccache for this job
- name: Running ${{ inputs.command }}
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
env:
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- ntwk/hyperspace
pull_request:

env:
Expand Down Expand Up @@ -43,7 +44,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', 'hyperspace' ]
steps:
- name: Checking out
uses: actions/checkout@v2
Expand All @@ -57,6 +58,10 @@ jobs:
BUILD_FIL_NETWORK: ${{ matrix.network }}
run: |
cargo run --locked -- -o output/builtin-actors.car
- name: Checking no wasm-bindgen references
run: |
sudo apt-get update && sudo apt-get -y install wabt parallel
find ./target -name '*.wasm' -print0 | parallel -0 --halt now,fail=1 sh -c 'wasm2wat --enable-bulk-memory {} | grep bindgen; test $? -ne 0'
coverage:
runs-on: ubuntu-latest
env:
Expand All @@ -70,7 +75,7 @@ jobs:
command: version
components: llvm-tools-preview
github_token: ${{ secrets.GITHUB_TOKEN }}
cache_name: v3-cov
cache_name: cov
save_cache: true
- name: Put LLVM tools into the PATH
run: echo "${HOME}/.rustup/toolchains/$(cat rust-toolchain)-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin" >> $GITHUB_PATH
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', 'hyperspace' ]
steps:
- name: Checking out
uses: actions/checkout@v2
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bundle: deps-build
cargo run -- -o output/builtin-actors.car

# Create all canonical network bundles
all-bundles: bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-testing
all-bundles: bundle-mainnet bundle-caterpillarnet bundle-butterflynet bundle-calibrationnet bundle-devnet bundle-testing bundle-testing bundle-wallaby bundle-hyperspace

bundle-mainnet: deps-build
BUILD_FIL_NETWORK=mainnet cargo run -- -o output/builtin-actors-mainnet.car
Expand All @@ -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-hyperspace: deps-build
BUILD_FIL_NETWORK=hyperspace cargo run -- -o output/builtin-actors-hyperspace.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
1 change: 1 addition & 0 deletions actors/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ rand = "0.8.5"
once_cell = "1.17.0"

[features]
hyperspace = []
fil-actor = ["fil_actors_runtime/fil-actor"]
2 changes: 2 additions & 0 deletions actors/evm/src/interpreter/precompiles/fvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ pub(super) fn call_actor_shared<RT: Runtime>(
// TODO only CBOR or "nothing" for now. We should support RAW and DAG_CBOR in the future.
let params = match codec {
fvm_ipld_encoding::CBOR => Some(IpldBlock { codec, data: params.into() }),
#[cfg(feature = "hyperspace")]
fvm_ipld_encoding::DAG_CBOR => Some(IpldBlock { codec, data: params.into() }),
0 if params.is_empty() => None,
_ => return Err(PrecompileError::InvalidInput),
};
Expand Down
2 changes: 2 additions & 0 deletions actors/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ fn handle_filecoin_method_output(output: &[u8]) -> Result<Option<IpldBlock>, Act
}
// Supported codecs.
fvm_ipld_encoding::CBOR => Some(IpldBlock { codec, data: return_data.into() }),
#[cfg(feature = "hyperspace")]
fvm_ipld_encoding::DAG_CBOR => Some(IpldBlock { codec, data: return_data.into() }),
// Everything else.
_ => return Err(ActorError::serialization(format!("unsupported codec: {codec}"))),
};
Expand Down
22 changes: 21 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const ACTORS: &[(&Package, &ID)] = &[
("ethaccount", "ethaccount"),
];

/// 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])] = &[("hyperspace", &["hyperspace"])];

const NETWORK_ENV: &str = "BUILD_FIL_NETWORK";

/// Returns the configured network name, checking both the environment and feature flags.
Expand All @@ -48,6 +54,10 @@ fn network_name() -> String {
Some("calibrationnet")
} else if cfg!(feature = "devnet") {
Some("devnet")
} else if cfg!(feature = "wallaby") {
Some("wallaby")
} else if cfg!(feature = "hyperspace") {
Some("hyperspace")
} else if cfg!(feature = "testing") {
Some("testing")
} else if cfg!(feature = "testing-fake-proofs") {
Expand Down Expand Up @@ -107,14 +117,24 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rerun-if-changed={}", file);
}

// 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")
.args(packages.iter().map(|pkg| "-p=".to_owned() + pkg))
.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
32 changes: 23 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,15 @@ 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"], &["sector-512m", "sector-32g", "sector-64g", "min-power-2g"]),
(
"testing",
&["wallaby", "hyperspace"],
&["sector-512m", "sector-32g", "sector-64g", "min-power-16g", "short-precommit"],
),
(&["calibrationnet"], &["sector-32g", "sector-64g", "min-power-32g"]),
(&["devnet"], &["sector-2k", "sector-8m", "small-deals", "short-precommit", "min-power-2k"]),
(
&["testing"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -29,7 +33,7 @@ static NETWORKS: &[(&str, &[&str])] = &[
],
),
(
"testing-fake-proofs",
&["testing-fake-proofs"],
&[
"sector-2k",
"sector-8m",
Expand All @@ -46,12 +50,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
3 changes: 3 additions & 0 deletions runtime/src/runtime/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,14 @@ pub mod policy_constants {
pub const MINIMUM_CONSENSUS_POWER: i64 = 2 << 10;
#[cfg(feature = "min-power-2g")]
pub const MINIMUM_CONSENSUS_POWER: i64 = 2 << 30;
#[cfg(feature = "min-power-16g")]
pub const MINIMUM_CONSENSUS_POWER: i64 = 16 << 30;
#[cfg(feature = "min-power-32g")]
pub const MINIMUM_CONSENSUS_POWER: i64 = 32 << 30;
#[cfg(not(any(
feature = "min-power-2k",
feature = "min-power-2g",
feature = "min-power-16g",
feature = "min-power-32g"
)))]
pub const MINIMUM_CONSENSUS_POWER: i64 = 10 << 40;
Expand Down
2 changes: 1 addition & 1 deletion test_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ multihash = { version = "0.16.1", default-features = false }
test-case = "2.2.1"
ethers = { version = "0.17.0", features = ["abigen"] }
hex = "0.4.3"
hex-literal = "0.3.4"
hex-literal = "0.3.4"
2 changes: 1 addition & 1 deletion test_vm/tests/init_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn placeholder_deploy() {

let deploy = || {
v.apply_message(
EAM_ACTOR_ADDR, // so this works even if "m2-native" is disabled.
EAM_ACTOR_ADDR,
INIT_ACTOR_ADDR,
TokenAmount::zero(),
fil_actor_init::Method::Exec4 as u64,
Expand Down

0 comments on commit dc3c074

Please sign in to comment.