Skip to content

Commit 06a1a46

Browse files
feat(starknet_os): os_logger: implement OsLogger::enter_tx
1 parent 9ee1d28 commit 06a1a46

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

crates/starknet_os/src/hint_processor/os_logger.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ pub enum OsLoggerError {
4747
DoubleFinalize,
4848
#[error("Failed to fetch identifier data for struct {0}.")]
4949
InnerBuiltinPtrsIdentifierMissing(String),
50+
#[error("No transaction should call another transaction.")]
51+
InTxContext,
5052
#[error("{0}")]
5153
MissingBuiltinPtr(String),
5254
#[error("The `members` field is None in identifier data for struct {0}.")]
@@ -462,4 +464,32 @@ impl OsLogger {
462464

463465
Ok(())
464466
}
467+
468+
#[allow(clippy::too_many_arguments)]
469+
pub fn enter_tx(
470+
&mut self,
471+
tx_type: TransactionType,
472+
tx_hash: TransactionHash,
473+
n_steps: usize,
474+
range_check_ptr: Relocatable,
475+
ids_data: &HashMap<String, HintReference>,
476+
vm: &VirtualMachine,
477+
ap_tracking: &ApTracking,
478+
os_program: &Program,
479+
) -> OsLoggerResult<()> {
480+
if self.current_tx.is_some() {
481+
return Err(OsLoggerError::InTxContext);
482+
}
483+
self.resource_counter_stack.push(ResourceCounter::new(
484+
n_steps,
485+
range_check_ptr,
486+
ids_data,
487+
vm,
488+
ap_tracking,
489+
os_program,
490+
)?);
491+
self.current_tx = Some(OsTransactionTrace::new(tx_type, tx_hash));
492+
self.log(&format!("Entering {tx_type:?}: {tx_hash}."), true);
493+
Ok(())
494+
}
465495
}

0 commit comments

Comments
 (0)