Skip to content

chore: switch back protocol dep to git next#2282

Open
juan518munoz wants to merge 18 commits into
nextfrom
jmunoz-update-miden-protocol
Open

chore: switch back protocol dep to git next#2282
juan518munoz wants to merge 18 commits into
nextfrom
jmunoz-update-miden-protocol

Conversation

@juan518munoz

Copy link
Copy Markdown
Collaborator

Summary

Switch back miden protocol dependency from crates.io to github's next branch. Unsure if this is something to have addressed now, the main goal of the PR is to apply most recent changes of protocol as soon as possible on the miden-client.

Changelog

Most notable changes are Delta storages being replaced by Patch, and the removal of the fee field from transactions (to be replaced by batched fees).

[[entry]]
scope       = "protocol"
impact      = "breaking"
description = "Updated `miden-protocol` dependencies to use the `next` branch (v0.16). Block and transaction account updates now use the absolute `AccountPatch` representation instead of the relative `AccountDelta`, and the `miden-tx-batch-prover` crate was renamed to `miden-tx-batch`. The per-transaction fee was also removed following its removal from the protocol transaction kernel (https://github.com/0xMiden/protocol/pull/3108), so the `fee` field was dropped from the `TransactionHeader` gRPC message and from the store and validator transaction tables, and `ProvenTransaction` and `TransactionId` construction no longer take a fee."

@juan518munoz juan518munoz Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make db changes like this (breaking)? Or rather remove throught a migration?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we will have to do this via migrations, and we do have the framework in place for such a situation.

However, this one would be particularly painful since (iiuc) it would require running through every public account's delta and calculating the absolute value instead.

This might be good practice but its also a waste of time since we would never apply this migration to any active network.

So this would just be an additional breaking change entry e.g.

[[entry]]
scope = "node"
impact = "breaking"
description = "Backwards incompatible database schema changes to align with new protocol."

@juan518munoz juan518munoz marked this pull request as ready for review June 24, 2026 22:00
@Mirko-von-Leipzig

Copy link
Copy Markdown
Collaborator

Thanks! Will begin reviewing. There are a handful of open PRs that I would like to squeeze in before merging this one.

@igamigo

igamigo commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Will begin reviewing. There are a handful of open PRs that I would like to squeeze in before merging this one.

No hurries, I'm also planning on taking a look soon. Thanks!

@igamigo igamigo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full review, but I got through most of the non-test code

Comment thread bin/ntx-builder/src/actor/execute.rs Outdated
Comment thread bin/remote-prover/src/server/prover.rs
Comment thread bin/remote-prover/src/server/prover.rs
Comment thread crates/block-producer/src/batch_builder/mod.rs
Comment thread crates/rpc/src/server/api/submit_proven_tx_batch.rs Outdated
Comment thread crates/store/src/account_state_forest/mod.rs Outdated
Comment thread crates/store/src/account_state_forest/mod.rs
Comment thread crates/store/src/account_state_forest/mod.rs Outdated
Comment thread crates/store/src/account_state_forest/mod.rs
Comment thread crates/store/src/account_state_forest/mod.rs Outdated
@igamigo igamigo requested a review from SantiagoPittella July 3, 2026 15:30

@igamigo igamigo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! I left some comments, most of which are quite minor. I think the only real question I have is related to how we fetch (and potentially reconstruct to insert to cache) the account vault details.

Comment thread bin/network-monitor/src/counter.rs Outdated
.expect("wallet tx only writes existing value slots");
}
let new_nonce = wallet.nonce() + account_delta.nonce_delta();
let new_nonce = account_patch.final_nonce().unwrap_or_else(|| wallet.nonce());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could expect() here, instead of defaulting to the preivous nonce. If the transaction succeeded, the nonce should have been updated and if it's not, it'd be signaling a problem.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as resolved as it was superseeded by the other comment

Comment thread bin/network-monitor/src/counter.rs Outdated
Comment on lines 213 to 222

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually looking at this could we not do wallet.apply_patch() directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, addressed in 05e49d5

Comment thread bin/network-monitor/src/counter.rs Outdated
storage_update: Option<(BenchmarkStorageUpdate, usize)>,
) -> AccountDelta {
let mut vault_delta = AccountVaultDelta::default();
) -> AccountPatch {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do AccountPatch::try_from here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm following correctly, but building an AccountPatch from the received Account would imply converting the full account into a patch (note that it also requires cloning it), when in reality we only want to create a patch with a subset of its vault/storage, only the modified ones.

Comment thread bin/validator/src/tx_validation/mod.rs Outdated
},
#[error("transaction proof verification failed")]
ProofVerificationFailed(#[from] miden_tx::TransactionVerifierError),
ProofVerificationFailed(#[from] miden_protocol::errors::TransactionVerifierError),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We can import the TransactionVerifierError

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the error as an import in 05e49d5

Comment on lines +70 to +73
#[expect(
clippy::large_enum_variant,
reason = "built per account update and consumed immediately"
)]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that this starts showing up now

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Comment on lines +185 to 187
for (slot_name, value_patch) in patch.values() {
value_updates.insert(slot_name, value_patch.value().unwrap_or(EMPTY_WORD));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is semantically the same as what was here before so maybe a question for @Mirko-von-Leipzig but should these removed values be deleted from the SQL table?


/// Process wallet assets and return them as a fungible asset delta. Track the negative adjustments
/// for the respective faucets.
fn prepare_fungible_asset_update(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong but it seems some of this setup could potentially be simplified with the delta to patch migration

Comment thread crates/store/src/state/account.rs Outdated
Comment on lines +153 to +156
self.forest
.write()
.await
.cache_vault_keys(assets.iter().map(miden_protocol::asset::Asset::vault_key));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may only want to cache here if the details are not in the "too many entries" category (this is what the storage map flow does, AFAIK)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall though, I may be missing something but these functions (both the new one and the previously-existing one related to storage maps) seem to be doing unnecessary work: they may be reading the whole set of key/values to just return LimitExceeded. cc @Mirko-von-Leipzig

};
entries.push((key, value));
}
let mut entries: Vec<(AssetVaultKey, Word)> = Vec::new();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We can do Vec::with_capacity() here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 05e49d5

@SantiagoPittella SantiagoPittella left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking good in general. Added some nits. Also lets ensure addressing Ignacio's comments + a search of "delta" throughout the repository since I think there are a couple places that still reference the old name

Comment thread bin/network-monitor/src/counter.rs Outdated
for (slot_name, value) in account_patch.storage().values() {
storage
.set_item(slot_name, *value)
.set_item(slot_name, value.value().unwrap_or_else(Word::empty))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the value shouldn't be removed and that StorageValuePatch::Remove is the only variant that makes this return None, lets replace this unwrap with an .expect("the value is always increased") or something like that

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseeded by other comment

Comment thread bin/ntx-builder/src/actor/mod.rs Outdated
Comment on lines 377 to 378

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Decides the actor's next mode after a coordinator notification, patching the in-memory
/// account when the actor's own transaction lands.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - Upserts each touched network account: new full-state path insert, partial patches apply to

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants