Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: inline actor bundles #3276

Merged
merged 15 commits into from
Jul 31, 2023
Merged

feat: inline actor bundles #3276

merged 15 commits into from
Jul 31, 2023

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Jul 25, 2023

Summary of changes

Changes introduced in this pull request:

  • Inline actor bundles
  • Re-enable state migration unit tests

Reference issue to close (if applicable)

Closes #2765

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@hanabi1224 hanabi1224 marked this pull request as ready for review July 25, 2023 17:22
@hanabi1224 hanabi1224 requested a review from a team as a code owner July 25, 2023 17:22
@hanabi1224 hanabi1224 requested review from lemmih and jdjaustin and removed request for a team July 25, 2023 17:22
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it less of a burden for developers. This approach forces builds even if there are no changes.

That is to say:

❯ cargo build
   Compiling forest-filecoin v0.11.1 (/home/rumcajs/prj/forest2)
    Finished dev [unoptimized] target(s) in 15.04s

forest2 on  hm/inline-actor-bundles [$?] is 📦 v0.11.1 via  v18.16.1 via 🦀 v1.71.0 took 15s
❯ cargo build
   Compiling forest-filecoin v0.11.1 (/home/rumcajs/prj/forest2)
    Finished dev [unoptimized] target(s) in 15.13s

as opposed to

❯ cargo build
   Compiling forest-filecoin v0.11.1 (/home/rumcajs/prj/forest)
    Finished dev [unoptimized] target(s) in 20.02s

forest on  query-cid-2 [$!?] is 📦 v0.11.1 via  v18.16.1 via 🦀 v1.71.0 took 20s
❯ cargo build
    Finished dev [unoptimized] target(s) in 0.15s

Notice how I need to build the binary again, even though I didn't do any changes. On most machines, unless some custom configuration is used, it will be even slower.

@@ -0,0 +1,2 @@
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just add actor_bundles to the root .gitignore? In general, it's a bit surprising to suddenly have such directory. Maybe we could use target/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to target/actor_bundles/

@hanabi1224
Copy link
Contributor Author

This approach forces builds even if there are no changes.

@LesnyRumcajs Fixed by tweaking cargo:rerun-if-changed lines, it should now only rebuild when bundle car cache is changed

Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also remove the logic from places like https://github.com/ChainSafe/forest/blob/hm/inline-actor-bundles/src/networks/devnet/mod.rs#L112 . To my understanding, this is no longer needed.

);

let mut zstd_encoder = ZstdEncoder::with_quality(
async_fs::File::create(Path::new(&env::var("OUT_DIR")?).join("actor_bundles.car.zst"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also defined in src/daemon/bundle.rs. Let's have a single source of truth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to share the code, include_bytes!(concat!(env!("OUT_DIR"), "/actor_bundles.car.zst")); requires str literals and is evaluated at compile time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below code does not compile, only literals (like "foo", -42 and 3.14) can be passed to concat!()

const BUNDLE_NAME: &str = "/actor_bundles.car.zst";
pub const ACTOR_BUNDLES_CAR_ZST: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), BUNDLE_NAME));

build.rs Outdated
use walkdir::WalkDir;

const PROTO_DIR: &str = "proto";
const CARGO_OUT_DIR: &str = "proto";

fn main() -> anyhow::Result<()> {
const ACTOR_BUNDLE_CACHE_DIR: &str = "target/actor_bundles/";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to have it as a PathBuf. The less we operate on strings and more on strongly typed objects, the less likely we'll introduce a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

#[tokio::test]
async fn test_load_actor_bundles() {
let db = fvm_ipld_blockstore::MemoryBlockstore::new();
load_actor_bundles(&db).await.unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add some assertions here, even with hard-coded Cids.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@hanabi1224
Copy link
Contributor Author

Let's also remove the logic from places like https://github.com/ChainSafe/forest/blob/hm/inline-actor-bundles/src/networks/devnet/mod.rs#L112 . To my understanding, this is no longer needed.

@LesnyRumcajs Fixed

src/mod.rs Outdated
pub url: Url,
}

lazy_static! {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could avoid this macro with once_cell::sync::Lazy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

manifest: Cid::try_from("bafy2bzacedbedgynklc4dgpyxippkxmba2mgtw7ecntoneclsvvl4klqwuyyy").unwrap(),
url: Url::parse("https://github.com/filecoin-project/builtin-actors/releases/download/v9.0.3/builtin-actors-calibrationnet.car").unwrap()
})
bundle: Some(Cid::try_from("bafy2bzacedbedgynklc4dgpyxippkxmba2mgtw7ecntoneclsvvl4klqwuyyy").unwrap())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this? I mean, we have this defined here and in src/mod.rs

Copy link
Contributor Author

@hanabi1224 hanabi1224 Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to map the cids to the network and height and use them in migrate functions. Moving everything to mod.rs might be too much

@hanabi1224 hanabi1224 added this pull request to the merge queue Jul 31, 2023
@hanabi1224 hanabi1224 removed this pull request from the merge queue due to a manual request Jul 31, 2023
@hanabi1224 hanabi1224 enabled auto-merge July 31, 2023 07:16
@hanabi1224 hanabi1224 added this pull request to the merge queue Jul 31, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 31, 2023
@hanabi1224 hanabi1224 added this pull request to the merge queue Jul 31, 2023
Merged via the queue into main with commit 1fcea0c Jul 31, 2023
@hanabi1224 hanabi1224 deleted the hm/inline-actor-bundles branch July 31, 2023 08:17
sudo-shashank pushed a commit that referenced this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration: download bundles from IPFS
4 participants