From 2b24ef7982201dfc179b312fe95eadf905afe4be Mon Sep 17 00:00:00 2001 From: polydez <155382956+polydez@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:33:59 +0500 Subject: [PATCH] Updated to the latest `next` branch of `miden-objects` (#494) * fix: update to the latest `miden-objects` * refactor: remove use of `std::iter` --- Cargo.lock | 6 +++--- bin/faucet/src/client.rs | 14 +++++++------- crates/store/src/db/tests.rs | 11 ++++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33f0b1396..645e54f0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1788,7 +1788,7 @@ dependencies = [ [[package]] name = "miden-lib" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#36416cedee53a475ee33ec6222e101cf5811e0b8" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#7c05c8e108f2a33c60a977493bb368924ac89cf1" dependencies = [ "miden-assembly", "miden-objects", @@ -1976,7 +1976,7 @@ dependencies = [ [[package]] name = "miden-objects" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#36416cedee53a475ee33ec6222e101cf5811e0b8" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#7c05c8e108f2a33c60a977493bb368924ac89cf1" dependencies = [ "miden-assembly", "miden-core", @@ -2047,7 +2047,7 @@ dependencies = [ [[package]] name = "miden-tx" version = "0.6.0" -source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#36416cedee53a475ee33ec6222e101cf5811e0b8" +source = "git+https://github.com/0xPolygonMiden/miden-base.git?branch=next#7c05c8e108f2a33c60a977493bb368924ac89cf1" dependencies = [ "miden-lib", "miden-objects", diff --git a/bin/faucet/src/client.rs b/bin/faucet/src/client.rs index c6edf5076..595709b5c 100644 --- a/bin/faucet/src/client.rs +++ b/bin/faucet/src/client.rs @@ -22,8 +22,9 @@ use miden_objects::{ BlockHeader, Felt, Word, }; use miden_tx::{ - auth::BasicAuthenticator, utils::Serializable, DataStore, DataStoreError, ProvingOptions, - TransactionExecutor, TransactionInputs, TransactionProver, + auth::BasicAuthenticator, utils::Serializable, DataStore, DataStoreError, + LocalTransactionProver, ProvingOptions, TransactionExecutor, TransactionInputs, + TransactionProver, }; use rand::{rngs::StdRng, thread_rng, Rng}; use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng}; @@ -123,14 +124,13 @@ impl FaucetClient { &mut self, executed_tx: ExecutedTransaction, ) -> Result { - let transaction_prover = TransactionProver::new(ProvingOptions::default()); + let transaction_prover = LocalTransactionProver::new(ProvingOptions::default()); let delta = executed_tx.account_delta().clone(); - let proven_transaction = - transaction_prover.prove_transaction(executed_tx).map_err(|err| { - FaucetError::InternalServerError(format!("Failed to prove transaction: {}", err)) - })?; + let proven_transaction = transaction_prover.prove(executed_tx).map_err(|err| { + FaucetError::InternalServerError(format!("Failed to prove transaction: {}", err)) + })?; let request = SubmitProvenTransactionRequest { transaction: proven_transaction.to_bytes(), diff --git a/crates/store/src/db/tests.rs b/crates/store/src/db/tests.rs index f0621a1f6..af5dcba7e 100644 --- a/crates/store/src/db/tests.rs +++ b/crates/store/src/db/tests.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use miden_lib::transaction::TransactionKernel; use miden_node_proto::domain::accounts::AccountSummary; use miden_objects::{ @@ -11,7 +9,7 @@ use miden_objects::{ }, delta::AccountUpdateDetails, Account, AccountCode, AccountDelta, AccountId, AccountStorage, AccountStorageDelta, - AccountVaultDelta, + AccountVaultDelta, StorageSlot, }, assets::{Asset, AssetVault, FungibleAsset, NonFungibleAsset, NonFungibleAssetDetails}, block::{BlockAccountUpdate, BlockNoteIndex, BlockNoteTree}, @@ -335,7 +333,10 @@ fn test_sql_public_account_details() { let non_fungible_faucet_id = AccountId::try_from(ACCOUNT_ID_NON_FUNGIBLE_FAUCET_ON_CHAIN).unwrap(); - let mut storage = AccountStorage::new(vec![], BTreeMap::new()).unwrap(); + let mut storage = AccountStorage::new( + std::iter::repeat(StorageSlot::Value(Word::default())).take(6).collect(), + ) + .unwrap(); storage.set_item(1, num_to_word(1)).unwrap(); storage.set_item(3, num_to_word(3)).unwrap(); storage.set_item(5, num_to_word(5)).unwrap(); @@ -431,7 +432,7 @@ fn test_sql_public_account_details() { assert_eq!(account_read.nonce(), account.nonce()); // Cleared item was not serialized, check it and apply delta only with clear item second time: - assert_eq!(account_read.storage().get_item(3), RpoDigest::default()); + assert_eq!(account_read.storage().get_item(3), Ok(RpoDigest::default())); let storage_delta = AccountStorageDelta::from_iters([3], [], []); account_read