diff --git a/Cargo.lock b/Cargo.lock index 4cf663324..eb5f37ee8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,7 +177,7 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -188,7 +188,7 @@ checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -836,6 +836,31 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bon" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47dbe92550676ee653353c310dfb9cf6ba17ee70396e1f7cf0a2020ad49b2fe" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "3.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519bd3116aeeb42d5372c29d982d16d0170d3d4a5ed85fc7dd91642ffff3c67c" +dependencies = [ + "darling", + "ident_case", + "prettyplease", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.117", +] + [[package]] name = "build-rs" version = "0.3.3" @@ -1653,7 +1678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2269,7 +2294,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.3", + "socket2 0.5.10", "system-configuration", "tokio", "tower-service", @@ -2869,21 +2894,21 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "miden-agglayer" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4302fc29d77db3d2c6323d1b211e503aafb91db2d572ef30c68829347fe79352" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "alloy-sol-types", "fs-err", "miden-assembly", "miden-core", - "miden-core-lib", "miden-crypto", "miden-protocol", "miden-standards", "miden-utils-sync", "primitive-types", "regex", + "serde", + "serde_json", "thiserror 2.0.18", "walkdir", ] @@ -2945,9 +2970,8 @@ dependencies = [ [[package]] name = "miden-block-prover" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde56bcea3cebe307786a856e204d84e7987c318e5a2909bcbb655d16286ce31" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "miden-protocol", "thiserror 2.0.18", @@ -3563,9 +3587,8 @@ dependencies = [ [[package]] name = "miden-protocol" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e860cc978d3467297de076e9bd22f0573b82ef73a3d223d6bb957731a45b8164" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "bech32", "fs-err", @@ -3575,9 +3598,9 @@ dependencies = [ "miden-core", "miden-core-lib", "miden-crypto", + "miden-crypto-derive", "miden-mast-package", "miden-processor", - "miden-protocol-macros", "miden-utils-sync", "miden-verifier", "rand 0.9.2", @@ -3591,17 +3614,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "miden-protocol-macros" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4daec4a5a6f050a670a8639e78e017ab11ef0bf2e253b012505f25e6247c13e7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.117", -] - [[package]] name = "miden-prover" version = "0.22.1" @@ -3687,13 +3699,12 @@ dependencies = [ [[package]] name = "miden-standards" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f455a087f41c30636b45ead961d1e66114d2d20661887b307cede05307eeb942" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ + "bon", "fs-err", "miden-assembly", - "miden-core", "miden-core-lib", "miden-processor", "miden-protocol", @@ -3705,14 +3716,11 @@ dependencies = [ [[package]] name = "miden-testing" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84430e84c6dee90d9bd92568be1c3082113f0b4b36f9db7933380f0295207f9" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "anyhow", "itertools 0.14.0", - "miden-agglayer", - "miden-assembly", "miden-block-prover", "miden-core-lib", "miden-crypto", @@ -3728,9 +3736,8 @@ dependencies = [ [[package]] name = "miden-tx" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d788795041ce5e6f947a3256314373171e4877c11b86fafeabcec4d8b8628d9" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "miden-processor", "miden-protocol", @@ -3742,9 +3749,8 @@ dependencies = [ [[package]] name = "miden-tx-batch-prover" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce059e2d599266b00708f6f1bff6af5cf82683e76df3ec812c2d1c72e880f943" +version = "0.15.0" +source = "git+https://github.com/0xMiden/protocol?branch=next#ad7420e778af4a4b7be4f4bb24d0e7155b487e22" dependencies = [ "miden-protocol", "miden-tx", @@ -3958,7 +3964,7 @@ version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -4835,7 +4841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" dependencies = [ "heck", - "itertools 0.14.0", + "itertools 0.13.0", "log", "multimap", "petgraph 0.8.3", @@ -4856,7 +4862,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" dependencies = [ "anyhow", - "itertools 0.14.0", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.117", @@ -4978,7 +4984,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls 0.23.37", - "socket2 0.6.3", + "socket2 0.5.10", "thiserror 2.0.18", "tokio", "tracing", @@ -5016,7 +5022,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.3", + "socket2 0.5.10", "tracing", "windows-sys 0.60.2", ] @@ -5385,7 +5391,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -5456,7 +5462,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -5863,7 +5869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -6078,7 +6084,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -6087,7 +6093,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8c27177b12a6399ffc08b98f76f7c9a1f4fe9fc967c784c5a071fa8d93cf7e1" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -6106,7 +6112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" dependencies = [ "rustix", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -7110,7 +7116,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 268a5687d..b9741a73b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,13 +61,13 @@ miden-remote-prover-client = { path = "crates/remote-prover-client", versio miden-node-rocksdb-cxx-linkage-fix = { path = "crates/rocksdb-cxx-linkage-fix", version = "0.15" } # miden-protocol dependencies. These should be updated in sync. -miden-agglayer = { version = "0.14" } -miden-block-prover = { version = "0.14" } -miden-protocol = { default-features = false, version = "0.14" } -miden-standards = { version = "0.14" } -miden-testing = { version = "0.14" } -miden-tx = { default-features = false, version = "0.14" } -miden-tx-batch-prover = { version = "0.14" } +miden-agglayer = { branch = "next", git = "https://github.com/0xMiden/protocol" } +miden-block-prover = { branch = "next", git = "https://github.com/0xMiden/protocol" } +miden-protocol = { branch = "next", default-features = false, git = "https://github.com/0xMiden/protocol" } +miden-standards = { branch = "next", git = "https://github.com/0xMiden/protocol" } +miden-testing = { branch = "next", git = "https://github.com/0xMiden/protocol" } +miden-tx = { branch = "next", default-features = false, git = "https://github.com/0xMiden/protocol" } +miden-tx-batch-prover = { branch = "next", git = "https://github.com/0xMiden/protocol" } # Other miden dependencies. These should align with those expected by miden-protocol. miden-crypto = { version = "0.23" } diff --git a/bin/network-monitor/src/deploy/mod.rs b/bin/network-monitor/src/deploy/mod.rs index 5a998bd63..7cf162b5a 100644 --- a/bin/network-monitor/src/deploy/mod.rs +++ b/bin/network-monitor/src/deploy/mod.rs @@ -15,7 +15,7 @@ use miden_protocol::account::{Account, AccountId, PartialAccount, StorageMapKey} use miden_protocol::asset::{AssetVaultKey, AssetWitness}; use miden_protocol::block::{BlockHeader, BlockNumber}; use miden_protocol::crypto::merkle::mmr::{MmrPeaks, PartialMmr}; -use miden_protocol::note::NoteScript; +use miden_protocol::note::{NoteScript, NoteScriptRoot}; use miden_protocol::transaction::{AccountInputs, InputNotes, PartialBlockchain, TransactionArgs}; use miden_protocol::utils::serde::Serializable; use miden_protocol::{MastForest, Word}; @@ -324,7 +324,7 @@ impl DataStore for MonitorDataStore { async fn get_note_script( &self, - _script_root: Word, + _script_root: NoteScriptRoot, ) -> Result, DataStoreError> { Ok(None) } diff --git a/bin/stress-test/src/seeding/mod.rs b/bin/stress-test/src/seeding/mod.rs index 36cf0c69f..5d487e0b8 100644 --- a/bin/stress-test/src/seeding/mod.rs +++ b/bin/stress-test/src/seeding/mod.rs @@ -50,7 +50,14 @@ use miden_protocol::utils::serde::Serializable; use miden_protocol::vm::ExecutionProof; use miden_protocol::{Felt, ONE, Word}; use miden_standards::account::auth::AuthSingleSig; -use miden_standards::account::faucets::BasicFungibleFaucet; +use miden_standards::account::faucets::{BasicFungibleFaucet, TokenMetadata}; +use miden_standards::account::metadata::{FungibleTokenMetadata, TokenName}; +use miden_standards::account::policies::{ + BurnPolicyConfig, + MintPolicyConfig, + PolicyAuthority, + TokenPolicyManager, +}; use miden_standards::account::wallets::BasicWallet; use miden_standards::note::P2idNote; use rand::Rng; @@ -279,7 +286,7 @@ async fn apply_block( /// Extract the payable fee as `FungibleAsset` from the given `BlockHeader`. fn fee_from_block(block_ref: &BlockHeader) -> Result { FungibleAsset::new( - block_ref.fee_parameters().native_asset_id(), + block_ref.fee_parameters().fee_faucet_id(), u64::from(block_ref.fee_parameters().verification_base_fee()), ) } @@ -350,10 +357,24 @@ fn create_faucet() -> Account { let init_seed = [0_u8; 32]; let token_symbol = TokenSymbol::new("TEST").unwrap(); + let token_metadata = FungibleTokenMetadata::builder( + TokenName::new("TEST").unwrap(), + token_symbol, + 2, + FungibleAsset::MAX_AMOUNT, + ) + .build() + .unwrap(); AccountBuilder::new(init_seed) .account_type(AccountType::FungibleFaucet) .storage_mode(AccountStorageMode::Private) - .with_component(BasicFungibleFaucet::new(token_symbol, 2, Felt::new(u64::MAX)).unwrap()) + .with_component(token_metadata) + .with_component(BasicFungibleFaucet) + .with_components(TokenPolicyManager::new( + PolicyAuthority::AuthControlled, + MintPolicyConfig::AllowAll, + BurnPolicyConfig::AllowAll, + )) .with_auth_component(AuthSingleSig::new( key_pair.public_key().into(), AuthScheme::Falcon512Poseidon2, @@ -370,7 +391,7 @@ fn create_batch(txs: &[ProvenTransaction], block_ref: &BlockHeader) -> ProvenBat .collect(); let input_notes = txs.iter().flat_map(|tx| tx.input_notes().iter().cloned()).collect(); let output_notes = txs.iter().flat_map(|tx| tx.output_notes().iter().cloned()).collect(); - ProvenBatch::new( + ProvenBatch::new_unchecked( BatchId::from_transactions(txs.iter()), block_ref.commitment(), block_ref.block_num(), @@ -458,7 +479,7 @@ fn create_emit_note_tx( ) -> ProvenTransaction { let initial_account_hash = faucet.to_commitment(); - let metadata_slot_name = BasicFungibleFaucet::metadata_slot(); + let metadata_slot_name = TokenMetadata::metadata_slot(); let slot = faucet.storage().get_item(metadata_slot_name).unwrap(); faucet .storage_mut() @@ -485,7 +506,7 @@ fn create_emit_note_tx( block_ref.block_num(), block_ref.commitment(), FungibleAsset::new( - block_ref.fee_parameters().native_asset_id(), + block_ref.fee_parameters().fee_faucet_id(), u64::from(block_ref.fee_parameters().verification_base_fee()), ) .unwrap(), diff --git a/crates/block-producer/src/test_utils/batch.rs b/crates/block-producer/src/test_utils/batch.rs index ca705e241..df97d3ea4 100644 --- a/crates/block-producer/src/test_utils/batch.rs +++ b/crates/block-producer/src/test_utils/batch.rs @@ -59,7 +59,7 @@ impl TransactionBatchConstructor for ProvenBatch { output_notes.extend(tx.output_notes().iter().cloned()); } - ProvenBatch::new( + ProvenBatch::new_unchecked( BatchId::from_transactions(txs.iter().copied()), Word::empty(), BlockNumber::GENESIS, diff --git a/crates/ntx-builder/src/actor/execute.rs b/crates/ntx-builder/src/actor/execute.rs index dba9a8f24..fca948e10 100644 --- a/crates/ntx-builder/src/actor/execute.rs +++ b/crates/ntx-builder/src/actor/execute.rs @@ -18,7 +18,7 @@ use miden_protocol::account::{ use miden_protocol::asset::{AssetVaultKey, AssetWitness}; use miden_protocol::block::{BlockHeader, BlockNumber}; use miden_protocol::errors::TransactionInputError; -use miden_protocol::note::{Note, NoteScript}; +use miden_protocol::note::{Note, NoteScript, NoteScriptRoot}; use miden_protocol::transaction::{ AccountInputs, ExecutedTransaction, @@ -43,7 +43,6 @@ use miden_tx::{ MastForestStore, NoteCheckerError, NoteConsumptionChecker, - NoteConsumptionInfo, TransactionExecutor, TransactionExecutorError, TransactionMastStore, @@ -270,18 +269,21 @@ impl NtxContext { )) .await { - Ok(NoteConsumptionInfo { successful, failed, .. }) => { + Ok(consumption_info) => { + let (successful, failed) = consumption_info.into_parts(); for failed_note in &failed { tracing::info!( - note.id = %failed_note.note.id(), - nullifier = %failed_note.note.nullifier(), - err = %failed_note.error.as_report(), + note.id = %failed_note.note().id(), + nullifier = %failed_note.note().nullifier(), + err = %failed_note.error().as_report(), "note failed consumability check", ); } // Map successful notes to input notes. - let successful = InputNotes::from_unauthenticated_notes(successful) + let successful_notes = + successful.into_iter().map(|s| s.note().clone()).collect::>(); + let successful = InputNotes::from_unauthenticated_notes(successful_notes) .map_err(NtxError::InputNotes)?; // If none are successful, abort. @@ -564,9 +566,10 @@ impl DataStore for NtxDataStore { /// 3. Remote store via gRPC. fn get_note_script( &self, - script_root: Word, + script_root: NoteScriptRoot, ) -> impl FutureMaybeSend, DataStoreError>> { async move { + let script_root = Word::from(script_root); // 1. In-memory LRU cache. if let Some(cached_script) = self.script_cache.get(&script_root) { return Ok(Some(cached_script)); diff --git a/crates/ntx-builder/src/actor/mod.rs b/crates/ntx-builder/src/actor/mod.rs index 4bd1d42ff..1b67f353b 100644 --- a/crates/ntx-builder/src/actor/mod.rs +++ b/crates/ntx-builder/src/actor/mod.rs @@ -528,14 +528,15 @@ fn log_failed_notes(failed: Vec) -> Vec<(Nullifier, NoteError)> { failed .into_iter() .map(|f| { - let error_msg = f.error.as_report(); + let error_msg = f.error().as_report(); tracing::info!( - note.id = %f.note.id(), - nullifier = %f.note.nullifier(), + note.id = %f.note().id(), + nullifier = %f.note().nullifier(), err = %error_msg, "note failed: consumability check", ); - (f.note.nullifier(), Arc::new(f.error) as NoteError) + let error: NoteError = Arc::new(std::io::Error::other(error_msg)); + (f.note().nullifier(), error) }) .collect() } diff --git a/crates/ntx-builder/src/clients/store.rs b/crates/ntx-builder/src/clients/store.rs index 49bebb522..c901fc69a 100644 --- a/crates/ntx-builder/src/clients/store.rs +++ b/crates/ntx-builder/src/clients/store.rs @@ -494,7 +494,7 @@ pub fn build_minimal_foreign_account( "account_code", ) })?; - let account_code = AccountCode::from_bytes(account_code_bytes)?; + let account_code = AccountCode::read_from_bytes(account_code_bytes)?; // Derive partial storage. Storage maps are not required for foreign accounts. let partial_storage = PartialStorage::new(account_details.storage_details.header.clone(), [])?; diff --git a/crates/ntx-builder/src/db/models/queries/tests.rs b/crates/ntx-builder/src/db/models/queries/tests.rs index 108dcab61..f46b1aafa 100644 --- a/crates/ntx-builder/src/db/models/queries/tests.rs +++ b/crates/ntx-builder/src/db/models/queries/tests.rs @@ -602,7 +602,7 @@ fn note_script_insert_and_lookup() { let account_id = mock_network_account_id(); let note: miden_protocol::note::Note = mock_single_target_note(account_id, 10).into_note(); let script = note.script().clone(); - let root = script.root(); + let root = Word::from(script.root()); // Insert the script. insert_note_script(conn, &root, &script).unwrap(); @@ -629,7 +629,7 @@ fn note_script_insert_is_idempotent() { let account_id = mock_network_account_id(); let note: miden_protocol::note::Note = mock_single_target_note(account_id, 10).into_note(); let script = note.script().clone(); - let root = script.root(); + let root = Word::from(script.root()); // Insert the same script twice — should not error. insert_note_script(conn, &root, &script).unwrap(); diff --git a/crates/proto/src/domain/block.rs b/crates/proto/src/domain/block.rs index 19a4bf8bf..c41974641 100644 --- a/crates/proto/src/domain/block.rs +++ b/crates/proto/src/domain/block.rs @@ -326,7 +326,7 @@ impl From for proto::blockchain::FeeParameters { impl From<&FeeParameters> for proto::blockchain::FeeParameters { fn from(value: &FeeParameters) -> Self { Self { - native_asset_id: Some(value.native_asset_id().into()), + native_asset_id: Some(value.fee_faucet_id().into()), verification_base_fee: value.verification_base_fee(), } } diff --git a/crates/store/src/db/migrations/2025062000000_setup/up.sql b/crates/store/src/db/migrations/2025062000000_setup/up.sql index 93a309eab..2f8538d98 100644 --- a/crates/store/src/db/migrations/2025062000000_setup/up.sql +++ b/crates/store/src/db/migrations/2025062000000_setup/up.sql @@ -58,7 +58,7 @@ CREATE TABLE notes ( note_index INTEGER NOT NULL, -- Index of note in batch, starting from 0 note_id BLOB NOT NULL, note_commitment BLOB NOT NULL, - note_type INTEGER NOT NULL, -- 1-Public (0b01), 2-Private (0b10), 3-Encrypted (0b11) + note_type INTEGER NOT NULL, -- 0-Private, 1-Public sender BLOB NOT NULL, tag INTEGER NOT NULL, network_note_type INTEGER NOT NULL, -- 0-not a network note, 1-single account target network note @@ -73,7 +73,7 @@ CREATE TABLE notes ( serial_num BLOB, PRIMARY KEY (committed_at, batch_index, note_index), - CONSTRAINT notes_type_in_enum CHECK (note_type BETWEEN 1 AND 3), + CONSTRAINT notes_type_in_enum CHECK (note_type BETWEEN 0 AND 1), CONSTRAINT notes_network_note_type_in_enum CHECK (network_note_type BETWEEN 0 AND 1), CONSTRAINT notes_consumed_at_is_u32 CHECK (consumed_at BETWEEN 0 AND 0xFFFFFFFF), CONSTRAINT notes_batch_index_is_u32 CHECK (batch_index BETWEEN 0 AND 0xFFFFFFFF), diff --git a/crates/store/src/db/models/queries/notes.rs b/crates/store/src/db/models/queries/notes.rs index 28871a0bb..5b1eba78a 100644 --- a/crates/store/src/db/models/queries/notes.rs +++ b/crates/store/src/db/models/queries/notes.rs @@ -803,12 +803,12 @@ pub struct NoteMetadataRawRow { attachment: Vec, } -#[expect(clippy::cast_sign_loss)] +#[expect(clippy::cast_sign_loss, clippy::cast_possible_truncation)] impl TryInto for NoteMetadataRawRow { type Error = DatabaseError; fn try_into(self) -> Result { let sender = AccountId::read_from_bytes(&self.sender[..])?; - let note_type = NoteType::try_from(self.note_type as u32) + let note_type = NoteType::try_from(self.note_type as u8) .map_err(miden_node_db::DatabaseError::conversiont_from_sql::)?; let tag = NoteTag::new(self.tag as u32); let attachment = NoteAttachment::read_from_bytes(&self.attachment)?; diff --git a/crates/store/src/db/tests.rs b/crates/store/src/db/tests.rs index e298ce9f0..1c582066a 100644 --- a/crates/store/src/db/tests.rs +++ b/crates/store/src/db/tests.rs @@ -319,7 +319,8 @@ fn sql_select_note_script_by_root() { assert_eq!(res.unwrap(), 1, "One element must have been inserted"); // test querying the script by the root - let note_script = queries::select_note_script_by_root(conn, new_note.script().root()).unwrap(); + let note_script = + queries::select_note_script_by_root(conn, Word::from(new_note.script().root())).unwrap(); assert_eq!(note_script, Some(new_note.script().clone())); // test querying the script by the root that is not in the database diff --git a/crates/store/src/genesis/config/mod.rs b/crates/store/src/genesis/config/mod.rs index 6c70a6f38..66c53307d 100644 --- a/crates/store/src/genesis/config/mod.rs +++ b/crates/store/src/genesis/config/mod.rs @@ -29,7 +29,13 @@ use miden_protocol::{Felt, ONE}; use miden_standards::AuthMethod; use miden_standards::account::auth::AuthSingleSig; use miden_standards::account::faucets::{BasicFungibleFaucet, TokenMetadata}; -use miden_standards::account::mint_policies::AuthControlled; +use miden_standards::account::metadata::{FungibleTokenMetadata, TokenName}; +use miden_standards::account::policies::{ + BurnPolicyConfig, + MintPolicyConfig, + PolicyAuthority, + TokenPolicyManager, +}; use miden_standards::account::wallets::create_basic_wallet; use rand::distr::weighted::Weight; use rand::{Rng, SeedableRng}; @@ -311,8 +317,8 @@ impl GenesisConfig { debug_assert_eq!(faucet_account.nonce(), ONE); // sanity check the total issuance against - let basic = BasicFungibleFaucet::try_from(&faucet_account)?; - let max_supply = basic.max_supply().as_canonical_u64(); + let metadata = TokenMetadata::try_from(faucet_account.storage())?; + let max_supply = metadata.max_supply().as_canonical_u64(); if max_supply < total_issuance { return Err(GenesisConfigError::MaxIssuanceExceeded { max_supply, @@ -394,9 +400,9 @@ impl NativeFaucetConfig { return Err(GenesisConfigError::NativeFaucetNotFungible { path: full_path }); } - let faucet = BasicFungibleFaucet::try_from(&account) + let metadata = TokenMetadata::try_from(account.storage()) .expect("validated as fungible faucet above"); - let symbol = TokenSymbolStr::from(faucet.symbol().clone()); + let symbol = TokenSymbolStr::from(metadata.symbol().clone()); Ok((account, symbol, None)) }, } @@ -436,18 +442,27 @@ impl FungibleFaucetConfig { AuthSingleSig::new(secret_key.public_key().into(), AuthScheme::Falcon512Poseidon2); let init_seed: [u8; 32] = rng.random(); - let max_supply = Felt::try_from(max_supply) - .expect("The `Felt::MODULUS` is _always_ larger than the `max_supply`"); - - let component = BasicFungibleFaucet::new(symbol.as_ref().clone(), decimals, max_supply)?; + let token_metadata = FungibleTokenMetadata::builder( + TokenName::new(&symbol.to_string()) + .expect("token symbol fits within token name byte limit"), + symbol.as_ref().clone(), + decimals, + max_supply, + ) + .build()?; // It's similar to `fn create_basic_fungible_faucet`, but we need to cover more cases. let faucet_account = AccountBuilder::new(init_seed) .account_type(AccountType::FungibleFaucet) .storage_mode(storage_mode.into()) .with_auth_component(auth) - .with_component(component) - .with_component(AuthControlled::allow_all()) + .with_component(token_metadata) + .with_component(BasicFungibleFaucet) + .with_components(TokenPolicyManager::new( + PolicyAuthority::AuthControlled, + MintPolicyConfig::AllowAll, + BurnPolicyConfig::AllowAll, + )) .build()?; debug_assert_eq!(faucet_account.nonce(), Felt::ZERO); diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac index d20f2d85f..2753dd76d 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_eth.mac differ diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac index 89d1231c9..9f7a0a2cb 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/agglayer_faucet_usdc.mac differ diff --git a/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac b/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac index 4eaf26f63..607ba4c8c 100644 Binary files a/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac and b/crates/store/src/genesis/config/samples/02-with-account-files/bridge.mac differ diff --git a/crates/store/src/genesis/config/tests.rs b/crates/store/src/genesis/config/tests.rs index acc1b9446..6641bf4fe 100644 --- a/crates/store/src/genesis/config/tests.rs +++ b/crates/store/src/genesis/config/tests.rs @@ -44,11 +44,11 @@ fn parsing_yields_expected_default_values() -> TestResult { assert_eq!(wallet2.nonce(), ONE); { - let faucet = BasicFungibleFaucet::try_from(native_faucet.clone()).unwrap(); + let metadata = TokenMetadata::try_from(native_faucet.storage()).unwrap(); - assert_eq!(faucet.max_supply(), Felt::new(100_000_000_000_000_000)); - assert_eq!(faucet.decimals(), 6); - assert_eq!(*faucet.symbol(), TokenSymbol::new("MIDEN").unwrap()); + assert_eq!(metadata.max_supply(), Felt::new(100_000_000_000_000_000)); + assert_eq!(metadata.decimals(), 6); + assert_eq!(*metadata.symbol(), TokenSymbol::new("MIDEN").unwrap()); } // check account balance, and ensure ordering is retained @@ -145,6 +145,13 @@ fn parsing_native_faucet_from_file() -> TestResult { use miden_protocol::account::auth::AuthScheme; use miden_protocol::account::{AccountBuilder, AccountFile, AccountStorageMode, AccountType}; use miden_standards::account::auth::AuthSingleSig; + use miden_standards::account::metadata::{FungibleTokenMetadata, TokenName}; + use miden_standards::account::policies::{ + BurnPolicyConfig, + MintPolicyConfig, + PolicyAuthority, + TokenPolicyManager, + }; use tempfile::tempdir; // Create a temporary directory for our test files @@ -159,14 +166,25 @@ fn parsing_native_faucet_from_file() -> TestResult { ); let auth = AuthSingleSig::new(secret_key.public_key().into(), AuthScheme::Falcon512Poseidon2); - let faucet_component = - BasicFungibleFaucet::new(TokenSymbol::new("MIDEN").unwrap(), 6, Felt::new(1_000_000_000))?; + let token_metadata = FungibleTokenMetadata::builder( + TokenName::new("MIDEN").unwrap(), + TokenSymbol::new("MIDEN").unwrap(), + 6, + 1_000_000_000, + ) + .build()?; let faucet_account = AccountBuilder::new(init_seed) .account_type(AccountType::FungibleFaucet) .storage_mode(AccountStorageMode::Public) .with_auth_component(auth) - .with_component(faucet_component) + .with_component(token_metadata) + .with_component(BasicFungibleFaucet) + .with_components(TokenPolicyManager::new( + PolicyAuthority::AuthControlled, + MintPolicyConfig::AllowAll, + BurnPolicyConfig::AllowAll, + )) .build()?; let faucet_id = faucet_account.id(); @@ -327,8 +345,8 @@ async fn parsing_agglayer_sample_with_account_files() -> TestResult { // Verify native faucet symbol { - let faucet = BasicFungibleFaucet::try_from(native_faucet.clone()).unwrap(); - assert_eq!(*faucet.symbol(), TokenSymbol::new("MIDEN").unwrap()); + let metadata = TokenMetadata::try_from(native_faucet.storage()).unwrap(); + assert_eq!(*metadata.symbol(), TokenSymbol::new("MIDEN").unwrap()); } // Bridge account is a regular account (not a faucet) diff --git a/crates/utils/src/fee.rs b/crates/utils/src/fee.rs index 5bde43284..33c4472ba 100644 --- a/crates/utils/src/fee.rs +++ b/crates/utils/src/fee.rs @@ -1,16 +1,16 @@ use miden_protocol::asset::FungibleAsset; use miden_protocol::block::FeeParameters; -use miden_protocol::testing::account_id::ACCOUNT_ID_NATIVE_ASSET_FAUCET; +use miden_protocol::testing::account_id::ACCOUNT_ID_FEE_FAUCET; /// Derive a default, zero valued fee, payable to -/// [`miden_protocol::testing::account_id::ACCOUNT_ID_NATIVE_ASSET_FAUCET`]. +/// [`miden_protocol::testing::account_id::ACCOUNT_ID_FEE_FAUCET`]. pub fn test_fee() -> FungibleAsset { - let faucet = ACCOUNT_ID_NATIVE_ASSET_FAUCET.try_into().unwrap(); + let faucet = ACCOUNT_ID_FEE_FAUCET.try_into().unwrap(); FungibleAsset::new(faucet, 0).unwrap() } /// Derive the default fee parameters, compatible with [`fn test_fee`]. pub fn test_fee_params() -> FeeParameters { - let faucet = ACCOUNT_ID_NATIVE_ASSET_FAUCET.try_into().unwrap(); + let faucet = ACCOUNT_ID_FEE_FAUCET.try_into().unwrap(); FeeParameters::new(faucet, 0).unwrap() } diff --git a/crates/validator/src/server/tests.rs b/crates/validator/src/server/tests.rs index 66357ab22..8d55f6a7e 100644 --- a/crates/validator/src/server/tests.rs +++ b/crates/validator/src/server/tests.rs @@ -312,7 +312,7 @@ async fn unknown_transactions_rejected() { // Build a dummy transaction header with a transaction ID that has NOT been // submitted through `submit_proven_transaction`. let account_id = ACCOUNT_ID_SENDER.try_into().unwrap(); - let fee = FungibleAsset::new(test_fee_params().native_asset_id(), 0).unwrap(); + let fee = FungibleAsset::new(test_fee_params().fee_faucet_id(), 0).unwrap(); let tx_header = TransactionHeader::new( account_id, Word::default(), @@ -324,7 +324,7 @@ async fn unknown_transactions_rejected() { let tx_id = tx_header.id(); // Build a ProvenBatch containing this transaction. - let batch = ProvenBatch::new( + let batch = ProvenBatch::new_unchecked( BatchId::from_ids(std::iter::once((tx_id, account_id))), genesis_header.commitment(), BlockNumber::GENESIS, diff --git a/crates/validator/src/tx_validation/data_store.rs b/crates/validator/src/tx_validation/data_store.rs index ac143ef3b..9b9742107 100644 --- a/crates/validator/src/tx_validation/data_store.rs +++ b/crates/validator/src/tx_validation/data_store.rs @@ -6,7 +6,7 @@ use miden_protocol::Word; use miden_protocol::account::{AccountId, PartialAccount, StorageMapKey, StorageMapWitness}; use miden_protocol::asset::{AssetVaultKey, AssetWitness}; use miden_protocol::block::{BlockHeader, BlockNumber}; -use miden_protocol::note::NoteScript; +use miden_protocol::note::{NoteScript, NoteScriptRoot}; use miden_protocol::transaction::{AccountInputs, PartialBlockchain, TransactionInputs}; use miden_protocol::vm::FutureMaybeSend; use miden_tx::{DataStore, DataStoreError, MastForestStore, TransactionMastStore}; @@ -94,7 +94,7 @@ impl DataStore for TransactionInputsDataStore { fn get_note_script( &self, - _script_root: Word, + _script_root: NoteScriptRoot, ) -> impl FutureMaybeSend, DataStoreError>> { async move { unimplemented!("get_note_script is not used during re-execution of transactions") } }