From 703ef1c9f6ff38d5270fe57d485cc7048934f673 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Mon, 3 Feb 2025 16:54:04 +0900 Subject: [PATCH] print warning when cache size is smaller than module or script size --- crates/storage/src/module_cache.rs | 15 +++++++++++++++ crates/storage/src/script_cache.rs | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/storage/src/module_cache.rs b/crates/storage/src/module_cache.rs index d1cf6c96..4a94aac7 100644 --- a/crates/storage/src/module_cache.rs +++ b/crates/storage/src/module_cache.rs @@ -81,6 +81,11 @@ impl InitiaModuleCache { ) -> VMResult<()> { // cache is too small to hold this module if self.capacity < allocated_size { + eprintln!( + "Module cache is too small to hold module with size {}", + allocated_size + ); + return Ok(()); } @@ -128,6 +133,11 @@ impl InitiaModuleCache { module_cache .put_with_weight(key, ModuleWrapper::new(module.clone(), allocated_size)) .unwrap_or_else(|_| None); + } else { + eprintln!( + "Module cache is too small to hold module with size {}", + allocated_size + ); } Ok(module) @@ -170,6 +180,11 @@ impl InitiaModuleCache { module_cache .put_with_weight(*checksum, code_wrapper.clone()) .unwrap_or_else(|_| None); + } else { + eprintln!( + "Module cache is too small to hold module with size {}", + allocated_size + ); } Some(code_wrapper) diff --git a/crates/storage/src/script_cache.rs b/crates/storage/src/script_cache.rs index 2c7f4f9b..e7ee9d94 100644 --- a/crates/storage/src/script_cache.rs +++ b/crates/storage/src/script_cache.rs @@ -50,6 +50,11 @@ impl InitiaScriptCache { let _ = script_cache .put_with_weight(key, ScriptWrapper::new(new_script, allocated_size)) .unwrap_or_else(|_| None); + } else { + eprintln!( + "Script cache is too small to hold module with size {}", + allocated_size + ); } Ok(deserialized_script) @@ -89,6 +94,11 @@ impl InitiaScriptCache { let _ = script_cache .put_with_weight(key, ScriptWrapper::new(new_script, allocated_size)) .unwrap_or_else(|_| None); + } else { + eprintln!( + "Script cache is too small to hold module with size {}", + allocated_size + ); } } Ok(verified_script)