From 91d8b851692d4e45c7cf19ec914ef2627ca8b457 Mon Sep 17 00:00:00 2001 From: Philippe Laferriere Date: Wed, 20 Nov 2024 13:12:32 -0500 Subject: [PATCH] refactor: compile advice injectors down to `Operation::Emit` --- CHANGELOG.md | 1 + assembly/src/assembler/basic_block_builder.rs | 11 +-- assembly/src/assembler/instruction/adv_ops.rs | 5 +- .../src/assembler/instruction/crypto_ops.rs | 22 ++---- .../src/assembler/instruction/ext2_ops.rs | 8 +- .../src/assembler/instruction/field_ops.rs | 6 +- assembly/src/assembler/instruction/mod.rs | 18 ++--- assembly/src/assembler/instruction/u32_ops.rs | 20 ++--- core/src/operations/decorators/advice.rs | 78 +++++++++++++++++++ processor/src/lib.rs | 1 - processor/src/operations/sys_ops.rs | 61 ++++++++++++++- 11 files changed, 173 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f0b8f60d..d6919335c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - [BREAKING] `DYNCALL` operation fixed, and now expects a memory address pointing to the procedure hash (#1535). - Permit child `MastNodeId`s to exceed the `MastNodeId`s of their parents (#1542). - Don't validate export names on `Library` deserialization (#1554) +- Compile advice injectors down to `Emit` operations (#1581) #### Fixes diff --git a/assembly/src/assembler/basic_block_builder.rs b/assembly/src/assembler/basic_block_builder.rs index 3246484d2..85f886f97 100644 --- a/assembly/src/assembler/basic_block_builder.rs +++ b/assembly/src/assembler/basic_block_builder.rs @@ -93,6 +93,12 @@ impl BasicBlockBuilder<'_> { let new_len = self.ops.len() + n; self.ops.resize(new_len, op); } + + /// Converts the advice injector into its corresponding event ID, and adds an `Emit` operation + /// to the list of basic block operations. + pub fn push_advice_injector(&mut self, injector: AdviceInjector) { + self.push_op(Operation::Emit(injector.into_event_id())) + } } /// Decorators @@ -105,11 +111,6 @@ impl BasicBlockBuilder<'_> { Ok(()) } - /// Adds the specified advice injector to the list of basic block decorators. - pub fn push_advice_injector(&mut self, injector: AdviceInjector) -> Result<(), AssemblyError> { - self.push_decorator(Decorator::Advice(injector)) - } - /// Adds an AsmOp decorator to the list of basic block decorators. /// /// This indicates that the provided instruction should be tracked and the cycle count for diff --git a/assembly/src/assembler/instruction/adv_ops.rs b/assembly/src/assembler/instruction/adv_ops.rs index 86a38c1fa..049ace4e4 100644 --- a/assembly/src/assembler/instruction/adv_ops.rs +++ b/assembly/src/assembler/instruction/adv_ops.rs @@ -23,9 +23,6 @@ pub fn adv_push(block_builder: &mut BasicBlockBuilder, n: u8) -> Result<(), Asse // ================================================================================================ /// Appends advice injector decorator to the span. -pub fn adv_inject( - block_builder: &mut BasicBlockBuilder, - injector: &AdviceInjectorNode, -) -> Result<(), AssemblyError> { +pub fn adv_inject(block_builder: &mut BasicBlockBuilder, injector: &AdviceInjectorNode) { block_builder.push_advice_injector(injector.into()) } diff --git a/assembly/src/assembler/instruction/crypto_ops.rs b/assembly/src/assembler/instruction/crypto_ops.rs index 54e6a2acf..a89015a06 100644 --- a/assembly/src/assembler/instruction/crypto_ops.rs +++ b/assembly/src/assembler/instruction/crypto_ops.rs @@ -113,10 +113,10 @@ pub(super) fn hmerge(block_builder: &mut BasicBlockBuilder) { /// - root of the tree, 4 elements. /// /// This operation takes 9 VM cycles. -pub(super) fn mtree_get(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { +pub(super) fn mtree_get(block_builder: &mut BasicBlockBuilder) { // stack: [d, i, R, ...] // pops the value of the node we are looking for from the advice stack - read_mtree_node(block_builder)?; + read_mtree_node(block_builder); #[rustfmt::skip] let ops = [ // verify the node V for root R with depth d and index i @@ -128,8 +128,6 @@ pub(super) fn mtree_get(block_builder: &mut BasicBlockBuilder) -> Result<(), Ass MovUp4, Drop, MovUp4, Drop, ]; block_builder.push_ops(ops); - - Ok(()) } /// Appends the MRUPDATE op with a parameter of "false" and stack manipulations to the span block @@ -165,18 +163,16 @@ pub(super) fn mtree_set(block_builder: &mut BasicBlockBuilder) -> Result<(), Ass /// It is not checked whether the provided roots exist as Merkle trees in the advide providers. /// /// This operation takes 16 VM cycles. -pub(super) fn mtree_merge(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { +pub(super) fn mtree_merge(block_builder: &mut BasicBlockBuilder) { // stack input: [R_rhs, R_lhs, ...] // stack output: [R_merged, ...] // invoke the advice provider function to merge 2 Merkle trees defined by the roots on the top // of the operand stack - block_builder.push_advice_injector(AdviceInjector::MerkleNodeMerge)?; + block_builder.push_advice_injector(AdviceInjector::MerkleNodeMerge); // perform the `hmerge`, updating the operand stack - hmerge(block_builder); - - Ok(()) + hmerge(block_builder) } // MERKLE TREES - HELPERS @@ -199,20 +195,18 @@ pub(super) fn mtree_merge(block_builder: &mut BasicBlockBuilder) -> Result<(), A /// - new value of the node, 4 elements (only in the case of mtree_set) /// /// This operation takes 4 VM cycles. -fn read_mtree_node(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { +fn read_mtree_node(block_builder: &mut BasicBlockBuilder) { // The stack should be arranged in the following way: [d, i, R, ...] so that the decorator // can fetch the node value from the root. In the `mtree.get` operation we have the stack in // the following format: [d, i, R], whereas in the case of `mtree.set` we would also have the // new node value post the tree root: [d, i, R, V_new] // // pops the value of the node we are looking for from the advice stack - block_builder.push_advice_injector(AdviceInjector::MerkleNodeToStack)?; + block_builder.push_advice_injector(AdviceInjector::MerkleNodeToStack); // pops the old node value from advice the stack => MPVERIFY: [V_old, d, i, R, ...] // MRUPDATE: [V_old, d, i, R, V_new, ...] block_builder.push_op_many(AdvPop, 4); - - Ok(()) } /// Update a node in the merkle tree. This operation will always copy the tree into a new instance, @@ -225,7 +219,7 @@ fn update_mtree(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyErr // Inject the old node value onto the stack for the call to MRUPDATE. // stack: [V_old, d, i, R_old, V_new, ...] (4 cycles) - read_mtree_node(block_builder)?; + read_mtree_node(block_builder); #[rustfmt::skip] let ops = [ diff --git a/assembly/src/assembler/instruction/ext2_ops.rs b/assembly/src/assembler/instruction/ext2_ops.rs index 6cc3ae88a..b2729553e 100644 --- a/assembly/src/assembler/instruction/ext2_ops.rs +++ b/assembly/src/assembler/instruction/ext2_ops.rs @@ -53,8 +53,8 @@ pub fn ext2_mul(block_builder: &mut BasicBlockBuilder) { /// operations outputs the result c = (c1, c0) where c = a * b^-1. /// /// This operation takes 11 VM cycles. -pub fn ext2_div(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(Ext2Inv)?; +pub fn ext2_div(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(Ext2Inv); #[rustfmt::skip] let ops = [ AdvPop, // [b0', b1, b0, a1, a0, ...] @@ -70,8 +70,6 @@ pub fn ext2_div(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyErr Drop // [a1*b1', a0*b0'...] ]; block_builder.push_ops(ops); - - Ok(()) } /// Given a stack with initial configuration given by [a1, a0, ...] where a = (a0, a1) represents @@ -116,7 +114,7 @@ pub fn ext2_neg(block_builder: &mut BasicBlockBuilder) { /// /// This operation takes 8 VM cycles. pub fn ext2_inv(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(Ext2Inv)?; + block_builder.push_advice_injector(Ext2Inv); #[rustfmt::skip] let ops = [ AdvPop, // [a0', a1, a0, ...] diff --git a/assembly/src/assembler/instruction/field_ops.rs b/assembly/src/assembler/instruction/field_ops.rs index 74063bb48..7033a92ef 100644 --- a/assembly/src/assembler/instruction/field_ops.rs +++ b/assembly/src/assembler/instruction/field_ops.rs @@ -259,8 +259,8 @@ fn perform_exp_for_small_power(span_builder: &mut BasicBlockBuilder, pow: u64) { /// /// # Errors /// Returns an error if the logarithm argument (top stack element) equals ZERO. -pub fn ilog2(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(AdviceInjector::ILog2)?; +pub fn ilog2(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(AdviceInjector::ILog2); block_builder.push_op(AdvPop); // [ilog2, n, ...] // compute the power-of-two for the value given in the advice tape (17 cycles) @@ -290,8 +290,6 @@ pub fn ilog2(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> ]; block_builder.push_ops(ops); - - Ok(()) } // COMPARISON OPERATIONS diff --git a/assembly/src/assembler/instruction/mod.rs b/assembly/src/assembler/instruction/mod.rs index 49e8bec16..76de7147c 100644 --- a/assembly/src/assembler/instruction/mod.rs +++ b/assembly/src/assembler/instruction/mod.rs @@ -89,7 +89,7 @@ impl Assembler { Instruction::ExpBitLength(num_pow_bits) => { field_ops::exp(block_builder, *num_pow_bits)? }, - Instruction::ILog2 => field_ops::ilog2(block_builder)?, + Instruction::ILog2 => field_ops::ilog2(block_builder), Instruction::Not => block_builder.push_op(Not), Instruction::And => block_builder.push_op(And), @@ -111,7 +111,7 @@ impl Assembler { Instruction::Ext2Add => ext2_ops::ext2_add(block_builder), Instruction::Ext2Sub => ext2_ops::ext2_sub(block_builder), Instruction::Ext2Mul => ext2_ops::ext2_mul(block_builder), - Instruction::Ext2Div => ext2_ops::ext2_div(block_builder)?, + Instruction::Ext2Div => ext2_ops::ext2_div(block_builder), Instruction::Ext2Neg => ext2_ops::ext2_neg(block_builder), Instruction::Ext2Inv => ext2_ops::ext2_inv(block_builder)?, @@ -190,10 +190,10 @@ impl Assembler { Instruction::U32Rotr => u32_ops::u32rotr(block_builder, None)?, Instruction::U32RotrImm(v) => u32_ops::u32rotr(block_builder, Some(v.expect_value()))?, Instruction::U32Popcnt => u32_ops::u32popcnt(block_builder), - Instruction::U32Clz => u32_ops::u32clz(block_builder)?, - Instruction::U32Ctz => u32_ops::u32ctz(block_builder)?, - Instruction::U32Clo => u32_ops::u32clo(block_builder)?, - Instruction::U32Cto => u32_ops::u32cto(block_builder)?, + Instruction::U32Clz => u32_ops::u32clz(block_builder), + Instruction::U32Ctz => u32_ops::u32ctz(block_builder), + Instruction::U32Clo => u32_ops::u32clo(block_builder), + Instruction::U32Cto => u32_ops::u32cto(block_builder), Instruction::U32Lt => u32_ops::u32lt(block_builder), Instruction::U32Lte => u32_ops::u32lte(block_builder), Instruction::U32Gt => u32_ops::u32gt(block_builder), @@ -361,15 +361,15 @@ impl Assembler { false, )?, - Instruction::AdvInject(injector) => adv_ops::adv_inject(block_builder, injector)?, + Instruction::AdvInject(injector) => adv_ops::adv_inject(block_builder, injector), // ----- cryptographic instructions --------------------------------------------------- Instruction::Hash => crypto_ops::hash(block_builder), Instruction::HPerm => block_builder.push_op(HPerm), Instruction::HMerge => crypto_ops::hmerge(block_builder), - Instruction::MTreeGet => crypto_ops::mtree_get(block_builder)?, + Instruction::MTreeGet => crypto_ops::mtree_get(block_builder), Instruction::MTreeSet => crypto_ops::mtree_set(block_builder)?, - Instruction::MTreeMerge => crypto_ops::mtree_merge(block_builder)?, + Instruction::MTreeMerge => crypto_ops::mtree_merge(block_builder), Instruction::MTreeVerify => block_builder.push_op(MpVerify(0)), Instruction::MTreeVerifyWithError(err_code) => { block_builder.push_op(MpVerify(err_code.expect_value())) diff --git a/assembly/src/assembler/instruction/u32_ops.rs b/assembly/src/assembler/instruction/u32_ops.rs index 8826d0593..23801be09 100644 --- a/assembly/src/assembler/instruction/u32_ops.rs +++ b/assembly/src/assembler/instruction/u32_ops.rs @@ -298,12 +298,11 @@ pub fn u32popcnt(span_builder: &mut BasicBlockBuilder) { /// provider). /// /// This operation takes 42 VM cycles. -pub fn u32clz(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(AdviceInjector::U32Clz)?; +pub fn u32clz(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(AdviceInjector::U32Clz); block_builder.push_op(AdvPop); // [clz, n, ...] verify_clz(block_builder); - Ok(()) } /// Translates `u32ctz` assembly instruction to VM operations. `u32ctz` counts the number of @@ -311,12 +310,11 @@ pub fn u32clz(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError /// provider). /// /// This operation takes 34 VM cycles. -pub fn u32ctz(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(AdviceInjector::U32Ctz)?; +pub fn u32ctz(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(AdviceInjector::U32Ctz); block_builder.push_op(AdvPop); // [ctz, n, ...] verify_ctz(block_builder); - Ok(()) } /// Translates `u32clo` assembly instruction to VM operations. `u32clo` counts the number of @@ -324,12 +322,11 @@ pub fn u32ctz(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError /// provider). /// /// This operation takes 41 VM cycles. -pub fn u32clo(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(AdviceInjector::U32Clo)?; +pub fn u32clo(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(AdviceInjector::U32Clo); block_builder.push_op(AdvPop); // [clo, n, ...] verify_clo(block_builder); - Ok(()) } /// Translates `u32cto` assembly instruction to VM operations. `u32cto` counts the number of @@ -337,12 +334,11 @@ pub fn u32clo(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError /// provider). /// /// This operation takes 33 VM cycles. -pub fn u32cto(block_builder: &mut BasicBlockBuilder) -> Result<(), AssemblyError> { - block_builder.push_advice_injector(AdviceInjector::U32Cto)?; +pub fn u32cto(block_builder: &mut BasicBlockBuilder) { + block_builder.push_advice_injector(AdviceInjector::U32Cto); block_builder.push_op(AdvPop); // [cto, n, ...] verify_cto(block_builder); - Ok(()) } /// Specifically handles these specific inputs per the spec. diff --git a/core/src/operations/decorators/advice.rs b/core/src/operations/decorators/advice.rs index 4cc60ec4b..ea558f166 100644 --- a/core/src/operations/decorators/advice.rs +++ b/core/src/operations/decorators/advice.rs @@ -5,6 +5,29 @@ use super::SignatureKind; // ADVICE INJECTORS // ================================================================================================ +// Randomly generated constant values for the VM's native events. All values were sampled between 0 +// and 2^32. + +pub const EVENT_MERKLE_NODE_MERGE: u32 = 191808474; +pub const EVENT_MERKLE_NODE_TO_STACK: u32 = 2389745239; +pub const EVENT_UPDATE_MERKLE_NODE: u32 = 3895296046; +pub const EVENT_MAP_VALUE_TO_STACK: u32 = 3754237093; +pub const EVENT_MAP_VALUE_TO_STACK_N: u32 = 2928255101; +pub const EVENT_U64_DIV: u32 = 4194199493; +pub const EVENT_EXT2_INV: u32 = 1774099307; +pub const EVENT_EXT2_INTT: u32 = 1091345727; +pub const EVENT_SMT_PEEK: u32 = 3186495057; +pub const EVENT_U32_CLZ: u32 = 1180644394; +pub const EVENT_U32_CTZ: u32 = 2777457657; +pub const EVENT_U32_CLO: u32 = 2311971056; +pub const EVENT_U32_CTO: u32 = 3070738514; +pub const EVENT_ILOG2: u32 = 3092594227; +pub const EVENT_MEM_TO_MAP: u32 = 3593064965; +pub const EVENT_HDWORD_TO_MAP: u32 = 2433155432; +pub const EVENT_HDWORD_TO_MAP_WITH_DOMAIN: u32 = 233822648; +pub const EVENT_HPERM_TO_MAP: u32 = 2997735825; +pub const EVENT_FALCON_SIG_TO_STACK: u32 = 3099530921; + /// Defines a set of actions which can be initiated from the VM to inject new data into the advice /// provider. /// @@ -292,6 +315,61 @@ pub enum AdviceInjector { FalconSigToStack, } +impl AdviceInjector { + pub fn into_event_id(self) -> u32 { + let event_id = match self { + AdviceInjector::MerkleNodeMerge => EVENT_MERKLE_NODE_MERGE, + AdviceInjector::MerkleNodeToStack => EVENT_MERKLE_NODE_TO_STACK, + AdviceInjector::UpdateMerkleNode => EVENT_UPDATE_MERKLE_NODE, + AdviceInjector::MapValueToStack => EVENT_MAP_VALUE_TO_STACK, + AdviceInjector::MapValueToStackN => EVENT_MAP_VALUE_TO_STACK_N, + AdviceInjector::U64Div => EVENT_U64_DIV, + AdviceInjector::Ext2Inv => EVENT_EXT2_INV, + AdviceInjector::Ext2Intt => EVENT_EXT2_INTT, + AdviceInjector::SmtPeek => EVENT_SMT_PEEK, + AdviceInjector::U32Clz => EVENT_U32_CLZ, + AdviceInjector::U32Ctz => EVENT_U32_CTZ, + AdviceInjector::U32Clo => EVENT_U32_CLO, + AdviceInjector::U32Cto => EVENT_U32_CTO, + AdviceInjector::ILog2 => EVENT_ILOG2, + AdviceInjector::MemToMap => EVENT_MEM_TO_MAP, + AdviceInjector::HdwordToMap => EVENT_HDWORD_TO_MAP, + AdviceInjector::HdwordToMapWithDomain => EVENT_HDWORD_TO_MAP_WITH_DOMAIN, + AdviceInjector::HpermToMap => EVENT_HPERM_TO_MAP, + AdviceInjector::FalconSigToStack => EVENT_FALCON_SIG_TO_STACK, + }; + + event_id as u32 + } + + /// Returns an advice injector corresponding to the specified event ID, or `None` if the event + /// ID is not recognized. + pub fn from_event_id(event_id: u32) -> Option { + match event_id as u32 { + EVENT_MERKLE_NODE_MERGE => Some(AdviceInjector::MerkleNodeMerge), + EVENT_MERKLE_NODE_TO_STACK => Some(AdviceInjector::MerkleNodeToStack), + EVENT_UPDATE_MERKLE_NODE => Some(AdviceInjector::UpdateMerkleNode), + EVENT_MAP_VALUE_TO_STACK => Some(AdviceInjector::MapValueToStack), + EVENT_MAP_VALUE_TO_STACK_N => Some(AdviceInjector::MapValueToStackN), + EVENT_U64_DIV => Some(AdviceInjector::U64Div), + EVENT_EXT2_INV => Some(AdviceInjector::Ext2Inv), + EVENT_EXT2_INTT => Some(AdviceInjector::Ext2Intt), + EVENT_SMT_PEEK => Some(AdviceInjector::SmtPeek), + EVENT_U32_CLZ => Some(AdviceInjector::U32Clz), + EVENT_U32_CTZ => Some(AdviceInjector::U32Ctz), + EVENT_U32_CLO => Some(AdviceInjector::U32Clo), + EVENT_U32_CTO => Some(AdviceInjector::U32Cto), + EVENT_ILOG2 => Some(AdviceInjector::ILog2), + EVENT_MEM_TO_MAP => Some(AdviceInjector::MemToMap), + EVENT_HDWORD_TO_MAP => Some(AdviceInjector::HdwordToMap), + EVENT_HDWORD_TO_MAP_WITH_DOMAIN => Some(AdviceInjector::HdwordToMapWithDomain), + EVENT_HPERM_TO_MAP => Some(AdviceInjector::HpermToMap), + EVENT_FALCON_SIG_TO_STACK => Some(AdviceInjector::FalconSigToStack), + _ => None, + } + } +} + impl crate::prettier::PrettyPrint for AdviceInjector { fn render(&self) -> crate::prettier::Document { crate::prettier::display(self) diff --git a/processor/src/lib.rs b/processor/src/lib.rs index 6f0a7f88a..869073d0e 100644 --- a/processor/src/lib.rs +++ b/processor/src/lib.rs @@ -626,7 +626,6 @@ impl Process { advice_provider.insert_hdword_into_adv_map(process_state, ZERO)?; }, AdviceInjector::HdwordToMapWithDomain => { - // TODO(plafer): get domain from stack let domain = self.stack.get(8); advice_provider.insert_hdword_into_adv_map(process_state, domain)?; todo!() diff --git a/processor/src/operations/sys_ops.rs b/processor/src/operations/sys_ops.rs index 1a198da3b..7508214e0 100644 --- a/processor/src/operations/sys_ops.rs +++ b/processor/src/operations/sys_ops.rs @@ -1,4 +1,4 @@ -use vm_core::{Felt, Operation}; +use vm_core::{AdviceInjector, Felt, Operation, SignatureKind, ZERO}; use super::{ super::{ @@ -7,7 +7,7 @@ use super::{ }, ExecutionError, Process, }; -use crate::Host; +use crate::{AdviceProvider, Host, ProcessState}; // SYSTEM OPERATIONS // ================================================================================================ @@ -122,9 +122,62 @@ impl Process { { self.stack.copy_state(0); self.decoder.set_user_op_helpers(Operation::Emit(event_id), &[event_id.into()]); - host.on_event(self.into(), event_id)?; - Ok(()) + // If it's a native event, handle it directly. Otherwise, forward it to the host. + if let Some(advice_injector) = AdviceInjector::from_event_id(event_id) { + self.handle_advice_injector(advice_injector, host) + } else { + host.on_event(self.into(), event_id) + } + } + + fn handle_advice_injector( + &self, + advice_injector: AdviceInjector, + host: &mut impl Host, + ) -> Result<(), ExecutionError> { + let advice_provider = host.advice_provider_mut(); + let process_state: ProcessState = (&*self).into(); + match advice_injector { + AdviceInjector::MerkleNodeMerge => advice_provider.merge_merkle_nodes(process_state), + AdviceInjector::MerkleNodeToStack => { + advice_provider.copy_merkle_node_to_adv_stack(process_state) + }, + AdviceInjector::MapValueToStack => { + advice_provider.copy_map_value_to_adv_stack(process_state, false, 0) + }, + AdviceInjector::MapValueToStackN => { + advice_provider.copy_map_value_to_adv_stack(process_state, true, 0) + }, + AdviceInjector::UpdateMerkleNode => { + let _ = advice_provider.update_operand_stack_merkle_node(process_state)?; + Ok(()) + }, + AdviceInjector::U64Div => advice_provider.push_u64_div_result(process_state), + AdviceInjector::Ext2Inv => advice_provider.push_ext2_inv_result(process_state), + AdviceInjector::Ext2Intt => advice_provider.push_ext2_intt_result(process_state), + AdviceInjector::SmtPeek => advice_provider.push_smtpeek_result(process_state), + AdviceInjector::U32Clz => advice_provider.push_leading_zeros(process_state), + AdviceInjector::U32Ctz => advice_provider.push_trailing_zeros(process_state), + AdviceInjector::U32Clo => advice_provider.push_leading_ones(process_state), + AdviceInjector::U32Cto => advice_provider.push_trailing_ones(process_state), + AdviceInjector::ILog2 => advice_provider.push_ilog2(process_state), + + AdviceInjector::MemToMap => { + advice_provider.insert_mem_values_into_adv_map(process_state) + }, + AdviceInjector::HdwordToMap => { + advice_provider.insert_hdword_into_adv_map(process_state, ZERO) + }, + AdviceInjector::HdwordToMapWithDomain => { + let domain = self.stack.get(8); + advice_provider.insert_hdword_into_adv_map(process_state, domain) + }, + AdviceInjector::HpermToMap => advice_provider.insert_hperm_into_adv_map(process_state), + AdviceInjector::FalconSigToStack => { + advice_provider.push_signature(process_state, SignatureKind::RpoFalcon512) + }, + } } }