From aa039c0c89ace7cdb9838116a1ab7b71269a920e Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 31 Oct 2024 11:06:47 -0600 Subject: [PATCH] fix(bench): fix sozo bench (#2601) * wip * benches: fix sozo benchmark --- crates/benches/contracts/Scarb.lock | 10 ++++----- crates/benches/contracts/Scarb.toml | 25 ++++++--------------- crates/benches/contracts/dojo_dev.toml | 30 ++++++++++++++++++++++++++ crates/dojo/test-utils/src/compiler.rs | 9 +------- output_sozo.txt | 1 + 5 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 crates/benches/contracts/dojo_dev.toml create mode 100644 output_sozo.txt diff --git a/crates/benches/contracts/Scarb.lock b/crates/benches/contracts/Scarb.lock index de94d7c64a..944857b5b8 100644 --- a/crates/benches/contracts/Scarb.lock +++ b/crates/benches/contracts/Scarb.lock @@ -3,20 +3,20 @@ version = 1 [[package]] name = "benches" -version = "0.4.4" +version = "1.0.0-rc.0" dependencies = [ "dojo", ] [[package]] name = "dojo" -version = "0.4.4" -source = "git+https://github.com/dojoengine/dojo#37f41d585f549013a73ca189034b0471f1e81731" +version = "1.0.0-rc.0" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7" dependencies = [ "dojo_plugin", ] [[package]] name = "dojo_plugin" -version = "0.3.11" -source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7d8aa29a92062fcb9e6659" +version = "2.8.4" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7" diff --git a/crates/benches/contracts/Scarb.toml b/crates/benches/contracts/Scarb.toml index 342a1fab1a..240685d344 100644 --- a/crates/benches/contracts/Scarb.toml +++ b/crates/benches/contracts/Scarb.toml @@ -1,24 +1,11 @@ [package] -cairo-version = "2.4.0" +cairo-version = "=2.8.4" name = "benches" -version = "0.4.4" +version = "1.0.0-rc.0" -[cairo] -sierra-replace-ids = true +[[target.starknet-contract]] +build-external-contracts = ["dojo::world::world_contract::world"] [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", version = "0.4.4" } - -[[target.dojo]] - -[tool.dojo] -initializer_class_hash = "0xbeef" - -[tool.dojo.env] -# rpc_url = "http://localhost:5050/" -# Default account for katana with seed = 0 -account_address = "0x2af9427c5a277474c079a1283c880ee8a6f0f8fbf73ce969c08d88befec1bba" -private_key = "0x1800000000300000180000000000030000000000003006001800006600" - -[tool.dojo.world.namespace] -default = "benches" +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.0" } +starknet = "=2.8.4" diff --git a/crates/benches/contracts/dojo_dev.toml b/crates/benches/contracts/dojo_dev.toml new file mode 100644 index 0000000000..5b048e70a5 --- /dev/null +++ b/crates/benches/contracts/dojo_dev.toml @@ -0,0 +1,30 @@ +[world] +description = "Bench world." +name = "bench" +seed = "bench" + +[env] +rpc_url = "http://localhost:5050/" +# Default account for katana with seed = 0 +account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec" +private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912" +#world_address = "0x077c0dc7c1aba7f8842aff393ce6aa71fa675b4ced1bc927f7fc971b6acd92fc" + +[namespace] +default = "ns" +mappings = { "ns" = ["c1", "M"], "ns2" = ["c1", "M"] } + +[init_call_args] +"ns-c1" = ["0xfffe"] +"ns2-c1" = ["0xfffe"] + +[writers] +"ns" = ["ns-c1", "ns-c2"] +"ns-M" = ["ns-c2", "ns-c1", "ns2-c1"] + +[owners] +"ns" = ["ns-c1"] + +[migration] +order_inits = ["ns-c2", "ns-c1"] +skip_contracts = ["ns-c3"] diff --git a/crates/dojo/test-utils/src/compiler.rs b/crates/dojo/test-utils/src/compiler.rs index 419359db2a..5266cf7f94 100644 --- a/crates/dojo/test-utils/src/compiler.rs +++ b/crates/dojo/test-utils/src/compiler.rs @@ -6,8 +6,7 @@ use std::{env, fs, io}; use assert_fs::TempDir; use camino::{Utf8Path, Utf8PathBuf}; -use scarb::compiler::plugin::CairoPluginRepository; -use scarb::compiler::{CompilationUnit, CompilerRepository, Profile}; +use scarb::compiler::{CompilationUnit, Profile}; use scarb::core::{Config, TargetKind}; use scarb::ops; use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; @@ -297,10 +296,6 @@ pub fn copy_project_temp( /// * `path` - The path to the Scarb.toml file to build the config for. /// * `profile` - The profile to use for the config. pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result { - let compilers = CompilerRepository::empty(); - - let cairo_plugins = CairoPluginRepository::empty(); - // If the cache_dir is not overriden, we can't run tests in parallel. let cache_dir = TempDir::new().unwrap(); @@ -310,9 +305,7 @@ pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result .global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap())) .ui_verbosity(Verbosity::Verbose) .log_filter_directive(env::var_os("SCARB_LOG")) - .compilers(compilers) .profile(profile) - .cairo_plugins(cairo_plugins) .build() } diff --git a/output_sozo.txt b/output_sozo.txt new file mode 100644 index 0000000000..0f3c86a1a0 --- /dev/null +++ b/output_sozo.txt @@ -0,0 +1 @@ +test build/Sozo.Cold ... bench: 4521852125 ns/iter (+/- 0)