Skip to content

Commit 9172e41

Browse files
starknet_os: refactor nondet hint IsReverted (#11122)
1 parent 82800e3 commit 9172e41

File tree

6 files changed

+20
-13
lines changed

6 files changed

+20
-13
lines changed

crates/apollo_starknet_os_program/src/cairo/starkware/starknet/core/os/execution/execute_transactions.cairo

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ func execute_invoke_function_transaction{
479479
execution_context=tx_execution_context
480480
);
481481

482-
if (nondet %{ execution_helper.tx_execution_info.is_reverted %} == FALSE) {
482+
local is_reverted;
483+
%{ IsReverted %}
484+
if (is_reverted == FALSE) {
483485
// Execute only non-reverted transactions.
484486
with remaining_gas {
485487
cap_remaining_gas(max_gas=EXECUTE_MAX_SIERRA_GAS);
@@ -522,8 +524,10 @@ func execute_l1_handler_transaction{
522524
alloc_locals;
523525

524526
%{ StartTx %}
527+
local is_reverted;
528+
%{ IsReverted %}
525529
// Skip the execution step for reverted transaction.
526-
if (nondet %{ execution_helper.tx_execution_info.is_reverted %} != FALSE) {
530+
if (is_reverted != FALSE) {
527531
%{ EndTx %}
528532
return ();
529533
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"os": "0x4567945373ae6aaacb9693b027795ef43d298e313a720e127ba2e4f7098b193",
3-
"virtual_os": "0x1824f5cc61f95707596b6a189ff174e283dd101a79628f82b80ed3bce740f2c",
2+
"os": "0x2cea6229ce04c350f1a56f359f0a700efa077d45cef3646d9f6643078d4e8f4",
3+
"virtual_os": "0x32c2f13056b9125a20d30c94921e56e25243968ce4ad7a11373ca3996384272",
44
"aggregator": "0x5757cea9a318eac0cb302b71e8fd14552074bab56932641e748094654a62aaa",
55
"aggregator_with_prefix": "0x5513f3b2381c0e7a0ab8e70add986be3dffd8413356f8df4e941bf3bfe572b3"
66
}

crates/starknet_os/src/hints/enum_definition.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,18 +675,14 @@ define_hint_enum!(
675675
(TxAccountDeploymentData, tx_account_deployment_data),
676676
(TxProofFacts, tx_proof_facts),
677677
(GenSignatureArg, gen_signature_arg),
678-
(
679-
IsReverted,
680-
is_reverted,
681-
"memory[ap] = to_felt_or_relocatable(execution_helper.tx_execution_info.is_reverted)"
682-
),
678+
(IsReverted, is_reverted),
683679
(CheckExecutionAndExitCall, check_execution_and_exit_call),
684680
(CheckSyscallResponse, check_syscall_response),
685681
(CheckNewCallContractResponse, check_new_call_contract_response),
686682
(CheckNewDeployResponse, check_new_deploy_response),
687683
(LogEnterSyscall, log_enter_syscall),
688684
(SetApToTxNonce, set_ap_to_tx_nonce, "memory[ap] = to_felt_or_relocatable(tx.nonce)"),
689-
(SetFpToTxNonce, set_fp_to_tx_nonce, "memory[fp + 5] = to_felt_or_relocatable(tx.nonce)"),
685+
(SetFpToTxNonce, set_fp_to_tx_nonce, "memory[fp + 6] = to_felt_or_relocatable(tx.nonce)"),
690686
(WriteSyscallResultDeprecated, write_syscall_result_deprecated),
691687
(WriteSyscallResult, write_syscall_result),
692688
(DeclareTxFields, declare_tx_fields),

crates/starknet_os/src/hints/hint_implementation/execution/implementation.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub(crate) fn gen_signature_arg<S: StateReader>(
541541

542542
pub(crate) fn is_reverted<S: StateReader>(
543543
hint_processor: &mut SnosHintProcessor<'_, S>,
544-
HintArgs { vm, .. }: HintArgs<'_>,
544+
HintArgs { vm, ids_data, ap_tracking, .. }: HintArgs<'_>,
545545
) -> OsHintResult {
546546
let is_reverted = hint_processor
547547
.execution_helpers_manager
@@ -550,7 +550,13 @@ pub(crate) fn is_reverted<S: StateReader>(
550550
.get_tx_execution_info_ref()?
551551
.tx_execution_info
552552
.is_reverted();
553-
insert_value_into_ap(vm, Felt::from(is_reverted))?;
553+
insert_value_from_var_name(
554+
Ids::IsReverted.into(),
555+
Felt::from(is_reverted),
556+
vm,
557+
ids_data,
558+
ap_tracking,
559+
)?;
554560
Ok(())
555561
}
556562

crates/starknet_os/src/hints/nondet_offsets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod test;
1919
/// implementation should be fetched from this map.
2020
pub(crate) static NONDET_FP_OFFSETS: LazyLock<HashMap<AllHints, usize>> = LazyLock::new(|| {
2121
HashMap::from([
22-
(AllHints::OsHint(OsHint::SetFpToTxNonce), 5),
22+
(AllHints::OsHint(OsHint::SetFpToTxNonce), 6),
2323
(AllHints::OsHint(OsHint::GetBlocksNumber), 3),
2424
])
2525
});

crates/starknet_os/src/hints/vars.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ define_string_enum! {
209209
(IsNUpdatesSmall),
210210
(IsOnCurve),
211211
(IsRemainingGasLtInitialBudget),
212+
(IsReverted),
212213
(IsSierraGasMode),
213214
(Key),
214215
(KeyLtMinAliasAllocValue),

0 commit comments

Comments
 (0)