Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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 @@ -23,6 +23,7 @@
* Refactored internal structure of account vault and storage Sqlite tables ([#1128](https://github.com/0xMiden/miden-client/pull/1128)).
* [BREAKING] Fixed `createP2IDNote` and `createP2IDENote` convenience functions in the Web Client ([#1142](https://github.com/0xMiden/miden-client/pull/1142)).
* [BREAKING] Rename `export/importNote` to `export/importNoteFile`, expose serialization functions for `Note` in Web Client ([#1159](https://github.com/0xMiden/miden-client/pull/1159)).
* [BREAKING] Change protobuf `AccountStateHeader` definition for reduced redundancy ([#1167](https://github.com/0xMiden/miden-client/pull/1167))

### Features

Expand Down
18 changes: 9 additions & 9 deletions Cargo.lock

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

18 changes: 10 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ version = "0.11.0"
[workspace.dependencies]
# Miden dependencies
miden-lib = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
miden-node-block-producer = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-ntx-builder = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-proto-build = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-node" }
miden-node-rpc = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-store = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-utils = { branch = "next", git = "https://github.com/0xMiden/miden-node" }
miden-node-block-producer = { branch = "bernhard-617-batch-proof", git = "https://github.com/0xMiden/miden-node" }
miden-node-ntx-builder = { branch = "bernhard-617-batch-proof", git = "https://github.com/0xMiden/miden-node" }
miden-node-proto-build = { branch = "bernhard-617-batch-proof", default-features = false, git = "https://github.com/0xMiden/miden-node" }
miden-node-rpc = { branch = "bernhard-617-batch-proof", git = "https://github.com/0xMiden/miden-node" }
miden-node-store = { branch = "bernhard-617-batch-proof", git = "https://github.com/0xMiden/miden-node" }
miden-node-utils = { branch = "bernhard-617-batch-proof", git = "https://github.com/0xMiden/miden-node" }
miden-objects = { branch = "next", default-features = false, git = "https://github.com/0xMiden/miden-base" }
miden-remote-prover = { branch = "next", features = ["concurrent"], git = "https://github.com/0xMiden/miden-node" }
miden-remote-prover-client = { branch = "next", default-features = false, features = [
miden-remote-prover = { branch = "bernhard-617-batch-proof", features = [
"concurrent",
], git = "https://github.com/0xMiden/miden-node" }
miden-remote-prover-client = { branch = "bernhard-617-batch-proof", default-features = false, features = [
"tx-prover",
], git = "https://github.com/0xMiden/miden-node" }
miden-testing = { branch = "next", default-features = false, features = [
Expand Down
30 changes: 15 additions & 15 deletions crates/rust-client/src/rpc/domain/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,18 @@ impl proto::rpc_store::account_proofs::account_proof::AccountStateHeader {
account_id: AccountId,
known_account_codes: &BTreeMap<Word, AccountCode>,
) -> Result<StateHeaders, crate::rpc::RpcError> {
use miden_objects::crypto::merkle::PartialSmt;

use crate::rpc::RpcError;
use crate::rpc::domain::MissingFieldHelper;
use crate::rpc::generated::rpc_store::account_proofs::account_proof::account_state_header::StorageSlotMapProof;

let proto::rpc_store::account_proofs::account_proof::AccountStateHeader {
header,
storage_header,
account_code,
storage_maps,
partial_storage_smts,
} = self;

let account_header = header
.ok_or(
proto::rpc_store::account_proofs::account_proof::AccountStateHeader::missing_field(
Expand Down Expand Up @@ -213,20 +215,18 @@ impl proto::rpc_store::account_proofs::account_proof::AccountStateHeader {
}
};

// Get map values into slot |-> (key, value, proof) mapping
let mut storage_slot_proofs: BTreeMap<u8, Vec<SmtProof>> = BTreeMap::new();
for StorageSlotMapProof { storage_slot, smt_proof } in storage_maps {
let proof = SmtProof::read_from_bytes(&smt_proof)?;
match storage_slot_proofs
.get_mut(&(u8::try_from(storage_slot).expect("there are no more than 256 slots")))
{
Some(list) => list.push(proof),
None => {
_ = storage_slot_proofs.insert(
u8::try_from(storage_slot).expect("only 256 storage slots"),
vec![proof],
);
},
let partial_storage_smts = partial_storage_smts.into_iter().map(|entry| {
let slot =
u8::try_from(entry.storage_slot).map_err(crate::rpc::RpcError::SlotOutOfBounds)?;
let partial_smt = PartialSmt::read_from_bytes(&entry.partial_smt)?;
Ok::<_, crate::rpc::RpcError>((slot, partial_smt))
});
for result in partial_storage_smts {
let (slot, partial_smt) = result?;
for (key, _value) in partial_smt.entries() {
let proof = partial_smt.open(key)?;
storage_slot_proofs.entry(slot).or_default().push(proof);
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/rust-client/src/rpc/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub enum RpcError {
NoteNotFound(NoteId),
#[error("rpc request failed for {0}: {1}")]
RequestError(String, String),
#[error("merkle proof is not conetained")]
MerkleError(#[from] MerkleError),
#[error("slot index out of bounds")]
SlotOutOfBounds(#[source] TryFromIntError),
}

impl From<DeserializationError> for RpcError {
Expand Down
20 changes: 16 additions & 4 deletions crates/rust-client/src/rpc/generated/nostd/rpc_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,26 @@ pub mod account_proofs {
/// the current one.
#[prost(bytes = "vec", optional, tag = "3")]
pub account_code: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
/// Storage slots information for this account
#[prost(message, repeated, tag = "4")]
pub storage_maps: ::prost::alloc::vec::Vec<
account_state_header::StorageSlotMapProof,
/// A sparse merkle tree per storage slot, including all relevant merkle proofs for storage entries.
#[prost(message, repeated, tag = "5")]
pub partial_storage_smts: ::prost::alloc::vec::Vec<
account_state_header::StorageSlotMapPartialSmt,
>,
}
/// Nested message and enum types in `AccountStateHeader`.
pub mod account_state_header {
/// Represents a single storage slot with the requested keys and their respective values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StorageSlotMapPartialSmt {
/// The storage slot index (\[0..255\]).
#[prost(uint32, tag = "1")]
pub storage_slot: u32,
/// Merkle proofs of the map value as partial sparse merkle tree for compression.
/// The respective rust types is `SparseMerkleTree` and the transformation to and from
/// bytes is done via the traits `Serializable::to_bytes` and `Deserializable::from_bytes`.
#[prost(bytes = "vec", tag = "2")]
pub partial_smt: ::prost::alloc::vec::Vec<u8>,
}
/// Represents a single storage slot with the requested keys and their respective values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StorageSlotMapProof {
Expand Down
20 changes: 16 additions & 4 deletions crates/rust-client/src/rpc/generated/std/rpc_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,26 @@ pub mod account_proofs {
/// the current one.
#[prost(bytes = "vec", optional, tag = "3")]
pub account_code: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
/// Storage slots information for this account
#[prost(message, repeated, tag = "4")]
pub storage_maps: ::prost::alloc::vec::Vec<
account_state_header::StorageSlotMapProof,
/// A sparse merkle tree per storage slot, including all relevant merkle proofs for storage entries.
#[prost(message, repeated, tag = "5")]
pub partial_storage_smts: ::prost::alloc::vec::Vec<
account_state_header::StorageSlotMapPartialSmt,
>,
}
/// Nested message and enum types in `AccountStateHeader`.
pub mod account_state_header {
/// Represents a single storage slot with the requested keys and their respective values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StorageSlotMapPartialSmt {
/// The storage slot index (\[0..255\]).
#[prost(uint32, tag = "1")]
pub storage_slot: u32,
/// Merkle proofs of the map value as partial sparse merkle tree for compression.
/// The respective rust types is `SparseMerkleTree` and the transformation to and from
/// bytes is done via the traits `Serializable::to_bytes` and `Deserializable::from_bytes`.
#[prost(bytes = "vec", tag = "2")]
pub partial_smt: ::prost::alloc::vec::Vec<u8>,
}
/// Represents a single storage slot with the requested keys and their respective values.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StorageSlotMapProof {
Expand Down
Loading