diff --git a/core/store/src/lib.rs b/core/store/src/lib.rs index 22b5111acdc..8cd96e8c7aa 100644 --- a/core/store/src/lib.rs +++ b/core/store/src/lib.rs @@ -893,6 +893,13 @@ impl StoreCompiledContractCache { /// Key must take into account VM being used and its configuration, so that /// we don't cache non-gas metered binaries, for example. impl CompiledContractCache for StoreCompiledContractCache { + #[tracing::instrument( + level = "trace", + target = "store", + "StoreCompiledContractCache::put", + skip_all, + fields(key = key.to_string(), value.len = value.debug_len()), + )] fn put(&self, key: &CryptoHash, value: CompiledContract) -> io::Result<()> { let mut update = crate::db::DBTransaction::new(); // We intentionally use `.set` here, rather than `.insert`. We don't yet @@ -907,6 +914,13 @@ impl CompiledContractCache for StoreCompiledContractCache { self.db.write(update) } + #[tracing::instrument( + level = "trace", + target = "store", + "StoreCompiledContractCache::get", + skip_all, + fields(key = key.to_string()), + )] fn get(&self, key: &CryptoHash) -> io::Result> { match self.db.get_raw_bytes(DBCol::CachedContractCode, key.as_ref()) { Ok(Some(bytes)) => Ok(Some(CompiledContract::try_from_slice(&bytes)?)), diff --git a/runtime/near-vm-runner/src/logic/mod.rs b/runtime/near-vm-runner/src/logic/mod.rs index d977834cad1..f1b6ac68813 100644 --- a/runtime/near-vm-runner/src/logic/mod.rs +++ b/runtime/near-vm-runner/src/logic/mod.rs @@ -32,6 +32,18 @@ pub enum CompiledContract { Code(Vec), } +impl CompiledContract { + /// Return the length of the compiled contract data. + /// + /// If the `CompiledContract` represents a compilation failure, returns `0`. + pub fn debug_len(&self) -> usize { + match self { + CompiledContract::CompileModuleError(_) => 0, + CompiledContract::Code(c) => c.len(), + } + } +} + /// Cache for compiled modules pub trait CompiledContractCache: Send + Sync { fn put(&self, key: &CryptoHash, value: CompiledContract) -> std::io::Result<()>;