Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -9,6 +9,7 @@
### Changes

- [BREAKING] Make `AccountProcedureIndexMap` construction infallible ([#2163](https://github.com/0xMiden/miden-base/pull/2163)).
- [BREAKING] Enforce minimum number of account procedures in tx kernel ([#2171](https://github.com/0xMiden/miden-base/pull/2171)).

## 0.12.2 (unreleased)
- Add proc-macro `WordWrapper` to ease implementation of `Word`-wrapping types ([#2071](https://github.com/0xMiden/miden-base/pull/2108)).
Expand Down
19 changes: 17 additions & 2 deletions crates/miden-lib/asm/kernels/transaction/lib/account.masm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ const.ERR_FAUCET_INVALID_STORAGE_OFFSET="storage offset is invalid for a faucet

const.ERR_ACCOUNT_CODE_COMMITMENT_MISMATCH="computed account code commitment does not match recorded account code commitment"

const.ERR_ACCOUNT_NOT_ENOUGH_PROCEDURES="number of account procedures must be at least 2"

const.ERR_ACCOUNT_TOO_MANY_PROCEDURES="number of account procedures exceeds the maximum limit of 256"

const.ERR_ACCOUNT_TOO_MANY_STORAGE_SLOTS="number of account storage slots exceeds the maximum limit of 255"
Expand Down Expand Up @@ -77,6 +79,9 @@ const.MAX_STORAGE_SLOT_INDEX=254
# The maximum number of account storage slots.
const.MAX_NUM_STORAGE_SLOTS=MAX_STORAGE_SLOT_INDEX+1

# The minimum number of account interface procedures.
const.MIN_NUM_PROCEDURES=2

# The maximum number of account interface procedures.
const.MAX_NUM_PROCEDURES=256

Expand Down Expand Up @@ -1377,8 +1382,18 @@ export.save_account_procedure_data
# OS => [num_procs, CODE_COMMITMENT]
# AS => [[ACCOUNT_PROCEDURE_DATA]]

# assert that account does not exceed allowed maximum number of procedures
dup exec.get_max_num_procedures lte assert.err=ERR_ACCOUNT_TOO_MANY_PROCEDURES
# make sure number of procedures is a valid u32, so we can use u32 operations for validation
u32assert.err=ERR_ACCOUNT_TOO_MANY_PROCEDURES
# OS => [num_procs, CODE_COMMITMENT]
# AS => [[ACCOUNT_PROCEDURE_DATA]]

# assert the account has at least the minimum number of procedures
dup u32gte.MIN_NUM_PROCEDURES assert.err=ERR_ACCOUNT_NOT_ENOUGH_PROCEDURES
# OS => [num_procs, CODE_COMMITMENT]
# AS => [[ACCOUNT_PROCEDURE_DATA]]

# assert the account does not exceed the maximum number of procedures
dup u32lte.MAX_NUM_PROCEDURES assert.err=ERR_ACCOUNT_TOO_MANY_PROCEDURES
# OS => [num_procs, CODE_COMMITMENT]
# AS => [[ACCOUNT_PROCEDURE_DATA]]

Expand Down
2 changes: 2 additions & 0 deletions crates/miden-lib/src/errors/tx_kernel_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub const ERR_ACCOUNT_IS_NOT_NATIVE: MasmError = MasmError::from_static_str("the
pub const ERR_ACCOUNT_NONCE_AT_MAX: MasmError = MasmError::from_static_str("account nonce is already at its maximum possible value");
/// Error Message: "account nonce can only be incremented once"
pub const ERR_ACCOUNT_NONCE_CAN_ONLY_BE_INCREMENTED_ONCE: MasmError = MasmError::from_static_str("account nonce can only be incremented once");
/// Error Message: "number of account procedures must be at least 2"
pub const ERR_ACCOUNT_NOT_ENOUGH_PROCEDURES: MasmError = MasmError::from_static_str("number of account procedures must be at least 2");
/// Error Message: "provided procedure index is out of bounds"
pub const ERR_ACCOUNT_PROC_INDEX_OUT_OF_BOUNDS: MasmError = MasmError::from_static_str("provided procedure index is out of bounds");
/// Error Message: "account procedure is not the authentication procedure; some procedures (e.g. `incr_nonce`) can be called only from the authentication procedure"
Expand Down
2 changes: 1 addition & 1 deletion crates/miden-lib/src/transaction/kernel_procedures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub const KERNEL_PROCEDURES: [Word; 52] = [
// tx_get_block_timestamp
word!("0x7903185b847517debb6c2072364e3e757b99ee623e97c2bd0a4661316c5c5418"),
// tx_start_foreign_context
word!("0x4bfde60ab4b1e42148ceea2845ecf9aae061a577972baf348379701760d476d7"),
word!("0x3755ddea584a3575bc3c97820f739d562334b91ab8c00642b519b4e22792b191"),
// tx_end_foreign_context
word!("0xaa0018aa8da890b73511879487f65553753fb7df22de380dd84c11e6f77eec6f"),
// tx_get_expiration_delta
Expand Down