diff --git a/Cargo.lock b/Cargo.lock index a272260..20b1631 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1452,26 +1452,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "bincode_derive", - "serde", - "unty", -] - -[[package]] -name = "bincode_derive" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" -dependencies = [ - "virtue", -] - [[package]] name = "bit-set" version = "0.8.0" @@ -1627,6 +1607,29 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "bson" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969a9ba84b0ff843813e7249eed1678d9b6607ce5a3b8f0a47af3fcf7978e6e" +dependencies = [ + "ahash", + "base64 0.22.1", + "bitvec", + "getrandom 0.2.16", + "getrandom 0.3.3", + "hex", + "indexmap 2.10.0", + "js-sys", + "once_cell", + "rand 0.9.2", + "serde", + "serde_bytes", + "serde_json", + "time", + "uuid", +] + [[package]] name = "bumpalo" version = "3.17.0" @@ -2705,8 +2708,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -2716,9 +2721,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", ] [[package]] @@ -4505,7 +4512,7 @@ version = "0.1.0" dependencies = [ "alloy", "anyhow", - "bincode", + "bson", "cacache", "clap", "futures", @@ -5026,6 +5033,7 @@ version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ + "indexmap 2.10.0", "itoa", "memchr", "ryu", @@ -6284,12 +6292,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "url" version = "2.5.4" @@ -6321,6 +6323,7 @@ checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" dependencies = [ "getrandom 0.3.3", "js-sys", + "serde", "wasm-bindgen", ] @@ -6348,12 +6351,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "virtue" -version = "0.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" - [[package]] name = "w3f-bls" version = "0.1.9" diff --git a/Cargo.toml b/Cargo.toml index e9464f7..598234d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ revive-dt-solc-binaries = { version = "0.1.0", path = "crates/solc-binaries" } alloy-primitives = "1.2.1" alloy-sol-types = "1.2.1" anyhow = "1.0" -bincode = { version = "2.0.1", features = ["serde"] } +bson = { version = "2.15.0" } cacache = { version = "13.1.0" } clap = { version = "4", features = ["derive"] } foundry-compilers-artifacts = { version = "0.18.0" } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index c44c153..b747bc1 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -23,7 +23,7 @@ revive-dt-report = { workspace = true } alloy = { workspace = true } anyhow = { workspace = true } -bincode = { workspace = true } +bson = { workspace = true } cacache = { workspace = true } clap = { workspace = true } futures = { workspace = true } diff --git a/crates/core/src/cached_compiler.rs b/crates/core/src/cached_compiler.rs index b9e1dfb..ee05428 100644 --- a/crates/core/src/cached_compiler.rs +++ b/crates/core/src/cached_compiler.rs @@ -19,7 +19,7 @@ use once_cell::sync::Lazy; use semver::Version; use serde::{Deserialize, Serialize}; use tokio::sync::{Mutex, RwLock}; -use tracing::{debug, debug_span, instrument}; +use tracing::{Instrument, debug, debug_span, instrument}; use crate::Platform; @@ -40,7 +40,8 @@ impl CachedCompiler { skip_all, fields( metadata_file_path = %metadata_file_path.as_ref().display(), - %mode + %mode, + platform = P::config_id().to_string() ), err )] @@ -70,24 +71,26 @@ impl CachedCompiler { metadata_file_path: metadata_file_path.as_ref().to_path_buf(), solc_mode: mode.clone(), }; - debug_span!( - "Running compilation for the cache key", - cache_key.platform_key = %cache_key.platform_key, - cache_key.compiler_version = %cache_key.compiler_version, - cache_key.metadata_file_path = %cache_key.metadata_file_path.display(), - cache_key.solc_mode = %cache_key.solc_mode, - ); - let compilation_callback = || async move { - compile_contracts::
( - metadata.directory()?, - compiler_path, - metadata.files_to_compile()?, - mode, - deployed_libraries, - ) - .map(|compilation_result| compilation_result.map(CacheValue::new)) - .await + let compilation_callback = || { + async move { + compile_contracts::
(
+ metadata.directory()?,
+ compiler_path,
+ metadata.files_to_compile()?,
+ mode,
+ deployed_libraries,
+ )
+ .map(|compilation_result| compilation_result.map(CacheValue::new))
+ .await
+ }
+ .instrument(debug_span!(
+ "Running compilation for the cache key",
+ cache_key.platform_key = %cache_key.platform_key,
+ cache_key.compiler_version = %cache_key.compiler_version,
+ cache_key.metadata_file_path = %cache_key.metadata_file_path.display(),
+ cache_key.solc_mode = %cache_key.solc_mode,
+ ))
};
let compiled_contracts = match deployed_libraries {
@@ -95,12 +98,13 @@ impl CachedCompiler {
// means that linking is required in this case.
Some(_) => {
debug!("Deployed libraries defined, recompilation must take place");
+ debug!("Cache miss");
compilation_callback().await?.compiler_output
}
// If no deployed libraries are specified then we can follow the cached flow and attempt
// to lookup the compilation artifacts in the cache.
None => {
- debug!("Deployed contract undefined, attempting to make use of cache");
+ debug!("Deployed libraries undefined, attempting to make use of cache");
// Lock this specific cache key such that we do not get inconsistent state. We want
// that when multiple cases come in asking for the compilation artifacts then they
@@ -182,6 +186,7 @@ impl ArtifactsCache {
}
}
+ #[instrument(level = "debug", skip_all, err)]
pub async fn with_invalidated_cache(self) -> Result