Skip to content

Commit

Permalink
Removes any remnants of TieredSmt (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer authored Feb 8, 2024
1 parent 9ca7ab3 commit a610832
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 124 deletions.
4 changes: 4 additions & 0 deletions air/src/constraints/chiplets/hasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,11 @@ trait EvaluationFrameExt<E: FieldElement> {
// --- Flags ----------------------------------------------------------------------------------

/// Set to 1 on the first 7 steps of every 8-step cycle. This flag is degree 1.
#[allow(dead_code)]
fn f_rpr(&self, k: &[E]) -> E;
/// Set to 1 when selector flags are (1,0,0) on rows which are multiples of 8. This flag is
/// degree 4.
#[allow(dead_code)]
fn f_bp(&self, k: &[E]) -> E;
/// Set to 1 when selector flags are (1,0,1) on rows which are multiples of 8. This flag is
/// degree 4.
Expand All @@ -359,9 +361,11 @@ trait EvaluationFrameExt<E: FieldElement> {
fn f_mu(&self, k: &[E]) -> E;
/// Set to 1 when selector flags are (0,0,0) on rows which are 1 less than a multiple of 8. This
/// flag is degree 4.
#[allow(dead_code)]
fn f_hout(&self, k: &[E]) -> E;
/// Set to 1 when selector flags are (0,0,1) on rows which are 1 less than a multiple of 8. This
/// flag is degree 4.
#[allow(dead_code)]
fn f_sout(&self, k: &[E]) -> E;
/// This flag will be set to 1 when either f_hout=1 or f_sout=1 in the current row. This flag is
/// degree 3.
Expand Down
4 changes: 4 additions & 0 deletions air/src/constraints/chiplets/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ trait EvaluationFrameExt<E: FieldElement> {
/// Gets the value of the specified selector column in the next row.
fn selector_next(&self, idx: usize) -> E;
/// The current context value.
#[allow(dead_code)]
fn ctx(&self) -> E;
/// The current address.
#[allow(dead_code)]
fn addr(&self) -> E;
/// The current clock cycle.
#[allow(dead_code)]
fn clk(&self) -> E;
/// The next clock cycle.
#[allow(dead_code)]
fn clk_next(&self) -> E;
/// The value from the specified index of the values (0, 1, 2, 3) in the current row.
fn v(&self, index: usize) -> E;
Expand Down
2 changes: 2 additions & 0 deletions air/src/constraints/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,14 @@ trait EvaluationFrameExt<E: FieldElement> {
fn stack_overflow_addr_next(&self) -> E;

/// Returns the current value of stack helper column `h0`.
#[allow(dead_code)]
fn stack_helper(&self) -> E;

/// Gets the current element of the clk register in the trace.
fn clk(&self) -> E;

/// Gets the next element of the clk register in the trace.
#[allow(dead_code)]
fn clk_next(&self) -> E;

/// Gets the current element of the fmp register in the trace.
Expand Down
3 changes: 1 addition & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ pub mod crypto {
pub use miden_crypto::merkle::{
DefaultMerkleStore, EmptySubtreeRoots, InnerNodeInfo, LeafIndex, MerkleError,
MerklePath, MerkleStore, MerkleTree, Mmr, MmrPeaks, NodeIndex, PartialMerkleTree,
RecordingMerkleStore, SimpleSmt, Smt, SmtProof, SmtProofError, StoreNode, TieredSmt,
SMT_DEPTH,
RecordingMerkleStore, SimpleSmt, Smt, SmtProof, SmtProofError, StoreNode, SMT_DEPTH,
};
}

Expand Down
57 changes: 2 additions & 55 deletions core/src/operations/decorators/advice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,63 +144,10 @@ pub enum AdviceInjector {
/// degree coefficients are located at the top of the advice stack.
Ext2Intt,

/// Pushes values onto the advice stack which are required for successful retrieval of a
/// value from a Sparse Merkle Tree data structure.
///
/// The Sparse Merkle Tree is tiered, meaning it will have leaf depths in `{16, 32, 48, 64}`.
/// The depth flags define the tier on which the leaf is located.
///
/// Inputs:
/// Operand stack: [KEY, ROOT, ...]
/// Advice stack: [...]
///
/// Outputs:
/// Operand stack: [KEY, ROOT, ...]
/// Advice stack: [f0, f1, K, V, f2]
///
/// Where:
/// - f0 is a boolean flag set to `1` if the depth is `16` or `48`.
/// - f1 is a boolean flag set to `1` if the depth is `16` or `32`.
/// - K is the remaining key word; will be zeroed if the tree don't contain a mapped value
/// for the key.
/// - V is the value word; will be zeroed if the tree don't contain a mapped value for the key.
/// - f2 is a boolean flag set to `1` if a remaining key is not zero.
/// Currently unimplemented
SmtGet,

/// Pushes values onto the advice stack which are required for successful insertion of a
/// key-value pair into a Sparse Merkle Tree data structure.
///
/// The Sparse Merkle Tree is tiered, meaning it will have leaf depths in `{16, 32, 48, 64}`.
///
/// Inputs:
/// Operand stack: [VALUE, KEY, ROOT, ...]
/// Advice stack: [...]
///
/// Outputs:
/// Operand stack: [OLD_VALUE, NEW_ROOT, ...]
/// Advice stack depends on the type of insert operation as follows:
/// - Update of an existing leaf: [ZERO (padding), d0, d1, ONE (is_update), OLD_VALUE]
/// - Simple insert at depth 16: [d0, d1, ONE (is_simple_insert), ZERO (is_update)]
/// - Simple insert at depth 32 or 48: [d0, d1, ONE (is_simple_insert), ZERO (is_update), P_NODE]
/// - Complex insert: [f0, f1, ZERO (is_simple_insert), ZERO (is_update), E_KEY, E_VALUE]
/// - Delete against an empty subtree: [d0, d1, ZERO (is_leaf), ONE (key_not_set)]
/// - Delete against another leaf: [d0, d1, ONE (is_leaf), ONE (key_not_set), KEY, VALUE]
/// - Delete against own leaf: [ZERO, ZERO, ZERO, ZERO (key_not_set), NEW_ROOT, OLD_VALUE]
///
/// Where:
/// - ROOT and NEW_ROOT are the roots of the TSMT before and after the insert respectively.
/// - VALUE is the value to be inserted.
/// - OLD_VALUE is the value previously associated with the specified KEY.
/// - d0 is a boolean flag set to `1` if the depth is `16` or `48`.
/// - d1 is a boolean flag set to `1` if the depth is `16` or `32`.
/// - P_NODE is an internal node located at the tier above the insert tier.
/// - f0 and f1 are boolean flags a combination of which determines the source and the target
/// tiers as follows:
/// - (0, 0): depth 16 -> 32
/// - (0, 1): depth 16 -> 48
/// - (1, 0): depth 32 -> 48
/// - (1, 1): depth 16, 32, or 48 -> 64
/// - E_KEY and E_VALUE are the key-value pair for a leaf which is to be replaced by a subtree.
/// Currently unimplemented
SmtSet,

/// Pushes onto the advice stack the value associated with the specified key in a Sparse
Expand Down
16 changes: 9 additions & 7 deletions processor/src/host/advice/injectors/smt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ use vm_core::{
// SMT INJECTORS
// ================================================================================================

pub(crate) fn push_smtget_inputs<S: ProcessState, A: AdviceProvider>(
_advice_provider: &mut A,
_process: &S,
) -> Result<HostResponse, ExecutionError> {
unimplemented!()
}

/// Pushes onto the advice stack the value associated with the specified key in a Sparse
/// Merkle Tree defined by the specified root.
///
Expand Down Expand Up @@ -72,6 +65,15 @@ pub(crate) fn push_smtpeek_result<S: ProcessState, A: AdviceProvider>(
Ok(HostResponse::None)
}

/// Currently unimplemented
pub(crate) fn push_smtget_inputs<S: ProcessState, A: AdviceProvider>(
_advice_provider: &mut A,
_process: &S,
) -> Result<HostResponse, ExecutionError> {
unimplemented!()
}

/// Currently unimplemented
pub(crate) fn push_smtset_inputs<S: ProcessState, A: AdviceProvider>(
_advice_provider: &mut A,
_process: &S,
Expand Down
69 changes: 9 additions & 60 deletions processor/src/host/advice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,39 +424,6 @@ pub trait AdviceProvider: Sized {
// DEFAULT SMT INJECTORS
// --------------------------------------------------------------------------------------------

/// Pushes values onto the advice stack which are required for successful retrieval of a
/// value from a Sparse Merkle Tree data structure.
///
/// The Sparse Merkle Tree is tiered, meaning it will have leaf depths in `{16, 32, 48, 64}`.
/// The depth flags define the tier on which the leaf is located.
///
/// Inputs:
/// Operand stack: [KEY, ROOT, ...]
/// Advice stack: [...]
///
/// Outputs:
/// Operand stack: [KEY, ROOT, ...]
/// Advice stack: [f0, f1, K, V, f2]
///
/// Where:
/// - f0 is a boolean flag set to `1` if the depth is `16` or `48`.
/// - f1 is a boolean flag set to `1` if the depth is `16` or `32`.
/// - K is the key; will be zeroed if the tree don't contain a mapped value for the key.
/// - V is the value word; will be zeroed if the tree don't contain a mapped value for the key.
/// - f2 is a boolean flag set to `1` if the key is not zero.
///
/// # Errors
/// Returns an error if the provided Merkle root doesn't exist on the advice provider.
///
/// # Panics
/// Will panic as unimplemented if the target depth is `64`.
fn push_smtget_inputs<S: ProcessState>(
&mut self,
process: &S,
) -> Result<HostResponse, ExecutionError> {
injectors::smt::push_smtget_inputs(self, process)
}

/// Pushes onto the advice stack the value associated with the specified key in a Sparse
/// Merkle Tree defined by the specified root.
///
Expand All @@ -483,33 +450,15 @@ pub trait AdviceProvider: Sized {
injectors::smt::push_smtpeek_result(self, process)
}

/// Pushes values onto the advice stack which are required for successful insertion of a
/// key-value pair into a Sparse Merkle Tree data structure.
///
/// The Sparse Merkle Tree is tiered, meaning it will have leaf depths in `{16, 32, 48, 64}`.
///
/// Inputs:
/// Operand stack: [VALUE, KEY, ROOT, ...]
/// Advice stack: [...]
///
/// Outputs:
/// Operand stack: [OLD_VALUE, NEW_ROOT, ...]
/// Advice stack: see comments for specialized handlers below.
///
/// Where:
/// - ROOT and NEW_ROOT are the roots of the TSMT before and after the insert respectively.
/// - VALUE is the value to be inserted.
/// - OLD_VALUE is the value previously associated with the specified KEY.
///
/// # Errors
/// Returns an error if:
/// - The Merkle store does not contain a node with the specified root.
/// - The Merkle store does not contain all nodes needed to validate the path between the root
/// and the relevant TSMT nodes.
/// - The advice map does not contain required data about TSMT leaves to be modified.
///
/// # Panics
/// Will panic as unimplemented if the target depth is `64`.
/// Currently unimplemented
fn push_smtget_inputs<S: ProcessState>(
&mut self,
process: &S,
) -> Result<HostResponse, ExecutionError> {
injectors::smt::push_smtget_inputs(self, process)
}

/// Currently unimplemented
fn push_smtset_inputs<S: ProcessState>(
&mut self,
process: &S,
Expand Down

0 comments on commit a610832

Please sign in to comment.