diff --git a/Cargo.lock b/Cargo.lock index 57fb138eec..73a3f1a171 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,6 +67,7 @@ dependencies = [ "fvm_ipld_blockstore", "fvm_ipld_encoding", "ignore", + "indexmap 2.8.0", "num-traits", "toml 0.8.20", "tracing", diff --git a/Cargo.toml b/Cargo.toml index d419da6762..a0026d4cca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -251,7 +251,7 @@ fvm_ipld_encoding = { git = "https://github.com/consensus-shipyard/ref-fvm.git" fvm_ipld_hamt = { git = "https://github.com/consensus-shipyard/ref-fvm.git" } fvm_ipld_amt = { git = "https://github.com/consensus-shipyard/ref-fvm.git" } -[profile.wasm] +[profile.wasm-actor] inherits = "release" panic = "abort" overflow-checks = false diff --git a/fendermint/actors-custom-car/Cargo.toml b/fendermint/actors-custom-car/Cargo.toml index b3cd53f8ab..4cb5c180ff 100644 --- a/fendermint/actors-custom-car/Cargo.toml +++ b/fendermint/actors-custom-car/Cargo.toml @@ -29,3 +29,4 @@ ignore = "0.4" tracing = "0.1" build-rs-utils = { path = "../../build-rs-utils" } which = "7" +indexmap = "2" diff --git a/fendermint/actors-custom-car/build.rs b/fendermint/actors-custom-car/build.rs index 7c816f3fe4..f9174250c3 100644 --- a/fendermint/actors-custom-car/build.rs +++ b/fendermint/actors-custom-car/build.rs @@ -19,7 +19,6 @@ use cargo_metadata::{DependencyKind, MetadataCommand}; use color_eyre::eyre::{bail, eyre, OptionExt, Result}; use fil_actor_bundler::Bundler; use fs_err as fs; -use std::collections::HashSet; use std::io::{BufRead, BufReader}; use std::ops::Deref; use std::path::{Path, PathBuf}; @@ -220,10 +219,15 @@ fn build_all_wasm_blobs( .iter() .map(|actor| format!("-p={}", actor.package_name)); - echo!("actors-custom-car", purple, "Target: {channel} {target}"); + echo!( + "actors-custom-car", + purple, + "Target: channel={channel} target={target}" + ); let rustup = which::which("rustup")?; + let profile = "wasm-actor"; // Cargo build command for all test_actors at once. let mut cmd = Command::new(rustup); cmd.arg("run") @@ -234,7 +238,8 @@ fn build_all_wasm_blobs( .args(package_args) .arg("--target") .arg(target) - .arg("--profile=wasm") + .arg("--profile") + .arg(profile) .arg("--features=fil-actor") .arg(format!("--manifest-path={}", manifest_path.display())) .stdout(Stdio::piped()) @@ -293,9 +298,11 @@ fn print_cargo_rerun_if_dependency_instructions( let cargo_lock = find_cargo_lock(out_dir).ok_or_eyre("Couldn't find Cargo.lock")?; rerun_if_changed(&cargo_lock); - let workspace = cargo_lock.parent().unwrap(); + let workspace_dir = cargo_lock + .parent() + .expect("A file always should have a parent"); - let metadata = create_metadata_command(workspace.join("Cargo.toml")).exec()?; + let metadata = create_metadata_command(workspace_dir.join("Cargo.toml")).exec()?; let package = metadata .packages @@ -307,7 +314,7 @@ fn print_cargo_rerun_if_dependency_instructions( let mut dependencies = Vec::from_iter(package.dependencies.iter()); // Collect all packages by follow the dependencies of all packages we find. - let mut packages = HashSet::new(); + let mut packages = indexmap::IndexSet::new(); packages.insert(DeduplicatePackage::from(package)); while let Some(dependency) = dependencies.pop() { @@ -325,7 +332,7 @@ fn print_cargo_rerun_if_dependency_instructions( let maybe_package = metadata .packages .iter() - .filter(|p| !p.manifest_path.starts_with(workspace)) + .filter(|p| !p.manifest_path.starts_with(workspace_dir)) .find(|p| { // Check that the name matches and that the version matches or this is // a git or path dep. A git or path dependency can only occur once, so we don't @@ -382,8 +389,10 @@ fn main() -> Result<()> { // `rustc` upgrades in `rust-toolchain.toml` let out_dir = out_dir.join(&channel); + let profile = "wasm-actor"; + // the joins represent the subdirectories under which `cargo` creates the actual WASM aritifacts - let wasm_blob_dir = out_dir.join(target).join("wasm"); + let wasm_blob_dir = out_dir.join(target).join(profile); echo!( "actors-custom-car", diff --git a/ipc/provider/src/manager/evm/manager.rs b/ipc/provider/src/manager/evm/manager.rs index a589337899..39d34ae9e5 100644 --- a/ipc/provider/src/manager/evm/manager.rs +++ b/ipc/provider/src/manager/evm/manager.rs @@ -362,7 +362,7 @@ impl SubnetManager for EthSubnetManager { let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } async fn pre_fund(&self, subnet: SubnetID, from: Address, balance: TokenAmount) -> Result<()> { @@ -575,7 +575,7 @@ impl SubnetManager for EthSubnetManager { let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } /// Approves the `from` address to use up to `amount` tokens from `token_address`. @@ -609,7 +609,7 @@ impl SubnetManager for EthSubnetManager { let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } async fn fund_with_token( @@ -641,7 +641,7 @@ impl SubnetManager for EthSubnetManager { let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } async fn release( @@ -671,7 +671,7 @@ impl SubnetManager for EthSubnetManager { let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } /// Send value between two addresses in a subnet @@ -926,7 +926,7 @@ impl SubnetManager for EthSubnetManager { let txn = extend_call_with_pending_block(call).await?; let pending_tx = txn.send().await?; let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } } @@ -1210,7 +1210,7 @@ impl BottomUpCheckpointRelayer for EthSubnetManager { let receipt = pending_tx.retries(TRANSACTION_RECEIPT_RETRIES).await?; - block_number_from_receipt(receipt) + block_number_from_positive_receipt(receipt) } async fn last_bottom_up_checkpoint_height( @@ -1510,15 +1510,23 @@ where } /// Get the block number from the transaction receipt -fn block_number_from_receipt( +fn block_number_from_positive_receipt( receipt: Option, ) -> Result { match receipt { - Some(r) => { - let block_number = r - .block_number - .ok_or_else(|| anyhow!("cannot get block number"))?; - Ok(block_number.as_u64() as ChainEpoch) + Some(r) => + // success only + { + if r.status.as_ref().map(|x| x.as_u64()) != Some(1) { + let block_number = r + .block_number + .ok_or_else(|| anyhow!("cannot get block number"))?; + Ok(block_number.as_u64() as ChainEpoch) + } else { + Err(anyhow!( + "txn sent to network, but receipt was a revert receipt" + )) + } } None => Err(anyhow!( "txn sent to network, but receipt cannot be obtained, please check scanner"