Skip to content

Commit

Permalink
Remove print_debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Nov 17, 2023
1 parent 86ddd8a commit d15f184
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 39 deletions.
4 changes: 0 additions & 4 deletions packages/vm/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const DEFAULT_MEMORY_LIMIT: Size = Size::mebi(64);
const DEFAULT_GAS_LIMIT: u64 = 1_000_000_000; // ~1ms
const DEFAULT_INSTANCE_OPTIONS: InstanceOptions = InstanceOptions {
gas_limit: DEFAULT_GAS_LIMIT,
print_debug: false,
};
const HIGH_GAS_LIMIT: u64 = 20_000_000_000_000; // ~20s, allows many calls on one instance

Expand Down Expand Up @@ -50,7 +49,6 @@ fn bench_instance(c: &mut Criterion) {
let backend = mock_backend(&[]);
let much_gas: InstanceOptions = InstanceOptions {
gas_limit: HIGH_GAS_LIMIT,
..DEFAULT_INSTANCE_OPTIONS
};
let mut instance =
Instance::from_code(CONTRACT, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();
Expand All @@ -68,7 +66,6 @@ fn bench_instance(c: &mut Criterion) {
let backend = mock_backend(&[]);
let much_gas: InstanceOptions = InstanceOptions {
gas_limit: HIGH_GAS_LIMIT,
..DEFAULT_INSTANCE_OPTIONS
};
let mut instance =
Instance::from_code(CONTRACT, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();
Expand All @@ -92,7 +89,6 @@ fn bench_instance(c: &mut Criterion) {
let backend = mock_backend(&[]);
let much_gas: InstanceOptions = InstanceOptions {
gas_limit: HIGH_GAS_LIMIT,
..DEFAULT_INSTANCE_OPTIONS
};
let mut instance =
Instance::from_code(CYBERPUNK, backend, much_gas, Some(DEFAULT_MEMORY_LIMIT)).unwrap();
Expand Down
1 change: 0 additions & 1 deletion packages/vm/examples/multi_threaded_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const DEFAULT_MEMORY_LIMIT: Size = Size::mebi(64);
const DEFAULT_GAS_LIMIT: u64 = 400_000 * 150;
const DEFAULT_INSTANCE_OPTIONS: InstanceOptions = InstanceOptions {
gas_limit: DEFAULT_GAS_LIMIT,
print_debug: false,
};
// Cache
const MEMORY_CACHE_SIZE: Size = Size::mebi(200);
Expand Down
8 changes: 1 addition & 7 deletions packages/vm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ where
&cached.module,
backend,
options.gas_limit,
options.print_debug,
None,
Some(&self.instantiation_lock),
)?;
Expand Down Expand Up @@ -532,7 +531,6 @@ mod tests {
const TESTING_MEMORY_LIMIT: Size = Size::mebi(16);
const TESTING_OPTIONS: InstanceOptions = InstanceOptions {
gas_limit: TESTING_GAS_LIMIT,
print_debug: false,
};
const TESTING_MEMORY_CACHE_SIZE: Size = Size::mebi(200);

Expand Down Expand Up @@ -1180,10 +1178,7 @@ mod tests {
let backend2 = mock_backend(&[]);

// Init from module cache
let options = InstanceOptions {
gas_limit: 10,
print_debug: false,
};
let options = InstanceOptions { gas_limit: 10 };
let mut instance1 = cache.get_instance(&checksum, backend1, options).unwrap();
assert_eq!(cache.stats().hits_fs_cache, 1);
assert_eq!(cache.stats().misses, 0);
Expand All @@ -1202,7 +1197,6 @@ mod tests {
// Init from memory cache
let options = InstanceOptions {
gas_limit: TESTING_GAS_LIMIT,
print_debug: false,
};
let mut instance2 = cache.get_instance(&checksum, backend2, options).unwrap();
assert_eq!(cache.stats().hits_pinned_memory_cache, 0);
Expand Down
24 changes: 2 additions & 22 deletions packages/vm/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub struct GasReport {
pub struct InstanceOptions {
/// Gas limit measured in [CosmWasm gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).
pub gas_limit: u64,
pub print_debug: bool,
}

pub struct Instance<A: BackendApi, S: Storage, Q: Querier> {
Expand Down Expand Up @@ -74,15 +73,7 @@ where
let engine = make_compiling_engine(memory_limit);
let module = compile(&engine, code)?;
let store = Store::new(engine);
Instance::from_module(
store,
&module,
backend,
options.gas_limit,
options.print_debug,
None,
None,
)
Instance::from_module(store, &module, backend, options.gas_limit, None, None)
}

#[allow(clippy::too_many_arguments)]
Expand All @@ -91,7 +82,6 @@ where
module: &Module,
backend: Backend<A, S, Q>,
gas_limit: u64,
print_debug: bool,
extra_imports: Option<HashMap<&str, Exports>>,
instantiation_lock: Option<&Mutex<()>>,
) -> VmResult<Self> {
Expand Down Expand Up @@ -470,23 +460,14 @@ pub fn instance_from_module<A, S, Q>(
module: &Module,
backend: Backend<A, S, Q>,
gas_limit: u64,
print_debug: bool,
extra_imports: Option<HashMap<&str, Exports>>,
) -> VmResult<Instance<A, S, Q>>
where
A: BackendApi + 'static, // 'static is needed here to allow copying API instances into closures
S: Storage + 'static, // 'static is needed here to allow using this in an Environment that is cloned into closures
Q: Querier + 'static,
{
Instance::from_module(
store,
module,
backend,
gas_limit,
print_debug,
extra_imports,
None,
)
Instance::from_module(store, module, backend, gas_limit, extra_imports, None)
}

#[cfg(test)]
Expand Down Expand Up @@ -645,7 +626,6 @@ mod tests {
&module,
backend,
instance_options.gas_limit,
false,
Some(extra_imports),
None,
)
Expand Down
5 changes: 0 additions & 5 deletions packages/vm/src/testing/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use super::storage::MockStorage;
/// higher than the limit for a single execution that we have in the production setup.
const DEFAULT_GAS_LIMIT: u64 = 500_000_000; // ~0.5ms
const DEFAULT_MEMORY_LIMIT: Option<Size> = Some(Size::mebi(16));
const DEFAULT_PRINT_DEBUG: bool = true;

pub fn mock_instance(
wasm: &[u8],
Expand Down Expand Up @@ -90,7 +89,6 @@ pub struct MockInstanceOptions<'a> {
pub available_capabilities: HashSet<String>,
/// Gas limit measured in [CosmWasm gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).
pub gas_limit: u64,
pub print_debug: bool,
/// Memory limit in bytes. Use a value that is divisible by the Wasm page size 65536, e.g. full MiBs.
pub memory_limit: Option<Size>,
}
Expand Down Expand Up @@ -118,7 +116,6 @@ impl Default for MockInstanceOptions<'_> {
// instance
available_capabilities: Self::default_capabilities(),
gas_limit: DEFAULT_GAS_LIMIT,
print_debug: DEFAULT_PRINT_DEBUG,
memory_limit: DEFAULT_MEMORY_LIMIT,
}
}
Expand Down Expand Up @@ -155,7 +152,6 @@ pub fn mock_instance_with_options(
let memory_limit = options.memory_limit;
let options = InstanceOptions {
gas_limit: options.gas_limit,
print_debug: options.print_debug,
};
Instance::from_code(wasm, backend, options, memory_limit).unwrap()
}
Expand All @@ -165,7 +161,6 @@ pub fn mock_instance_options() -> (InstanceOptions, Option<Size>) {
(
InstanceOptions {
gas_limit: DEFAULT_GAS_LIMIT,
print_debug: DEFAULT_PRINT_DEBUG,
},
DEFAULT_MEMORY_LIMIT,
)
Expand Down

0 comments on commit d15f184

Please sign in to comment.