Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend AccountId to two Felts and refactor creation process #982

Open
wants to merge 52 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3191d39
feat: Add new AccountId layout
PhilippGackstatter Nov 22, 2024
e366a29
feat: Move epoch to second felt top 16 bits
PhilippGackstatter Nov 25, 2024
6913855
feat: Implement account id conversions
PhilippGackstatter Nov 25, 2024
fe6d524
chore: Refactor AccountId to contain felts as fields
PhilippGackstatter Nov 25, 2024
e4d6a0a
chore: Move account type into id
PhilippGackstatter Nov 25, 2024
47dfc4f
chore: Add changelog entry
PhilippGackstatter Nov 25, 2024
1a4c217
chore: Remove unnecessary conversion impl
PhilippGackstatter Nov 25, 2024
81dd03d
feat: AccountId changes in `objects`
PhilippGackstatter Nov 29, 2024
ef3bac0
feat: Refactor `NoteTag`
PhilippGackstatter Nov 29, 2024
43bbeb5
fix: account id byte & hex encoding
PhilippGackstatter Nov 29, 2024
cc4a290
fix: Note Metadata merging & unmerging + tests
PhilippGackstatter Dec 2, 2024
fdb5303
fix: clippy lints & tx inputs account seed validation
PhilippGackstatter Dec 2, 2024
2c9b4fd
chore: Fix objects crate
PhilippGackstatter Dec 3, 2024
459c120
feat: Implement AccountId changes in MASM
PhilippGackstatter Dec 4, 2024
c24aff0
feat: Implement account seed validation in masm
PhilippGackstatter Dec 9, 2024
7c82a5d
fix: account id set item
PhilippGackstatter Dec 9, 2024
c271a66
Fix account ID uniqueness and FPI procedures
PhilippGackstatter Dec 10, 2024
e97aec4
fix: Makefile env variables
PhilippGackstatter Dec 10, 2024
0fe3f8c
fix: P2IDR script
PhilippGackstatter Dec 10, 2024
07291c2
fix: block epoch shaping & account id note tag test
PhilippGackstatter Dec 10, 2024
38aed9b
feat: Move ID version to least significant nibble
PhilippGackstatter Dec 10, 2024
e38fee7
fix: copied procedures & non fungible bit
PhilippGackstatter Dec 10, 2024
db95bc3
feat: Reorder account id in fungible assets
PhilippGackstatter Dec 10, 2024
0bc8329
feat: Add account id documentation
PhilippGackstatter Dec 10, 2024
f3d649e
fix: no-std build and regenerate kernel errors
PhilippGackstatter Dec 10, 2024
95cfe9c
feat: add version and epoch validatation to validate_id
PhilippGackstatter Dec 10, 2024
fc082ca
chore: Fix doc build
PhilippGackstatter Dec 10, 2024
6aed570
chore: Remove old account id and seed
PhilippGackstatter Dec 10, 2024
a6b31c2
feat: Reenable non fungible asset check
PhilippGackstatter Dec 11, 2024
ac9e145
fix: non fungible asset stack & decompose bit flip
PhilippGackstatter Dec 11, 2024
16f0f23
fix: shape_second_felt masm impl
PhilippGackstatter Dec 11, 2024
02f6f52
chore: Rename epoch block to anchor block
PhilippGackstatter Dec 11, 2024
f69f7c7
feat: Document account id
PhilippGackstatter Dec 11, 2024
9f2c828
feat: cleanup api, account and asset masm
PhilippGackstatter Dec 11, 2024
1e94e69
feat: Add errors and update docs in masm
PhilippGackstatter Dec 11, 2024
1f768aa
chore: Cleanup rust side
PhilippGackstatter Dec 11, 2024
1a486cf
fix: account id docs
PhilippGackstatter Dec 11, 2024
4d8e0e9
Merge remote-tracking branch 'origin/next' into pgackst-account-id-re…
PhilippGackstatter Dec 12, 2024
8fafcb3
feat: Document `NoteMetadata` encoding
PhilippGackstatter Dec 12, 2024
6ed22f2
feat: Document `NoteExecutionHint` felt layout
PhilippGackstatter Dec 12, 2024
c4ad56c
feat: Introduce `BlockNumber` for the `AfterBlock` variant
PhilippGackstatter Dec 12, 2024
6ec50f9
fix: Rename to `AfterBlockNumber` and fix doc build
PhilippGackstatter Dec 12, 2024
0be4e70
chore: Make copies of IDs consistent
PhilippGackstatter Dec 12, 2024
44ed4a0
feat: Improve and add documentation for account id and prefix
PhilippGackstatter Dec 12, 2024
cba2d6d
chore: Modify and test `build_swap_tag`
PhilippGackstatter Dec 12, 2024
461664f
feat: add asset serialization format assertion test
PhilippGackstatter Dec 12, 2024
f84f65e
feat: Improve clarity of note tag constructor
PhilippGackstatter Dec 12, 2024
0771b4c
feat: check for min account ones in test IDs
PhilippGackstatter Dec 12, 2024
00cdd20
chore: Remove `Account::new`
PhilippGackstatter Dec 12, 2024
17abf92
feat: change `create_basic_{fungible_faucet,wallet}` to take header
PhilippGackstatter Dec 12, 2024
1421ada
feat: Enforce anchor block multiple of 2^16
PhilippGackstatter Dec 12, 2024
6fb398b
fix: `AccountBuilder` docs
PhilippGackstatter Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Added conversion from `Account` to `AccountDelta` for initial account state representation as delta (#983).
- [BREAKING] Added `miden::note::get_script_hash` procedure (#995).
- [BREAKING] Refactor error messages in `miden-lib` and `miden-tx` and use `thiserror` 2.0 (#1005).
- [BREAKING] Extend `AccountId` to two `Felt`s and require block hash in derivation (#982).

## 0.6.2 (2024-11-20)

Expand Down
5 changes: 5 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ WARNINGS=RUSTDOCFLAGS="-D warnings"
DEBUG_ASSERTIONS=RUSTFLAGS="-C debug-assertions"
ALL_FEATURES_BUT_ASYNC=--features concurrent,testing
BUILD_KERNEL_ERRORS=BUILD_KERNEL_ERRORS=1
# Enable backtraces for tests where we return an anyhow::Result which contains a `Backtrace`.
BACKTRACE=RUST_BACKTRACE=1

# -- linting --------------------------------------------------------------------------------------

Expand Down Expand Up @@ -56,12 +58,12 @@ test-build: ## Build the test binary

.PHONY: test-default
test-default: ## Run default tests excluding `prove`
$(DEBUG_ASSERTIONS) cargo nextest run --profile default --cargo-profile test-release --features concurrent,testing --filter-expr "not test(prove)"
$(DEBUG_ASSERTIONS) $(BACKTRACE) cargo nextest run --profile default --cargo-profile test-release --features concurrent,testing --filter-expr "not test(prove)"


.PHONY: test-prove
test-prove: ## Run `prove` tests (tests which use the Miden prover)
$(DEBUG_ASSERTIONS) cargo nextest run --profile prove --cargo-profile test-release --features concurrent,testing --filter-expr "test(prove)"
$(DEBUG_ASSERTIONS) $(BACKTRACE) cargo nextest run --profile prove --cargo-profile test-release --features concurrent,testing --filter-expr "test(prove)"


.PHONY: test
Expand Down
5 changes: 3 additions & 2 deletions bin/bench-tx/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use super::{read_to_string, write, Benchmark, Path};
// CONSTANTS
// ================================================================================================

pub const ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN: u64 = 0x200000000000001f; // 2305843009213693983
pub const ACCOUNT_ID_SENDER: u64 = 0x800000000000001f; // 9223372036854775839
// Copied from miden_objects::accounts::account_id::testing.
pub const ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN: u128 = 0xaa00000000bb020000cc000000dd00;
pub const ACCOUNT_ID_SENDER: u128 = 0xaa00000000bb080000cc000000dd00;

pub const DEFAULT_AUTH_SCRIPT: &str = "
begin
Expand Down
6 changes: 4 additions & 2 deletions bin/tx-prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ mod test {

use miden_lib::transaction::TransactionKernel;
use miden_objects::{
accounts::account_id::testing::{ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN, ACCOUNT_ID_SENDER},
assets::{Asset, FungibleAsset},
notes::NoteType,
testing::account_code::DEFAULT_AUTH_SCRIPT,
testing::{
account_code::DEFAULT_AUTH_SCRIPT,
account_id::{ACCOUNT_ID_FUNGIBLE_FAUCET_ON_CHAIN, ACCOUNT_ID_SENDER},
},
transaction::{ProvenTransaction, TransactionScript, TransactionWitness},
};
use miden_tx::{
Expand Down
51 changes: 26 additions & 25 deletions miden-lib/asm/kernels/transaction/api.masm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ end
#! Returns the account id.
#!
#! Inputs: [pad(16)]
#! Outputs: [acct_id, pad(15)]
#! Outputs: [acct_id_hi, acct_id_lo, pad(14)]
#!
#! Where:
#! - acct_id is the account id.
Expand All @@ -83,11 +83,11 @@ end
export.get_account_id
# get the account id
exec.account::get_id
# => [acct_id, pad(16)]
# => [acct_id_hi, acct_id_lo, pad(16)]

# truncate the stack
swap drop
# => [acct_id, pad(15)]
swapw dropw
# => [acct_id_hi, acct_id_lo, pad(14)]
end

#! Returns the account nonce.
Expand Down Expand Up @@ -229,7 +229,7 @@ export.set_account_item
# if the transaction is being executed against a faucet account then assert
# index != FAUCET_STORAGE_DATA_SLOT (reserved slot)
dup exec.account::get_faucet_storage_data_slot eq
exec.account::get_id exec.account::is_faucet
exec.account::get_id swap drop exec.account::is_faucet
and assertz.err=ERR_FAUCET_STORAGE_DATA_SLOT_IS_RESERVED
# => [index, V', pad(11)]

Expand Down Expand Up @@ -371,7 +371,7 @@ end

#! Returns the balance of a fungible asset associated with a faucet_id.
#!
#! Inputs: [faucet_id, pad(15)]
#! Inputs: [faucet_id_hi, faucet_id_lo, pad(14)]
#! Outputs: [balance, pad(15)]
#!
#! Where:
Expand All @@ -384,8 +384,8 @@ end
#! Invocation: dynexec
export.account_vault_get_balance
# get the vault root
exec.memory::get_acct_vault_root_ptr swap
# => [faucet_id, acct_vault_root_ptr, pad(15)]
exec.memory::get_acct_vault_root_ptr movdn.2
# => [faucet_id_hi, faucet_id_lo, acct_vault_root_ptr, pad(13)]

# get the asset balance
exec.asset_vault::get_balance
Expand Down Expand Up @@ -554,22 +554,22 @@ end
#! Returns the sender of the note currently being processed.
#!
#! Inputs: [pad(16)]
#! Outputs: [sender, pad(15)]
#! Outputs: [sender_hi, sender_lo, pad(14)]
#!
#! Where:
#! - sender is the sender of the note currently being processed.
#! - sender is the sender account id of the note currently being processed.
#!
#! Panics if:
#! - a note is not being processed.
#!
#! Invocation: dynexec
export.get_note_sender
exec.note::get_sender
# => [sender, pad(16)]
exec.note::get_sender
# => [sender_hi, sender_lo, pad(16)]

# truncate the stack
swap drop
# => [sender, pad(15)]
swapw dropw
# => [sender_hi, sender_lo, pad(14)]
end

#! Returns the block number of the last known block at the time of transaction execution.
Expand Down Expand Up @@ -818,7 +818,7 @@ end
#! Invocation: dynexec
export.get_fungible_faucet_total_issuance
# assert that we are executing a transaction against a fungible faucet (access checks)
exec.account::get_id exec.account::is_fungible_faucet
exec.account::get_id swap drop exec.account::is_fungible_faucet
assert.err=ERR_ACCOUNT_TOTAL_ISSUANCE_PROC_CAN_ONLY_BE_CALLED_ON_FUNGIBLE_FAUCET
# => [pad(16)]

Expand Down Expand Up @@ -879,10 +879,10 @@ end
#! Moves the account pointer to the currently accessing foreign account.
#!
#! Inputs:
#! Operand stack: [foreign_account_id, pad(15)]
#! Operand stack: [foreign_account_id_hi, foreign_account_id_lo, pad(14)]
#! Advice map: {
#! FOREIGN_ACCOUNT_ID: [[foreign_account_id, 0, 0, account_nonce], VAULT_ROOT, STORAGE_ROOT,
#! CODE_ROOT],
#! FOREIGN_ACCOUNT_ID: [[foreign_account_lo, foreign_account_id_hi, 0, 0, account_nonce],
#! VAULT_ROOT, STORAGE_ROOT, CODE_ROOT],
#! STORAGE_ROOT: [[STORAGE_SLOT_DATA]],
#! CODE_ROOT: [num_procs, [ACCOUNT_PROCEDURE_DATA]]
#! }
Expand All @@ -909,29 +909,30 @@ end
export.start_foreign_context
# check that this procedure was executed against the native account
exec.memory::assert_native_account
# OS => [foreign_account_id, pad(15)]
# OS => [foreign_account_id_hi, foreign_account_id_lo, pad(14)]

# get the memory address and a flag whether this account was already loaded.
exec.account::get_foreign_account_ptr
# OS => [was_loaded, ptr, foreign_account_id, pad(15)]
# OS => [was_loaded, ptr, foreign_account_id_hi, foreign_account_id_lo, pad(14)]

if.true
exec.memory::set_current_account_data_ptr drop
exec.memory::set_current_account_data_ptr drop drop
# OS => [pad(16)]
else
exec.memory::set_current_account_data_ptr
# OS => [foreign_account_id, pad(15)]
# OS => [foreign_account_id_hi, foreign_account_id_lo, pad(14)]

# construct the word with account ID to load the core account data from the advice map
push.0.0.0
# OS => [0, 0, 0, foreign_account_id, pad(15)]
swap push.0.0
# OS => [0, 0, foreign_account_id_lo, foreign_account_id_hi, pad(14)]

# move the core account data to the advice stack
adv.push_mapval
# OS => [0, 0, 0, foreign_account_id, pad(15)]
# OS => [0, 0, foreign_account_id_lo, foreign_account_id_hi, pad(14)]
# AS => [[foreign_account_id, 0, 0, account_nonce], VAULT_ROOT, STORAGE_ROOT, CODE_ROOT]

# store the id and nonce of the foreign account to the memory
# TODO: dropw can be optimized away?
dropw adv_loadw
exec.memory::set_acct_id_and_nonce dropw
# OS => [pad(16)]
Expand Down
Loading
Loading