fix(store): query only latest vault rows when applying account delta#1789
Merged
fix(store): query only latest vault rows when applying account delta#1789
Conversation
Collaborator
|
@drahnr do we need this on |
drahnr
reviewed
Mar 13, 2026
Comment on lines
+213
to
+219
| let mut assets = Vec::new(); | ||
| for (_vault_key_bytes, maybe_asset_bytes) in entries { | ||
| if let Some(asset_bytes) = maybe_asset_bytes { | ||
| assets.push(Asset::read_from_bytes(&asset_bytes)?); | ||
| } | ||
| } | ||
| Ok(assets) |
Contributor
There was a problem hiding this comment.
Suggested change
| let mut assets = Vec::new(); | |
| for (_vault_key_bytes, maybe_asset_bytes) in entries { | |
| if let Some(asset_bytes) = maybe_asset_bytes { | |
| assets.push(Asset::read_from_bytes(&asset_bytes)?); | |
| } | |
| } | |
| Ok(assets) | |
| Result::from_iter(entries.into_iter().filter_map(|(_vault_key_bytes, maybe_asset_bytes)| { maybe_asset_bytes.map(Asset::read_from_bytes).transpose()})); |
Contributor
|
The code in question was changed in #1538 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While testing for 0xMiden/miden-client#1843, I made some changes to the node seed store binary and bumped into this bug.
When applying a partial account delta, the store reconstructed the
AssetVaultby querying all historical vault rows instead of only the current state. This causedDuplicateAsseterror when the same vault key had entries across multiple blocks. i.e., after 2+ balance updates to the same faucet for an account. This is way the current test did not catch the error, I updated it to update the account 3 times and it fails.The fix is to replace the historical range query with a new
select_latest_vault_assetsfunction that filters onis_latest = true, returning only the current vault state for reconstruction.