From 08b17affaa577a0e7b274af051292c9ae3a7a538 Mon Sep 17 00:00:00 2001 From: fannyguthmann Date: Mon, 7 Aug 2023 14:38:27 +0300 Subject: [PATCH 1/2] Added comments to document-execute/os_usage.rs --- src/execution/os_usage.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/execution/os_usage.rs b/src/execution/os_usage.rs index 5e6b1aad7..56492a220 100644 --- a/src/execution/os_usage.rs +++ b/src/execution/os_usage.rs @@ -4,6 +4,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use crate::{definitions::transaction_type::TransactionType, transaction::error::TransactionError}; +/// Represents the operating system resources associated with syscalls and transactions. #[derive(Debug, Clone)] pub struct OsResources { execute_syscalls: HashMap, @@ -11,6 +12,7 @@ pub struct OsResources { } impl Default for OsResources { + /// Provide default values for `OsResources`. fn default() -> Self { let execute_txs_inner: HashMap = HashMap::from([ ( @@ -255,6 +257,18 @@ impl Default for OsResources { } } +/// Calculate the additional operating system resources required to execute a transaction +/// given a set of syscalls invoked and a transaction type. +/// +/// # Arguments +/// +/// * `syscall_counter` - A map that counts how many times each syscall was invoked. +/// * `tx_type` - The type of transaction to be executed. +/// +/// # Returns +/// +/// Returns the total execution resources required to process the transaction given +/// the syscalls invoked, or a `TransactionError` if there's an issue. pub fn get_additional_os_resources( syscall_counter: HashMap, tx_type: &TransactionType, @@ -283,6 +297,7 @@ pub fn get_additional_os_resources( Ok(additional_os_resources) } +/// Test for the `get_additional_os_resources` function. #[test] fn get_additional_os_resources_test() { let syscall_counter = HashMap::from([("storage_read".into(), 2), ("storage_write".into(), 3)]); From 1187b565e18d15c5bad41d1e60911e7a1980b1fb Mon Sep 17 00:00:00 2001 From: fannyguthmann Date: Mon, 7 Aug 2023 16:08:35 +0300 Subject: [PATCH 2/2] Added comments to document-execute/os_usage.rs --- src/execution/os_usage.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/execution/os_usage.rs b/src/execution/os_usage.rs index 56492a220..a7a70ae87 100644 --- a/src/execution/os_usage.rs +++ b/src/execution/os_usage.rs @@ -259,16 +259,6 @@ impl Default for OsResources { /// Calculate the additional operating system resources required to execute a transaction /// given a set of syscalls invoked and a transaction type. -/// -/// # Arguments -/// -/// * `syscall_counter` - A map that counts how many times each syscall was invoked. -/// * `tx_type` - The type of transaction to be executed. -/// -/// # Returns -/// -/// Returns the total execution resources required to process the transaction given -/// the syscalls invoked, or a `TransactionError` if there's an issue. pub fn get_additional_os_resources( syscall_counter: HashMap, tx_type: &TransactionType,