-
Notifications
You must be signed in to change notification settings - Fork 159
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
Conversation
There was a problem hiding this 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.
actor_bundles/.gitignore
Outdated
@@ -0,0 +1,2 @@ | |||
* |
There was a problem hiding this comment.
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/
?
There was a problem hiding this comment.
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/
@LesnyRumcajs Fixed by tweaking |
There was a problem hiding this 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")) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/daemon/bundle.rs
Outdated
#[tokio::test] | ||
async fn test_load_actor_bundles() { | ||
let db = fvm_ipld_blockstore::MemoryBlockstore::new(); | ||
load_actor_bundles(&db).await.unwrap(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@LesnyRumcajs Fixed |
src/mod.rs
Outdated
pub url: Url, | ||
} | ||
|
||
lazy_static! { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/networks/calibnet/mod.rs
Outdated
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #2765
Other information and links
Change checklist