chore: switch back protocol dep to git next#2282
Conversation
There was a problem hiding this comment.
Should we make db changes like this (breaking)? Or rather remove throught a migration?
There was a problem hiding this comment.
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."|
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
left a comment
There was a problem hiding this comment.
Not a full review, but I got through most of the non-test code
…rotocol # Conflicts: # crates/rpc/src/server/api/submit_proven_tx_batch.rs
igamigo
left a comment
There was a problem hiding this comment.
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.
| .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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Marking as resolved as it was superseeded by the other comment
There was a problem hiding this comment.
Actually looking at this could we not do wallet.apply_patch() directly?
| storage_update: Option<(BenchmarkStorageUpdate, usize)>, | ||
| ) -> AccountDelta { | ||
| let mut vault_delta = AccountVaultDelta::default(); | ||
| ) -> AccountPatch { |
There was a problem hiding this comment.
I think we can do AccountPatch::try_from here
There was a problem hiding this comment.
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.
| }, | ||
| #[error("transaction proof verification failed")] | ||
| ProofVerificationFailed(#[from] miden_tx::TransactionVerifierError), | ||
| ProofVerificationFailed(#[from] miden_protocol::errors::TransactionVerifierError), |
There was a problem hiding this comment.
nit: We can import the TransactionVerifierError
There was a problem hiding this comment.
Added the error as an import in 05e49d5
| #[expect( | ||
| clippy::large_enum_variant, | ||
| reason = "built per account update and consumed immediately" | ||
| )] |
There was a problem hiding this comment.
Interesting that this starts showing up now
| for (slot_name, value_patch) in patch.values() { | ||
| value_updates.insert(slot_name, value_patch.value().unwrap_or(EMPTY_WORD)); | ||
| } |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
I could be wrong but it seems some of this setup could potentially be simplified with the delta to patch migration
| self.forest | ||
| .write() | ||
| .await | ||
| .cache_vault_keys(assets.iter().map(miden_protocol::asset::Asset::vault_key)); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
nit: We can do Vec::with_capacity() here
SantiagoPittella
left a comment
There was a problem hiding this comment.
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
| 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
| /// Decides the actor's next mode after a coordinator notification, patching the in-memory | |
| /// account when the actor's own transaction lands. |
There was a problem hiding this comment.
| /// - Upserts each touched network account: new full-state path insert, partial patches apply to |
Summary
Switch back miden protocol dependency from crates.io to github's
nextbranch. 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
Deltastorages being replaced byPatch, and the removal of thefeefield from transactions (to be replaced by batched fees).