diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50c101eb4a1..141ea7bbd36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,6 +189,9 @@ jobs: - name: Run tests run: cargo test working-directory: radix-engine + - name: Run tests (no_std) + run: cargo test --no-default-features --features alloc + working-directory: radix-engine radix-engine-wasmer: name: Run Radix Engine tests with Wasmer runs-on: ${{ matrix.os }} diff --git a/radix-engine-derive/Cargo.toml b/radix-engine-derive/Cargo.toml index 77b935e7181..568dd8ff960 100644 --- a/radix-engine-derive/Cargo.toml +++ b/radix-engine-derive/Cargo.toml @@ -11,8 +11,6 @@ proc-macro2 = { version = "1.0.38" } syn = { version = "1.0.93", features = ["full", "extra-traits"] } quote = { version = "1.0.18" } uuid = { version = "1.0.0", features = ["v4"] } -serde = { version = "1.0.137", default-features = false } -serde_json = { version = "1.0.81", default-features = false } sbor = { path = "../sbor", default-features = false } scrypto-abi = { path = "../scrypto-abi", default-features = false } @@ -29,12 +27,10 @@ scrypto-abi = { path = "../scrypto-abi", default-features = false } # default = ["std"] std = [ - "serde/std", "serde_json/std", "sbor/std", "sbor/serde", "scrypto-abi/std", "scrypto-abi/serde" ] alloc = [ - "serde/alloc", "serde_json/alloc", "sbor/alloc", "sbor/serde", "scrypto-abi/alloc", "scrypto-abi/serde" ] diff --git a/radix-engine-stores/Cargo.toml b/radix-engine-stores/Cargo.toml index 4a84dfaa26c..426901b4da7 100644 --- a/radix-engine-stores/Cargo.toml +++ b/radix-engine-stores/Cargo.toml @@ -4,10 +4,18 @@ version = "0.7.0" edition = "2021" [dependencies] +sbor = { path = "../sbor", default-features = false } radix-engine = { path = "../radix-engine" } radix-engine-interface = { path = "../radix-engine-interface", default-features = false } -sbor = { path = "../sbor" } rocksdb = { version = "0.19.0", optional = true } [features] +default = ["std"] +std = [ + "sbor/std", "radix-engine-interface/std", +] +alloc = [ + "sbor/alloc","radix-engine-interface/alloc", +] + rocksdb = ["dep:rocksdb"] \ No newline at end of file diff --git a/radix-engine/Cargo.toml b/radix-engine/Cargo.toml index ebecdbff2c8..205a610a690 100644 --- a/radix-engine/Cargo.toml +++ b/radix-engine/Cargo.toml @@ -12,9 +12,10 @@ utils = { path = "../utils", default-features = false } radix-engine-constants = { path = "../radix-engine-constants" } colored = { version = "2.0.0", default-features = false } hex = { version = "0.4.3", default-features = false } -bitflags = "1.3" +bitflags = { version = "1.3" } indexmap = { version = "1.8.1" } -moka = { version = "0.9.4", features = ["sync"], default-features = false } +lru = { version = "0.8.1", default-features = false } +moka = { version = "0.9.4", features = ["sync"], default-features = false, optional = true } # WASM de-/serialization parity-wasm = { version = "0.42.2" } @@ -35,7 +36,7 @@ wasmer-compiler-singlepass = { version = "2.2.1", optional = true } [dev-dependencies] wabt = { version = "0.10.0" } criterion = { version = "0.3", features = ["html_reports"] } -scrypto-unit = { path = "../scrypto-unit" } +scrypto-unit = { path = "../scrypto-unit", default-features = false } rand = { version = "0.8.5" } rand_chacha = { version = "0.3.1" } rayon = "1.5.3" @@ -55,8 +56,11 @@ harness = false [features] # You should enable either `std` or `alloc` default = ["std"] -std = ["sbor/std", "scrypto/std", "wasmi/std", "transaction/std"] -alloc = ["sbor/alloc", "scrypto/alloc", "transaction/alloc"] +std = ["sbor/std", "scrypto/std", "scrypto-unit/std", "wasmi/std", "transaction/std", "radix-engine-interface/std", "utils/std", "moka"] +alloc = ["sbor/alloc", "scrypto/alloc", "scrypto-unit/alloc", "transaction/alloc", "radix-engine-interface/alloc", "utils/alloc", "lru/hashbrown"] # Use `wasmer` as WASM engine, otherwise `wasmi` wasmer = ["dep:wasmer", "dep:wasmer-compiler-singlepass"] + +# Use moka for caching +moka = ["dep:moka"] \ No newline at end of file diff --git a/radix-engine/benches/wasm.rs b/radix-engine/benches/wasm.rs index 20e3be34c85..3e0eaa433e6 100644 --- a/radix-engine/benches/wasm.rs +++ b/radix-engine/benches/wasm.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use criterion::{criterion_group, criterion_main, Criterion}; use radix_engine::model::extract_abi; use radix_engine::wasm::DefaultWasmEngine; @@ -7,6 +5,7 @@ use radix_engine::wasm::InstrumentedCode; use radix_engine::wasm::WasmEngine; use radix_engine::wasm::WasmValidator; use radix_engine_interface::crypto::hash; +use sbor::rust::sync::Arc; fn bench_wasm_validation(c: &mut Criterion) { let code = include_bytes!("../../assets/account.wasm"); diff --git a/radix-engine/src/engine/interpreters/scrypto_interface.rs b/radix-engine/src/engine/interpreters/scrypto_interface.rs index 62d4097c340..75c36f81b71 100644 --- a/radix-engine/src/engine/interpreters/scrypto_interface.rs +++ b/radix-engine/src/engine/interpreters/scrypto_interface.rs @@ -18,6 +18,8 @@ use radix_engine_interface::api::types::{ }; use radix_engine_interface::crypto::Hash; use radix_engine_interface::data::IndexedScryptoValue; +use sbor::rust::string::String; +use sbor::rust::vec::Vec; impl<'g, 's, W, R, N, T> SysNativeInvokable for Kernel<'g, 's, W, R> where diff --git a/radix-engine/src/engine/interpreters/scrypto_interpreter.rs b/radix-engine/src/engine/interpreters/scrypto_interpreter.rs index 99b89c796c5..567f7aa188d 100644 --- a/radix-engine/src/engine/interpreters/scrypto_interpreter.rs +++ b/radix-engine/src/engine/interpreters/scrypto_interpreter.rs @@ -116,6 +116,8 @@ mod tests { // RFC 2056 fn assert_all() { assert_send::>(); + // TODO: make sure engine is indeed multi-thread safe! + #[cfg(not(feature = "alloc"))] assert_sync::>(); } }; diff --git a/radix-engine/src/engine/interpreters/wasm_runtime.rs b/radix-engine/src/engine/interpreters/wasm_runtime.rs index 5739d20b87f..306bee9f13c 100644 --- a/radix-engine/src/engine/interpreters/wasm_runtime.rs +++ b/radix-engine/src/engine/interpreters/wasm_runtime.rs @@ -12,6 +12,7 @@ use radix_engine_interface::api::wasm_input::{ ResourceManagerMethodInvocation, VaultMethodInvocation, WorktopMethodInvocation, }; use radix_engine_interface::data::{IndexedScryptoValue, ScryptoCustomTypeId}; +use sbor::rust::vec::Vec; /// A glue between system api (call frame and track abstraction) and WASM. /// diff --git a/radix-engine/src/engine/kernel.rs b/radix-engine/src/engine/kernel.rs index 51c445db9a9..6e30f157a4b 100644 --- a/radix-engine/src/engine/kernel.rs +++ b/radix-engine/src/engine/kernel.rs @@ -7,10 +7,10 @@ use radix_engine_interface::api::types::{ use radix_engine_interface::crypto::Hash; use radix_engine_interface::data::*; +use sbor::rust::fmt::Debug; +use sbor::rust::mem; use scrypto::access_rule_node; use scrypto::rule; -use std::fmt::Debug; -use std::mem; use transaction::errors::IdAllocationError; use transaction::model::AuthZoneParams; use transaction::validation::*; diff --git a/radix-engine/src/engine/modules/execution_trace.rs b/radix-engine/src/engine/modules/execution_trace.rs index e1fefae2f07..12f77d9c4c7 100644 --- a/radix-engine/src/engine/modules/execution_trace.rs +++ b/radix-engine/src/engine/modules/execution_trace.rs @@ -9,7 +9,7 @@ use radix_engine_interface::api::types::{ use radix_engine_interface::data::IndexedScryptoValue; use radix_engine_interface::math::Decimal; use radix_engine_interface::model::*; -use std::fmt::Debug; +use sbor::rust::fmt::Debug; #[derive(Debug, Clone, PartialEq, Eq)] #[scrypto(TypeId, Encode, Decode)] diff --git a/radix-engine/src/engine/modules/module.rs b/radix-engine/src/engine/modules/module.rs index f259e3f0233..7869479e359 100644 --- a/radix-engine/src/engine/modules/module.rs +++ b/radix-engine/src/engine/modules/module.rs @@ -7,7 +7,7 @@ use radix_engine_interface::api::types::{ Level, LockHandle, RENodeId, SubstateId, SubstateOffset, VaultId, }; use radix_engine_interface::data::IndexedScryptoValue; -use std::fmt::Debug; +use sbor::rust::fmt::Debug; #[derive(Debug)] pub enum InvocationInfo<'a> { diff --git a/radix-engine/src/engine/system_api.rs b/radix-engine/src/engine/system_api.rs index 3e13e07193d..63df40065e2 100644 --- a/radix-engine/src/engine/system_api.rs +++ b/radix-engine/src/engine/system_api.rs @@ -4,7 +4,7 @@ use crate::model::{Resource, SubstateRef, SubstateRefMut}; use crate::types::*; use bitflags::bitflags; use radix_engine_interface::api::types::{Level, LockHandle, RENodeId, SubstateOffset, VaultId}; -use std::fmt::Debug; +use sbor::rust::fmt::Debug; bitflags! { #[derive(Encode, Decode, TypeId)] diff --git a/radix-engine/src/model/kv_store/node.rs b/radix-engine/src/model/kv_store/node.rs index bf5abfce680..34fad8db120 100644 --- a/radix-engine/src/model/kv_store/node.rs +++ b/radix-engine/src/model/kv_store/node.rs @@ -1,6 +1,6 @@ -use sbor::rust::collections::HashMap; - use crate::model::KeyValueStoreEntrySubstate; +use sbor::rust::collections::HashMap; +use sbor::rust::vec::Vec; #[derive(Debug)] pub struct KeyValueStore { diff --git a/radix-engine/src/model/method_authorization.rs b/radix-engine/src/model/method_authorization.rs index 8fc609a1484..e84c660788a 100644 --- a/radix-engine/src/model/method_authorization.rs +++ b/radix-engine/src/model/method_authorization.rs @@ -1,5 +1,6 @@ use radix_engine_interface::math::Decimal; use radix_engine_interface::model::*; +use sbor::rust::vec::Vec; use sbor::*; use scrypto::scrypto; diff --git a/radix-engine/src/model/resources/substates/vault.rs b/radix-engine/src/model/resources/substates/vault.rs index b60d0fe820e..a9c562b95da 100644 --- a/radix-engine/src/model/resources/substates/vault.rs +++ b/radix-engine/src/model/resources/substates/vault.rs @@ -4,7 +4,7 @@ use crate::model::{ ResourceOperationError, VaultError, }; use crate::types::*; -use std::ops::Deref; +use sbor::rust::ops::Deref; #[derive(Debug, Clone, PartialEq, Eq)] #[scrypto(TypeId, Encode, Decode)] diff --git a/radix-engine/src/transaction/preview_executor.rs b/radix-engine/src/transaction/preview_executor.rs index d2954a18d4c..fb20ad7edf9 100644 --- a/radix-engine/src/transaction/preview_executor.rs +++ b/radix-engine/src/transaction/preview_executor.rs @@ -35,22 +35,24 @@ pub fn execute_preview>>, + #[cfg(not(feature = "moka"))] + cache: RefCell>>>, + #[cfg(feature = "moka")] + cache: moka::sync::Cache<(Hash, Hash), Arc>>, } #[derive(Debug, Clone)] pub struct InstrumenterOptions { - max_cache_size_bytes: u64, + max_cache_size_bytes: usize, } impl Default for WasmInstrumenter { @@ -29,7 +31,12 @@ pub struct InstrumentedCode { impl WasmInstrumenter { pub fn new(options: InstrumenterOptions) -> Self { - let cache = Cache::builder() + #[cfg(not(feature = "moka"))] + let cache = RefCell::new(lru::LruCache::new( + NonZeroUsize::new(options.max_cache_size_bytes / (1024 * 1024)).unwrap(), + )); + #[cfg(feature = "moka")] + let cache = moka::sync::Cache::builder() .weigher(|_key: &(Hash, Hash), value: &Arc>| -> u32 { value .len() @@ -37,7 +44,7 @@ impl WasmInstrumenter { .and_then(|total| total.try_into().ok()) .unwrap_or(u32::MAX) }) - .max_capacity(options.max_cache_size_bytes) + .max_capacity(options.max_cache_size_bytes as u64) .build(); Self { cache } @@ -51,6 +58,16 @@ impl WasmInstrumenter { let code_hash = hash(code); let cache_key = (code_hash, *wasm_metering_config.identifier()); + #[cfg(not(feature = "moka"))] + { + if let Some(cached) = self.cache.borrow_mut().get(&cache_key) { + return InstrumentedCode { + code: cached.clone(), + code_hash, + }; + } + } + #[cfg(feature = "moka")] if let Some(cached) = self.cache.get(&cache_key) { return InstrumentedCode { code: cached.clone(), @@ -60,6 +77,11 @@ impl WasmInstrumenter { let instrumented_ref = Arc::new(self.instrument_no_cache(code, wasm_metering_config)); + #[cfg(not(feature = "moka"))] + self.cache + .borrow_mut() + .put(cache_key, instrumented_ref.clone()); + #[cfg(feature = "moka")] self.cache.insert(cache_key, instrumented_ref.clone()); InstrumentedCode { diff --git a/radix-engine/src/wasm/wasmer.rs b/radix-engine/src/wasm/wasmer.rs index 739b844d99c..87b8284f450 100644 --- a/radix-engine/src/wasm/wasmer.rs +++ b/radix-engine/src/wasm/wasmer.rs @@ -1,8 +1,6 @@ -use std::sync::{Arc, Mutex}; - use crate::model::InvokeError; -use moka::sync::Cache; use radix_engine_interface::data::IndexedScryptoValue; +use sbor::rust::sync::{Arc, Mutex}; use wasmer::{ imports, Function, HostEnvInitError, Instance, LazyInit, Module, RuntimeError, Store, Universal, Val, WasmerEnv, @@ -18,6 +16,7 @@ use super::InstrumentedCode; pub struct WasmerModule { module: Module, + #[allow(dead_code)] code_size_bytes: usize, } @@ -37,7 +36,10 @@ pub struct WasmerInstanceEnv { pub struct WasmerEngine { store: Store, - modules_cache: Cache>, + #[cfg(not(feature = "moka"))] + modules_cache: RefCell>>, + #[cfg(feature = "moka")] + modules_cache: moka::sync::Cache>, } pub fn send_value(instance: &Instance, value: &[u8]) -> Result> { @@ -222,7 +224,7 @@ impl WasmInstance for WasmerInstance { #[derive(Debug, Clone)] pub struct EngineOptions { - max_cache_size_bytes: u64, + max_cache_size_bytes: usize, } impl Default for WasmerEngine { @@ -236,12 +238,17 @@ impl Default for WasmerEngine { impl WasmerEngine { pub fn new(options: EngineOptions) -> Self { let compiler = Singlepass::new(); - let modules_cache = Cache::builder() + #[cfg(not(feature = "moka"))] + let modules_cache = RefCell::new(lru::LruCache::new( + NonZeroUsize::new(options.max_cache_size_bytes / (1024 * 1024)).unwrap(), + )); + #[cfg(feature = "moka")] + let modules_cache = moka::sync::Cache::builder() .weigher(|_key: &Hash, value: &Arc| -> u32 { // Approximate the module entry size by the code size value.code_size_bytes.try_into().unwrap_or(u32::MAX) }) - .max_capacity(options.max_cache_size_bytes) + .max_capacity(options.max_cache_size_bytes as u64) .build(); Self { store: Store::new(&Universal::new(compiler).engine()), @@ -255,6 +262,13 @@ impl WasmEngine for WasmerEngine { fn instantiate(&self, instrumented_code: &InstrumentedCode) -> WasmerInstance { let code_hash = &instrumented_code.code_hash; + #[cfg(not(feature = "moka"))] + { + if let Some(cached_module) = self.modules_cache.borrow_mut().get(code_hash) { + return cached_module.instantiate(); + } + } + #[cfg(feature = "moka")] if let Some(cached_module) = self.modules_cache.get(code_hash) { return cached_module.instantiate(); } @@ -266,6 +280,11 @@ impl WasmEngine for WasmerEngine { code_size_bytes: code.len(), }); + #[cfg(not(feature = "moka"))] + self.modules_cache + .borrow_mut() + .put(*code_hash, new_module.clone()); + #[cfg(feature = "moka")] self.modules_cache.insert(*code_hash, new_module.clone()); new_module.instantiate() diff --git a/radix-engine/src/wasm/wasmi.rs b/radix-engine/src/wasm/wasmi.rs index dabaaff90c2..0ed51eafc74 100644 --- a/radix-engine/src/wasm/wasmi.rs +++ b/radix-engine/src/wasm/wasmi.rs @@ -1,11 +1,10 @@ -use moka::sync::Cache; use radix_engine_interface::crypto::Hash; use radix_engine_interface::data::IndexedScryptoValue; -use std::sync::Arc; +use sbor::rust::sync::Arc; use wasmi::*; use crate::model::InvokeError; -use crate::types::{format, Box}; +use crate::types::*; use crate::wasm::constants::*; use crate::wasm::errors::*; use crate::wasm::traits::*; @@ -14,6 +13,7 @@ use super::InstrumentedCode; pub struct WasmiModule { module: Module, + #[allow(dead_code)] code_size_bytes: usize, } @@ -30,7 +30,11 @@ pub struct WasmiExternals<'a, 'b, 'r> { pub struct WasmiEnvModule {} impl ModuleImportResolver for WasmiEnvModule { - fn resolve_func(&self, field_name: &str, signature: &Signature) -> Result { + fn resolve_func( + &self, + field_name: &str, + signature: &wasmi::Signature, + ) -> Result { match field_name { RADIX_ENGINE_FUNCTION_NAME => { if signature.params() != [ValueType::I32] @@ -211,11 +215,14 @@ impl WasmInstance for WasmiInstance { #[derive(Debug, Clone)] pub struct EngineOptions { - max_cache_size_bytes: u64, + max_cache_size_bytes: usize, } pub struct WasmiEngine { - modules_cache: Cache>, + #[cfg(not(feature = "moka"))] + modules_cache: RefCell>>, + #[cfg(feature = "moka")] + modules_cache: moka::sync::Cache>, } impl Default for WasmiEngine { @@ -228,16 +235,19 @@ impl Default for WasmiEngine { impl WasmiEngine { pub fn new(options: EngineOptions) -> Self { - let cache = Cache::builder() + #[cfg(not(feature = "moka"))] + let modules_cache = RefCell::new(lru::LruCache::new( + NonZeroUsize::new(options.max_cache_size_bytes / (1024 * 1024)).unwrap(), + )); + #[cfg(feature = "moka")] + let modules_cache = moka::sync::Cache::builder() .weigher(|_key: &Hash, value: &Arc| -> u32 { // Approximate the module entry size by the code size value.code_size_bytes.try_into().unwrap_or(u32::MAX) }) - .max_capacity(options.max_cache_size_bytes) + .max_capacity(options.max_cache_size_bytes as u64) .build(); - Self { - modules_cache: cache, - } + Self { modules_cache } } } @@ -246,6 +256,14 @@ impl WasmEngine for WasmiEngine { fn instantiate(&self, instrumented_code: &InstrumentedCode) -> WasmiInstance { let code_hash = &instrumented_code.code_hash; + + #[cfg(not(feature = "moka"))] + { + if let Some(cached_module) = self.modules_cache.borrow_mut().get(code_hash) { + return cached_module.instantiate(); + } + } + #[cfg(feature = "moka")] if let Some(cached_module) = self.modules_cache.get(code_hash) { return cached_module.instantiate(); } @@ -257,6 +275,11 @@ impl WasmEngine for WasmiEngine { code_size_bytes: code.len(), }); + #[cfg(not(feature = "moka"))] + self.modules_cache + .borrow_mut() + .put(*code_hash, new_module.clone()); + #[cfg(feature = "moka")] self.modules_cache.insert(*code_hash, new_module.clone()); new_module.instantiate() diff --git a/radix-engine/tests/blueprints/kv_store/src/cyclic_map.rs b/radix-engine/tests/blueprints/kv_store/src/cyclic_map.rs index 32f0ddd6aa9..3d66ebabd54 100644 --- a/radix-engine/tests/blueprints/kv_store/src/cyclic_map.rs +++ b/radix-engine/tests/blueprints/kv_store/src/cyclic_map.rs @@ -1,8 +1,8 @@ use radix_engine_interface::api::types::*; use radix_engine_interface::api::wasm_input::*; +use sbor::rust::marker::PhantomData; use scrypto::engine::scrypto_env::*; use scrypto::prelude::*; -use std::marker::PhantomData; blueprint! { struct CyclicMap { diff --git a/radix-engine/tests/execution_trace.rs b/radix-engine/tests/execution_trace.rs index 197985bbceb..ae5cbe3448c 100644 --- a/radix-engine/tests/execution_trace.rs +++ b/radix-engine/tests/execution_trace.rs @@ -6,8 +6,8 @@ use radix_engine_interface::api::types::NativeMethod; use radix_engine_interface::core::NetworkDefinition; use radix_engine_interface::data::*; use radix_engine_interface::model::FromPublicKey; +use sbor::rust::ops::Add; use scrypto_unit::*; -use std::ops::Add; use transaction::builder::ManifestBuilder; #[test] diff --git a/sbor/src/rust.rs b/sbor/src/rust.rs index fceb35164d3..2b41cd42345 100644 --- a/sbor/src/rust.rs +++ b/sbor/src/rust.rs @@ -15,6 +15,8 @@ pub use alloc::str; #[cfg(feature = "alloc")] pub use alloc::string; #[cfg(feature = "alloc")] +pub use alloc::sync; +#[cfg(feature = "alloc")] pub use alloc::vec; #[cfg(feature = "alloc")] pub use core::cell; @@ -31,6 +33,8 @@ pub use core::marker; #[cfg(feature = "alloc")] pub use core::mem; #[cfg(feature = "alloc")] +pub use core::num; +#[cfg(feature = "alloc")] pub use core::ops; #[cfg(feature = "alloc")] pub use core::ptr; @@ -60,6 +64,8 @@ pub use std::marker; #[cfg(not(feature = "alloc"))] pub use std::mem; #[cfg(not(feature = "alloc"))] +pub use std::num; +#[cfg(not(feature = "alloc"))] pub use std::ops; #[cfg(not(feature = "alloc"))] pub use std::ptr; @@ -72,6 +78,8 @@ pub use std::str; #[cfg(not(feature = "alloc"))] pub use std::string; #[cfg(not(feature = "alloc"))] +pub use std::sync; +#[cfg(not(feature = "alloc"))] pub use std::vec; /// Collection types. diff --git a/scrypto-unit/Cargo.toml b/scrypto-unit/Cargo.toml index 9edcea11204..14196192526 100644 --- a/scrypto-unit/Cargo.toml +++ b/scrypto-unit/Cargo.toml @@ -4,7 +4,7 @@ version = "0.7.0" edition = "2021" [dependencies] -radix-engine = { path = "../radix-engine" } +radix-engine = { path = "../radix-engine", default-features = false } radix-engine-interface = { path = "../radix-engine-interface", default-features = false } radix-engine-constants = { path = "../radix-engine-constants" } transaction = { path = "../transaction", default-features = false } @@ -17,5 +17,5 @@ wabt = { version = "0.10.0" } [features] default = ["std"] -std = ["scrypto/std", "scrypto/serde", "sbor/std"] -alloc = ["scrypto/alloc", "scrypto/serde", "sbor/alloc"] \ No newline at end of file +std = ["scrypto/std", "scrypto/serde", "sbor/std", "radix-engine-interface/std", "radix-engine/std", "transaction/std", "utils/std"] +alloc = ["scrypto/alloc", "scrypto/serde", "sbor/alloc", "radix-engine-interface/alloc", "radix-engine/alloc", "transaction/alloc","utils/alloc"] \ No newline at end of file diff --git a/scrypto/Cargo.toml b/scrypto/Cargo.toml index 9a54f9a2350..961eb2b224e 100644 --- a/scrypto/Cargo.toml +++ b/scrypto/Cargo.toml @@ -24,8 +24,8 @@ strum = { version = "0.24", default-features = false, features = ["derive"] } [features] # You should enable either `std` or `alloc` default = ["std", "prelude"] -std = ["hex/std", "sbor/std", "scrypto-abi/std", "scrypto-derive/std", "strum/std", "utils/std", "radix-engine-interface/std"] -alloc = ["hex/alloc", "sbor/alloc", "scrypto-abi/alloc", "scrypto-derive/alloc", "utils/alloc", "radix-engine-interface/alloc"] +std = ["hex/std", "sbor/std", "scrypto-abi/std", "scrypto-derive/std", "strum/std", "utils/std", "radix-engine-interface/std", "radix-engine-derive/std", "utils/std"] +alloc = ["hex/alloc", "sbor/alloc", "scrypto-abi/alloc", "scrypto-derive/alloc", "utils/alloc", "radix-engine-interface/alloc", "radix-engine-derive/alloc", "utils/alloc"] # Turn on this feature to enable tracing. trace = ["scrypto-derive/trace"] diff --git a/simulator/Cargo.lock b/simulator/Cargo.lock index 231b9fd56be..cfedea8c0af 100644 --- a/simulator/Cargo.lock +++ b/simulator/Cargo.lock @@ -165,9 +165,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" dependencies = [ "jobserver", ] @@ -189,9 +189,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", "num-integer", @@ -298,9 +298,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" +checksum = "96bf8df95e795db1a4aca2957ad884a2df35413b24bbeb3114422f3cc21498e8" dependencies = [ "autocfg", "cfg-if", @@ -311,9 +311,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" +checksum = "422f23e724af1240ec469ea1e834d87a4b59ce2efe2c6a96256b0c47e2fd86aa" dependencies = [ "cfg-if", ] @@ -343,9 +343,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" dependencies = [ "cc", "cxxbridge-flags", @@ -355,9 +355,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" dependencies = [ "cc", "codespan-reporting", @@ -370,15 +370,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" +checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" [[package]] name = "cxxbridge-macro" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" dependencies = [ "proc-macro2", "quote", @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", "crypto-common", @@ -588,9 +588,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.51" +version = "0.1.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -618,9 +618,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", "hashbrown", @@ -662,9 +662,12 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" @@ -686,9 +689,9 @@ checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -696,9 +699,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "librocksdb-sys" @@ -754,6 +757,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" + [[package]] name = "memchr" version = "2.5.0" @@ -762,9 +771,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memoffset" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] @@ -783,9 +792,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "moka" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8256cf9fa396576521e5e94affadb95818ec48f5dbedca36714387688aea29" +checksum = "7b49a05f67020456541f4f29cbaa812016a266a86ec76f96d3873d459c68fe5e" dependencies = [ "crossbeam-channel", "crossbeam-epoch", @@ -793,6 +802,7 @@ dependencies = [ "num_cpus", "once_cell", "parking_lot", + "rustc_version", "scheduled-thread-pool", "skeptic", "smallvec", @@ -856,28 +866,19 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" dependencies = [ "hermit-abi", "libc", ] -[[package]] -name = "num_threads" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" -dependencies = [ - "libc", -] - [[package]] name = "once_cell" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "opaque-debug" @@ -887,9 +888,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "os_str_bytes" -version = "6.3.0" +version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "parity-wasm" @@ -940,9 +941,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-error" @@ -1005,6 +1006,7 @@ dependencies = [ "colored", "hex", "indexmap", + "lru", "moka", "parity-wasm", "radix-engine-constants", @@ -1030,8 +1032,6 @@ dependencies = [ "quote", "sbor", "scrypto-abi", - "serde", - "serde_json", "syn", "uuid", ] @@ -1158,9 +1158,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -1169,9 +1169,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "remove_dir_all" @@ -1198,6 +1198,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustversion" version = "1.0.9" @@ -1352,9 +1361,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "8e8b3801309262e8184d9687fb697586833e939767aea0dda89f5a8e650e8bd7" dependencies = [ "itoa", "ryu", @@ -1363,9 +1372,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368f2d60d049ea019a84dcd6687b0d1e0030fe663ae105039bdf967ed5e6a9a7" +checksum = "25bf4a5a814902cd1014dbccfa4d4560fb8432c779471e96e035602519f82eef" dependencies = [ "base64", "chrono", @@ -1379,9 +1388,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ccadfacf6cf10faad22bbadf55986bdd0856edfb5d9210aa1dcf1f516e84e93" +checksum = "e3452b4c0f6c1e357f73fdb87cd1efabaa12acf328c7a528e252893baeb3f4aa" dependencies = [ "darling", "proc-macro2", @@ -1410,7 +1419,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -1419,7 +1428,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", "keccak", ] @@ -1604,13 +1613,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ "itoa", - "libc", - "num_threads", "serde", "time-core", "time-macros", @@ -1624,9 +1631,9 @@ checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" [[package]] name = "time-macros" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bb801831d812c562ae7d2bfb531f26e66e4e1f6b17307ba4149c5064710e5b" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" dependencies = [ "time-core", ] @@ -1698,25 +1705,14 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" name = "utils" version = "0.7.0" dependencies = [ - "bech32", - "forward_ref", - "hex", - "num-bigint", - "num-traits", - "paste", "sbor", - "scrypto-abi", - "scrypto-derive", - "sha2 0.10.6", - "sha3", - "strum", ] [[package]] name = "uuid" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" dependencies = [ "getrandom 0.2.8", ] diff --git a/test.sh b/test.sh index a22c704b5ed..e21ee85a4d7 100755 --- a/test.sh +++ b/test.sh @@ -26,6 +26,8 @@ echo "Testing with no_std..." (cd scrypto; cargo test --no-default-features --features alloc,prelude --release) (cd scrypto-abi; cargo test --no-default-features --features alloc) (cd scrypto-tests; cargo test --no-default-features --features alloc) +(cd radix-engine; cargo test --no-default-features --features alloc) + echo "Building system packages and examples..." (cd assets/blueprints/account; scrypto test) diff --git a/transaction/Cargo.toml b/transaction/Cargo.toml index 25c7d9b857f..733d2b2e12b 100644 --- a/transaction/Cargo.toml +++ b/transaction/Cargo.toml @@ -18,6 +18,6 @@ serde_with = { version = "2.0.1" } [features] # You should enable either `std` or `alloc` default = ["std"] -std = ["sbor/std", "scrypto/std", "hex/std", "ed25519-dalek/std", "secp256k1/std"] -alloc = ["sbor/alloc", "scrypto/alloc", "hex/alloc", "ed25519-dalek/alloc", "secp256k1/alloc"] +std = ["sbor/std", "radix-engine-interface/std", "scrypto/std", "hex/std", "ed25519-dalek/std", "secp256k1/std", "utils/std"] +alloc = ["sbor/alloc", "radix-engine-interface/alloc", "scrypto/alloc", "hex/alloc", "ed25519-dalek/alloc", "secp256k1/alloc", "utils/alloc"] serde = ["serde/derive", "scrypto/serde"] \ No newline at end of file diff --git a/utils/Cargo.toml b/utils/Cargo.toml index be604a5dadc..bc008d74a06 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -4,35 +4,9 @@ version = "0.7.0" edition = "2021" [dependencies] -sha2 = { version = "0.10.2", default-features = false } -sha3 = { version = "0.10.1", default-features = false } -hex = { version = "0.4.3", default-features = false } -num-traits = { version = "0.2.15", default-features = false } -num-bigint = { version = "0.4.3", default-features = false } -bech32 = { version = "0.9.0", default-features = false } sbor = { path = "../sbor", default-features = false } -scrypto-abi = { path = "../scrypto-abi", default-features = false } -scrypto-derive = { path = "../scrypto-derive", default-features = false } -forward_ref = { version = "1.0.0"} -paste = { version = "1.0.7"} -serde = { version = "1.0.144", default-features = false, optional = true } -strum = { version = "0.24", default-features = false, features = ["derive"] } [features] -# You should enable either `std` or `alloc` -default = ["std", "prelude"] -std = ["hex/std", "sbor/std", "scrypto-abi/std", "scrypto-derive/std", "strum/std"] -alloc = ["hex/alloc", "sbor/alloc", "scrypto-abi/alloc", "scrypto-derive/alloc"] - -# Turn on this feature to enable tracing. -trace = ["scrypto-derive/trace"] - -# Enable serde derives -serde = ["sbor/serde", "scrypto-abi/serde", "serde/derive"] - -# Enable prelude. -# Note that prelude introduces duplicated symbols which may confuse rustc suggestions. -prelude = [] - -# Disable ABI gen in the output WASM. -no-abi-gen = ["scrypto-derive/no-abi-gen"] +default = ["std"] +std = ["sbor/std"] +alloc = ["sbor/alloc"]