Skip to content

Commit 1bee2f7

Browse files
committed
refactor: Use BlockNumber instead of u32 and update miden-base
1 parent 4196611 commit 1bee2f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+919
-490
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* [BREAKING] Added support for specifying map storage slots for FPI (#645)
1414
* Limited the number of decimals that an asset can have (#666).
1515
* [BREAKING] Removed the `testing` feature from the CLI (#670).
16+
* Added per transaction prover support to the web client (#674).
17+
* [BREAKING] Added `BlockNumber` structure (#677).
1618

1719
### Fixes
1820

Cargo.lock

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async-trait = "0.1"
2222
miden-lib = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false }
2323
miden-objects = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false }
2424
miden-tx = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", default-features = false, features = ["async"] }
25-
miden-remote-provers = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", features = ["tx-prover"] }
25+
miden-proving-service-client = { git = "https://github.com/0xPolygonMiden/miden-base", branch = "next", features = ["tx-prover"] }
2626
rand = { version = "0.8" }
2727
serde = { version = "1.0", features = ["derive"] }
2828
thiserror = { version = "2.0", default-features = false }

bin/miden-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ comfy-table = { version = "7.1" }
3737
figment = { version = "0.10", features = ["toml", "env"] }
3838
miden-client = { version = "0.6", path = "../../crates/rust-client", features = ["sqlite", "tonic"] }
3939
miden-lib = { workspace = true }
40-
miden-remote-provers = { workspace = true }
40+
miden-proving-service-client = { workspace = true , features = ["std", "tx-prover"]}
4141
rand = { workspace = true }
4242
serde = { version = "1.0", features = ["derive"] }
4343
tokio = { workspace = true }

bin/miden-cli/src/commands/new_transactions.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ use miden_client::{
55
accounts::AccountId,
66
assets::{FungibleAsset, NonFungibleDeltaAction},
77
crypto::{Digest, FeltRng},
8-
notes::{build_swap_tag, get_input_note_with_id_prefix, NoteType as MidenNoteType},
8+
notes::{
9+
build_swap_tag, get_input_note_with_id_prefix, BlockNumber, NoteType as MidenNoteType,
10+
},
911
transactions::{
1012
PaymentTransactionData, SwapTransactionData, TransactionRequest, TransactionRequestBuilder,
1113
TransactionResult,
1214
},
1315
Client,
1416
};
15-
use miden_remote_provers::RemoteTransactionProver;
17+
use miden_proving_service_client::RemoteTransactionProver;
1618
use tracing::info;
1719

1820
use crate::{
@@ -142,7 +144,7 @@ impl SendCmd {
142144

143145
let transaction_request = TransactionRequestBuilder::pay_to_id(
144146
payment_transaction,
145-
self.recall_height,
147+
self.recall_height.map(BlockNumber::from),
146148
(&self.note_type).into(),
147149
client.rng(),
148150
)

bin/miden-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use miden_cli::Cli;
22

3-
extern crate alloc;
3+
extern crate std;
44

55
#[tokio::main]
66
async fn main() -> Result<(), String> {

bin/miden-cli/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ async fn debug_mode_outputs_logs() {
698698
// Export the note
699699
let note_file: NoteFile = NoteFile::NoteDetails {
700700
details: note.clone().into(),
701-
after_block_num: 0,
701+
after_block_num: 0.into(),
702702
tag: Some(note.metadata().tag()),
703703
};
704704

crates/rust-client/src/accounts.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,19 @@ impl<R: FeltRng> Client<R> {
184184
pub struct AccountUpdates {
185185
/// Updated public accounts.
186186
updated_public_accounts: Vec<Account>,
187-
/// Node account hashes that don't match the tracked information.
188-
mismatched_offchain_accounts: Vec<(AccountId, Digest)>,
187+
/// Node account hashes that don't match the current tracked state for private accounts.
188+
mismatched_private_accounts: Vec<(AccountId, Digest)>,
189189
}
190190

191191
impl AccountUpdates {
192192
/// Creates a new instance of `AccountUpdates`.
193193
pub fn new(
194194
updated_public_accounts: Vec<Account>,
195-
mismatched_offchain_accounts: Vec<(AccountId, Digest)>,
195+
mismatched_private_accounts: Vec<(AccountId, Digest)>,
196196
) -> Self {
197197
Self {
198198
updated_public_accounts,
199-
mismatched_offchain_accounts,
199+
mismatched_private_accounts,
200200
}
201201
}
202202

@@ -205,9 +205,9 @@ impl AccountUpdates {
205205
&self.updated_public_accounts
206206
}
207207

208-
/// Returns the mismatched offchain accounts.
209-
pub fn mismatched_offchain_accounts(&self) -> &[(AccountId, Digest)] {
210-
&self.mismatched_offchain_accounts
208+
/// Returns the mismatched private accounts.
209+
pub fn mismatched_private_accounts(&self) -> &[(AccountId, Digest)] {
210+
&self.mismatched_private_accounts
211211
}
212212
}
213213

crates/rust-client/src/mock.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use miden_lib::transaction::TransactionKernel;
1010
use miden_objects::{
1111
accounts::{AccountCode, AccountId},
1212
assets::{FungibleAsset, NonFungibleAsset},
13-
block::Block,
13+
block::{Block, BlockNumber},
1414
crypto::{
1515
merkle::{Mmr, MmrProof},
1616
rand::RpoRandomCoin,
@@ -127,17 +127,17 @@ impl MockRpcApi {
127127
}
128128

129129
/// Returns the chain tip block number.
130-
fn get_chain_tip_block_num(&self) -> u32 {
130+
fn get_chain_tip_block_num(&self) -> BlockNumber {
131131
self.blocks.last().map(|b| b.header().block_num()).unwrap()
132132
}
133133

134134
/// Retrieves a block by its block number.
135-
fn get_block_by_num(&self, block_num: u32) -> Option<&Block> {
136-
self.blocks.get(block_num as usize)
135+
fn get_block_by_num(&self, block_num: BlockNumber) -> Option<&Block> {
136+
self.blocks.get(block_num.as_usize())
137137
}
138138

139139
/// Generates a sync state response based on the request block number.
140-
pub fn get_sync_state_request(&self, request_block_num: u32) -> SyncStateResponse {
140+
pub fn get_sync_state_request(&self, request_block_num: BlockNumber) -> SyncStateResponse {
141141
// Determine the next block number to sync
142142
let next_block_num = self
143143
.notes
@@ -156,7 +156,7 @@ impl MockRpcApi {
156156
// Prepare the MMR delta
157157
let mmr_delta = self
158158
.get_mmr()
159-
.get_delta((request_block_num + 1) as usize, next_block_num as usize)
159+
.get_delta((request_block_num.as_u32() + 1) as usize, next_block_num.as_usize())
160160
.ok()
161161
.map(Into::into);
162162

@@ -169,12 +169,12 @@ impl MockRpcApi {
169169
.iter()
170170
.map(|n| NullifierUpdate {
171171
nullifier: Some(n.inner().into()),
172-
block_num: next_block_num,
172+
block_num: next_block_num.as_u32(),
173173
})
174174
.collect();
175175

176176
SyncStateResponse {
177-
chain_tip: self.get_chain_tip_block_num(),
177+
chain_tip: self.get_chain_tip_block_num().as_u32(),
178178
block_header: Some(next_block.header().into()),
179179
mmr_delta,
180180
accounts: vec![],
@@ -185,7 +185,10 @@ impl MockRpcApi {
185185
}
186186

187187
/// Retrieves notes that are included in the specified block number.
188-
fn get_notes_in_block(&self, block_num: u32) -> impl Iterator<Item = NoteSyncRecord> + '_ {
188+
fn get_notes_in_block(
189+
&self,
190+
block_num: BlockNumber,
191+
) -> impl Iterator<Item = NoteSyncRecord> + '_ {
189192
self.notes.values().filter_map(move |note| {
190193
if note.location().map_or(false, |loc| loc.block_num() == block_num) {
191194
let proof = note.proof()?;
@@ -206,7 +209,7 @@ use alloc::boxed::Box;
206209
impl NodeRpcClient for MockRpcApi {
207210
async fn sync_notes(
208211
&mut self,
209-
_block_num: u32,
212+
_block_num: BlockNumber,
210213
_note_tags: &[NoteTag],
211214
) -> Result<NoteSyncInfo, RpcError> {
212215
let response = SyncNoteResponse {
@@ -222,7 +225,7 @@ impl NodeRpcClient for MockRpcApi {
222225
/// Executes the specified sync state request and returns the response.
223226
async fn sync_state(
224227
&mut self,
225-
block_num: u32,
228+
block_num: BlockNumber,
226229
_account_ids: &[AccountId],
227230
_note_tags: &[NoteTag],
228231
_nullifiers_tags: &[u16],
@@ -237,10 +240,10 @@ impl NodeRpcClient for MockRpcApi {
237240
/// Only used for retrieving genesis block right now so that's the only case we need to cover.
238241
async fn get_block_header_by_number(
239242
&mut self,
240-
block_num: Option<u32>,
243+
block_num: Option<BlockNumber>,
241244
include_mmr_proof: bool,
242245
) -> Result<(BlockHeader, Option<MmrProof>), RpcError> {
243-
if block_num == Some(0) {
246+
if block_num == Some(0.into()) {
244247
return Ok((self.blocks.first().unwrap().header(), None));
245248
}
246249
let block = self
@@ -250,7 +253,7 @@ impl NodeRpcClient for MockRpcApi {
250253
.unwrap();
251254

252255
let mmr_proof = if include_mmr_proof {
253-
Some(self.get_mmr().open(block_num.unwrap() as usize).unwrap())
256+
Some(self.get_mmr().open(block_num.unwrap().as_usize()).unwrap())
254257
} else {
255258
None
256259
};

crates/rust-client/src/notes/import.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use alloc::string::ToString;
22

33
use miden_objects::{
4+
block::BlockNumber,
45
crypto::rand::FeltRng,
56
notes::{Note, NoteDetails, NoteFile, NoteId, NoteInclusionProof, NoteMetadata, NoteTag},
67
};
@@ -185,7 +186,7 @@ impl<R: FeltRng> Client<R> {
185186
&mut self,
186187
previous_note: Option<InputNoteRecord>,
187188
details: NoteDetails,
188-
after_block_num: u32,
189+
after_block_num: BlockNumber,
189190
tag: Option<NoteTag>,
190191
) -> Result<Option<InputNoteRecord>, ClientError> {
191192
let mut note_record = previous_note.unwrap_or({
@@ -237,7 +238,7 @@ impl<R: FeltRng> Client<R> {
237238
/// proof.
238239
async fn check_expected_note(
239240
&mut self,
240-
mut request_block_num: u32,
241+
mut request_block_num: BlockNumber,
241242
tag: NoteTag,
242243
expected_note: &miden_objects::notes::NoteDetails,
243244
) -> Result<Option<(NoteMetadata, NoteInclusionProof)>, ClientError> {
@@ -249,7 +250,7 @@ impl<R: FeltRng> Client<R> {
249250

250251
let sync_notes = self.rpc_api.sync_notes(request_block_num, &[tag]).await?;
251252

252-
if sync_notes.block_header.block_num() == sync_notes.chain_tip {
253+
if sync_notes.block_header.block_num() == sync_notes.chain_tip.into() {
253254
return Ok(None);
254255
}
255256

0 commit comments

Comments
 (0)