diff --git a/.cargo/config.toml b/.cargo/config.toml index 75c9564058..3d0eefe156 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -14,7 +14,19 @@ rustflags = [ "-C", "force-unwind-tables=yes", "-C", - "link-arg=/STACK:8000000" # Set stack to 8 MB + "link-arg=/STACK:8000000", # Set stack to 8 MB + # force static linking for the rocksdb and bitcoinconsensus crates + "-Ctarget-feature=+crt-static", + "-Clink-args=/DEFAULTLIB:libcmt.lib", + "-Clink-args=/DEFAULTLIB:libvcruntime.lib", + "-Clink-args=/DEFAULTLIB:libucrt.lib", + "-Clink-args=/DEFAULTLIB:oldnames.lib", + "-Clink-args=/DEFAULTLIB:legacy_stdio_definitions.lib", + "-Clink-args=/NODEFAULTLIB:msvcrt.lib", + "-Clink-args=/NODEFAULTLIB:msvcrtd.lib", + "-Clink-args=/NODEFAULTLIB:libcmtd.lib", + "-Clink-args=/NODEFAULTLIB:vcruntime.lib", + "-Clink-args=/NODEFAULTLIB:vcruntimed.lib" ] [alias] diff --git a/Cargo.lock b/Cargo.lock index 1d6dfb9035..dfed65d6d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5892,6 +5892,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libmimalloc-sys" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libp2p-identity" version = "0.2.9" @@ -6139,6 +6149,15 @@ dependencies = [ "quote 1.0.37", ] +[[package]] +name = "mimalloc" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" @@ -9316,40 +9335,31 @@ dependencies = [ name = "rooch" version = "0.7.7" dependencies = [ - "accumulator", "anyhow 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", "async-trait", "bcs", "bitcoin 0.32.3", - "bitcoin-move", - "bitcoincore-rpc", "ciborium", "clap 4.5.17", "codespan-reporting", "csv", "datatest-stable 0.1.1", "fastcrypto 0.1.8 (git+https://github.com/MystenLabs/fastcrypto?rev=56f6223b84ada922b6cb2c672c69db2ea3dc6a13)", - "framework-builder", "framework-release", "framework-types", - "futures", "hex", "itertools 0.13.0", "jemallocator", "lazy_static 1.5.0", "log", "metrics", + "mimalloc", "move-binary-format", - "move-bytecode-utils", - "move-bytecode-verifier", "move-cli", "move-command-line-common", "move-compiler", "move-core-types", - "move-coverage", - "move-disassembler", "move-errmapgen", - "move-model", "move-package", "move-stdlib", "move-unit-test", @@ -9368,7 +9378,6 @@ dependencies = [ "moveos-verifier", "once_cell", "parking_lot 0.12.3", - "prometheus", "rand 0.8.5", "raw-store", "regex", @@ -9385,7 +9394,6 @@ dependencies = [ "rooch-rpc-api", "rooch-rpc-client", "rooch-rpc-server", - "rooch-sequencer", "rooch-store", "rooch-types", "rpassword", @@ -9396,7 +9404,6 @@ dependencies = [ "serde_json", "serde_with 2.3.3", "serde_yaml 0.9.34+deprecated", - "serenity", "smt", "tabled", "tempfile", @@ -9788,7 +9795,6 @@ dependencies = [ "ciborium", "cosmwasm-std", "cosmwasm-vm", - "libc", "log", "move-binary-format", "move-core-types", diff --git a/Cargo.toml b/Cargo.toml index 0cc0b44664..4eaeb202ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -343,7 +343,7 @@ scopeguard = "1.1" uuid = { version = "1.11.0", features = ["v4", "fast-rng"] } protobuf = { version = "2.28", features = ["with-bytes"] } redb = { version = "2.1.1" } -rocksdb = { git = "https://github.com/rooch-network/rust-rocksdb.git", rev = "41d102327ba3cf9a2335d1192e8312c92bc3d6f9", features = ["lz4"] } +rocksdb = { git = "https://github.com/rooch-network/rust-rocksdb.git", rev = "41d102327ba3cf9a2335d1192e8312c92bc3d6f9", features = ["lz4","mt_static"] } lz4 = { version = "1.28.0" } ripemd = { version = "0.1.3" } fastcrypto-zkp = { version = "0.1.3" } diff --git a/crates/rooch-rpc-client/src/client_config.rs b/crates/rooch-rpc-client/src/client_config.rs index d76c3d7787..b7450a8de0 100644 --- a/crates/rooch-rpc-client/src/client_config.rs +++ b/crates/rooch-rpc-client/src/client_config.rs @@ -128,7 +128,7 @@ impl Default for Env { fn default() -> Self { Env { alias: BuiltinChainID::Local.chain_name(), - rpc: ServerConfig::default().url(false), + rpc: format!("http://127.0.0.1:{}", ServerConfig::default().port), ws: None, } } diff --git a/crates/rooch/Cargo.toml b/crates/rooch/Cargo.toml index d2c7df6057..3394327ab9 100644 --- a/crates/rooch/Cargo.toml +++ b/crates/rooch/Cargo.toml @@ -40,46 +40,29 @@ fastcrypto = { workspace = true } log = { workspace = true } csv = { workspace = true } tempfile = { workspace = true } -[target.'cfg(not(target_env = "msvc"))'.dependencies] -jemallocator = { version = "0.5.4", features = ["unprefixed_malloc_on_supported_platforms", "profiling"] } rustc-hash = { workspace = true } rand = { workspace = true } tabled = { workspace = true } xorf = { workspace = true } xxhash-rust = { workspace = true, features = ["xxh3"] } vergen-pretty = { workspace = true } -prometheus = { workspace = true } lazy_static = { workspace = true } schemars = { workspace = true } bitcoin = { workspace = true } -bitcoincore-rpc = { workspace = true } ciborium = { workspace = true } wasmer = { workspace = true } tiny-keccak = { workspace = true } -serenity = { features = [ - "client", - "gateway", - "rustls_backend", - "cache", - "model", -], workspace = true } -futures = { workspace = true } -move-bytecode-utils = { workspace = true } move-binary-format = { workspace = true } -move-bytecode-verifier = { workspace = true } move-cli = { workspace = true } move-command-line-common = { workspace = true } move-compiler = { workspace = true } move-core-types = { workspace = true } -move-coverage = { workspace = true } -move-disassembler = { workspace = true } move-errmapgen = { workspace = true } move-package = { workspace = true } move-unit-test = { workspace = true } move-vm-runtime = { workspace = true, features = ["stacktrace", "debugging", "testing"] } move-vm-test-utils = { workspace = true } -move-model = { workspace = true } move-stdlib = { workspace = true } move-vm-types = { workspace = true } @@ -92,15 +75,12 @@ moveos-verifier = { workspace = true } moveos-object-runtime = { workspace = true } moveos-compiler = { workspace = true } moveos-config = { workspace = true } -accumulator = { workspace = true } metrics = { workspace = true } moveos-gas-profiling = { workspace = true } -framework-builder = { workspace = true } framework-types = { workspace = true } raw-store = { workspace = true } smt = { workspace = true } -bitcoin-move = { workspace = true } rooch-key = { workspace = true } rooch-types = { workspace = true } @@ -115,12 +95,17 @@ rooch-indexer = { workspace = true } rooch-db = { workspace = true } rooch-common = { workspace = true } rooch-store = { workspace = true } -rooch-sequencer = { workspace = true } rooch-faucet = { workspace = true } rooch-oracle = { workspace = true } framework-release = { workspace = true } +#We should keep the allocator in the last of the dependencies +[target.'cfg(not(target_env = "msvc"))'.dependencies] +jemallocator = { version = "0.5.4", features = ["unprefixed_malloc_on_supported_platforms", "profiling"] } +[target.'cfg(target_env = "msvc")'.dependencies] +mimalloc = { version = "0.1.39" } + [build-dependencies] anyhow = { workspace = true } vergen-git2 = { workspace = true } \ No newline at end of file diff --git a/crates/rooch/src/commands/init.rs b/crates/rooch/src/commands/init.rs index 4ab4be1480..fcf20eea3f 100644 --- a/crates/rooch/src/commands/init.rs +++ b/crates/rooch/src/commands/init.rs @@ -94,7 +94,7 @@ impl CommandAction<()> for Init { if address_and_port_regex.is_match(&url) { url } else { - return Err(RoochError::CommandArgumentError("Invalid input format. Please provide a valid URL (e.g., http://0.0.0.0:6767).".to_owned())); + return Err(RoochError::CommandArgumentError("Invalid input format. Please provide a valid URL (e.g., http://127.0.0.1:6767).".to_owned())); } }; Some(if url.trim().is_empty() { diff --git a/crates/rooch/src/main.rs b/crates/rooch/src/main.rs index 0a6df00f18..8d81e10e41 100644 --- a/crates/rooch/src/main.rs +++ b/crates/rooch/src/main.rs @@ -6,11 +6,29 @@ use rooch::RoochCli; use std::process::exit; #[cfg(not(target_env = "msvc"))] -use jemallocator::Jemalloc; +mod allocator { + use jemallocator::Jemalloc; + + pub type Allocator = Jemalloc; + + pub const fn allocator() -> Allocator { + Jemalloc + } +} + +#[cfg(target_env = "msvc")] +mod allocator { + use mimalloc::MiMalloc; + + pub type Allocator = MiMalloc; + + pub const fn allocator() -> Allocator { + MiMalloc + } +} -#[cfg(not(target_env = "msvc"))] #[global_allocator] -static GLOBAL: Jemalloc = Jemalloc; +static GLOBAL: allocator::Allocator = allocator::allocator(); /// rooch is a command line tools for Rooch Network #[tokio::main] diff --git a/frameworks/rooch-nursery/Cargo.toml b/frameworks/rooch-nursery/Cargo.toml index 297ae96fdc..40531a900d 100644 --- a/frameworks/rooch-nursery/Cargo.toml +++ b/frameworks/rooch-nursery/Cargo.toml @@ -19,7 +19,6 @@ log = { workspace = true } serde_json = { workspace = true } ciborium = { workspace = true } wasmer = { workspace = true } -libc = { workspace = true } cosmwasm-vm = { workspace = true } cosmwasm-std = { workspace = true } once_cell = { workspace = true } diff --git a/frameworks/rooch-nursery/src/natives/wasm.rs b/frameworks/rooch-nursery/src/natives/wasm.rs index 1f309bc34c..d04fdbe535 100644 --- a/frameworks/rooch-nursery/src/natives/wasm.rs +++ b/frameworks/rooch-nursery/src/natives/wasm.rs @@ -460,21 +460,21 @@ fn execute_wasm_function_inner( // TODO: check the length of arguments for the function calling - let trap_handler: Box< - dyn Fn(libc::c_int, *const libc::siginfo_t, *const libc::c_void) -> bool - + Send - + Sync - + 'static, - > = Box::new(|signum, siginfo, ctx| { - warn!( - "Trap handler called, signum:{:?}, siginfo:{:?}, context:{:?}", - signum, siginfo, ctx - ); - false - }); + // let trap_handler: Box< + // dyn Fn(libc::c_int, *const libc::siginfo_t, *const libc::c_void) -> bool + // + Send + // + Sync + // + 'static, + // > = Box::new(|signum, siginfo, ctx| { + // warn!( + // "Trap handler called, signum:{:?}, siginfo:{:?}, context:{:?}", + // signum, siginfo, ctx + // ); + // false + // }); // Set trap handler - instance.store.set_trap_handler(Some(trap_handler)); + // instance.store.set_trap_handler(Some(trap_handler)); match calling_function.call(&mut instance.store, wasm_func_args.as_slice()) { Ok(ret) => { diff --git a/moveos/raw-store/Cargo.toml b/moveos/raw-store/Cargo.toml index e2ddc58c56..3950aa90bb 100644 --- a/moveos/raw-store/Cargo.toml +++ b/moveos/raw-store/Cargo.toml @@ -18,7 +18,7 @@ anyhow = { workspace = true } serde = { workspace = true } tap = { workspace = true } tokio = { workspace = true } -rocksdb = { workspace = true, features = ["lz4"] } +rocksdb = { workspace = true } parking_lot = { workspace = true } prometheus = { workspace = true } diff --git a/moveos/raw-store/src/lib.rs b/moveos/raw-store/src/lib.rs index bcf26c87be..fac465451d 100644 --- a/moveos/raw-store/src/lib.rs +++ b/moveos/raw-store/src/lib.rs @@ -867,3 +867,15 @@ where KVStore::multiple_get(self.get_store(), encoded_keys) } } + +#[cfg(test)] +mod tests { + use super::*; + use moveos_config::store_config::RocksdbConfig; + + #[test] + fn test_new_db() { + let tmpdir = moveos_config::temp_dir(); + let _db = RocksDB::new(tmpdir.path(), vec![], RocksdbConfig::default()).unwrap(); + } +}