Skip to content

Commit

Permalink
Merge branch 'next' into phklive-account-code-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
phklive authored Jul 30, 2024
2 parents 32dbaab + 194267b commit 68c419b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: changelog

on:
pull_request:
types: [opened, reopened, synchronize]
types: [opened, reopened, synchronize, labeled, unlabeled]

jobs:
changelog:
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Nullifiers are stored in a sparse Merkle tree, which maps [note nullifiers](note
![Architecture core concepts](../img/architecture/state/nullifier-db.png){ width="80%" }
</center>

To prove that a note has not been consumed previously, the operator needs to provide a Merkle path to its node, and then show that the value in that node is `0`. In our case nullifiers are $32$ bytes each, and thus, the height of the Sparse Merkle Tree need to be $256$.
To prove that a note has not been consumed previously, the operator needs to provide a Merkle path to its node, and then show that the value in that node is `0`. In our case nullifiers are $32$ bytes each, and thus, the height of the Sparse Merkle Tree needs to be $256$.

To add new nullifiers to the database, operators needs to maintain the entire nullifier set. Otherwise, they would not be able to compute the new root of the tree.
To add new nullifiers to the database, operators need to maintain the entire nullifier set. Otherwise, they would not be able to compute the new root of the tree.

!!! note
Nullifiers as constructed in Miden break linkability of privately stored notes and the information about the note's consumption. To know the [note's nullifier](notes.md#note-nullifier-to-ensure-private-consumption) one must know the note's data.
Expand Down
4 changes: 2 additions & 2 deletions docs/architecture/transactions/contexts.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export.receive_asset
end
```

The [account API](https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/miden/account.masm#L162) exposes procedures to manage accounts. This particular procedure that was called by the wallet invokes a `syscall` to return back to the root context **(3)**, where the account vault is stored in memory (see prologue). `syscall` can incoke all procedures defined in the [Kernel API](https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/kernels/transaction/api.masm).
The [account API](https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/miden/account.masm#L162) exposes procedures to manage accounts. This particular procedure that was called by the wallet invokes a `syscall` to return back to the root context **(3)**, where the account vault is stored in memory (see prologue). `syscall` can invoke all procedures defined in the [Kernel API](https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/kernels/transaction/api.masm).

```arduino
#! Add the specified asset to the vault.
Expand All @@ -76,4 +76,4 @@ end

Now, the asset can be safely added to the vault within the kernel context, and the note can be successfully processed.

<br/>
<br/>
4 changes: 2 additions & 2 deletions docs/architecture/transactions/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ comments: true

The Miden transaction executor is the component that executes transactions.

Transaction execution consists of the following steps and results in a `ExecutedTransaction` object:
Transaction execution consists of the following steps and results in an `ExecutedTransaction` object:

1. Fetch the data required to execute a transaction from the data store.
2. Compile the transaction into an executable [MASM](https://0xpolygonmiden.github.io/miden-vm/user_docs/assembly/main.html) program using the transaction compiler.
Expand Down Expand Up @@ -49,4 +49,4 @@ A successfully executed transaction results in a new account state which is a ve

The transaction prover proves the inputted `ExecutedTransaction` and returns a `ProvenTransaction` object. The Miden node verifies the `ProvenTransaction` object using the transaction verifier and, if valid, updates the [state](../state.md) databases.

<br/>
<br/>
4 changes: 2 additions & 2 deletions docs/architecture/transactions/kernel.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The transaction kernel program receives two types of inputs, public inputs via t

The operand stack holds the global inputs which serve as a commitment to the data being provided via the advice provider.

The advice provider holds data of the last known block, account and input note data. The details are layed out in the next paragraph.
The advice provider holds data of the last known block, account and input note data. The details are laid out in the next paragraph.

## Prologue

Expand Down Expand Up @@ -156,4 +156,4 @@ There is an exception for special accounts, called faucets, which can mint or bu

The transaction kernel program outputs the transaction script root, a commitment of all newly created outputs notes, and the account hash in its new state.

<br/>
<br/>
27 changes: 24 additions & 3 deletions miden-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ pub mod accounts;
pub mod notes;
pub mod transaction;

#[cfg(all(test, feature = "std"))]
mod tests;

// RE-EXPORTS
// ================================================================================================

Expand Down Expand Up @@ -60,3 +57,27 @@ impl Library for MidenLib {
self.contents.dependencies()
}
}

// TESTS
// ================================================================================================

// NOTE: Most kernel-related tests can be found under /miden-tx/kernel_tests
#[cfg(all(test, feature = "std"))]
mod tests {
use miden_objects::assembly::Library;

#[test]
fn test_compile() {
let path = "miden::kernels::tx::memory::get_input_note_ptr";
let miden = super::MidenLib::default();
let exists = miden.modules().any(|module| {
module
.ast
.procs()
.iter()
.any(|proc| module.path.append(&proc.name).unwrap().as_str() == path)
});

assert!(exists);
}
}
22 changes: 0 additions & 22 deletions miden-lib/src/tests/mod.rs

This file was deleted.

8 changes: 4 additions & 4 deletions miden-tx/src/tests/kernel_tests/test_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn test_set_code_is_not_immediate() {
assert_eq!(
read_root_mem_value(&process, ACCT_CODE_COMMITMENT_PTR),
tx_context.account().code().commitment().as_elements(),
"the code commitment must not change immediatelly",
"the code commitment must not change immediately",
);

assert_eq!(
Expand Down Expand Up @@ -373,17 +373,17 @@ fn test_get_map_item() {
assert_eq!(
Word::default(),
process.get_stack_word(1),
"The the rest of the stack must be cleared",
"The rest of the stack must be cleared",
);
assert_eq!(
Word::default(),
process.get_stack_word(2),
"The the rest of the stack must be cleared",
"The rest of the stack must be cleared",
);
assert_eq!(
Word::default(),
process.get_stack_word(3),
"The the rest of the stack must be cleared",
"The rest of the stack must be cleared",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion objects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Structures used to define fungible and non-fungible assets. Accounts own assets

### Block

Structures used to define a block. These objects contains authentication structures, merkle trees, used to represent the state of the rollup at a given point in time.
Structures used to define a block. These objects contain authentication structures, merkle trees, used to represent the state of the rollup at a given point in time.

### Notes

Expand Down
2 changes: 1 addition & 1 deletion objects/src/transaction/prepared_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::{
/// A struct that contains all of the data required to execute a transaction.
///
/// This includes:
/// - A an executable program which defines the transaction.
/// - An executable program which defines the transaction.
/// - An optional transaction script.
/// - A set of inputs against which the transaction program should be executed.
#[derive(Debug)]
Expand Down

0 comments on commit 68c419b

Please sign in to comment.