From fa568c4ed04e195e4d8835e173f4b81ee9905139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20IRMAK?= Date: Thu, 30 Nov 2023 13:49:10 +0300 Subject: [PATCH] Fix memory_holes showing up on trace API even tho it is 0 --- vm/rust/src/jsonrpc.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vm/rust/src/jsonrpc.rs b/vm/rust/src/jsonrpc.rs index 4ad3cfb840..a76a9d25aa 100644 --- a/vm/rust/src/jsonrpc.rs +++ b/vm/rust/src/jsonrpc.rs @@ -194,7 +194,8 @@ impl From for OrderedEvent { #[derive(Serialize)] pub struct ExecutionResources { pub steps: usize, - pub memory_holes: usize, + #[serde(skip_serializing_if = "Option::is_none")] + pub memory_holes: Option, #[serde(skip_serializing_if = "Option::is_none")] pub range_check_builtin_applications: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -219,7 +220,11 @@ impl From for ExecutionResources { fn from(val: VmExecutionResources) -> Self { ExecutionResources { steps: val.n_steps, - memory_holes: val.n_memory_holes, + memory_holes: if val.n_memory_holes > 0 { + Some(val.n_memory_holes) + } else { + None + }, range_check_builtin_applications: val.builtin_instance_counter.get(RANGE_CHECK_BUILTIN_NAME).cloned(), pedersen_builtin_applications: val.builtin_instance_counter.get(HASH_BUILTIN_NAME).cloned(), poseidon_builtin_applications: val.builtin_instance_counter.get(POSEIDON_BUILTIN_NAME).cloned(),