-
Notifications
You must be signed in to change notification settings - Fork 115
fix: skip value slot normalization for new account's deltas #2075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b650f6f
fix: Skip value slot normalization for new account's deltas
PhilippGackstatter 7f780c9
chore: add changelog
PhilippGackstatter 6b3d74d
chore: Remove map case from test (to be included separately)
PhilippGackstatter baeb856
chore: test account created from tx delta matches original
PhilippGackstatter 536d83a
Apply suggestion from @mmagician
bobbinth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ use miden_objects::testing::constants::{ | |
| }; | ||
| use miden_objects::testing::storage::{STORAGE_INDEX_0, STORAGE_INDEX_2}; | ||
| use miden_objects::transaction::TransactionScript; | ||
| use miden_objects::{EMPTY_WORD, Felt, LexicographicWord, Word, ZERO}; | ||
| use miden_objects::{EMPTY_WORD, Felt, FieldElement, LexicographicWord, Word, ZERO}; | ||
| use miden_tx::LocalTransactionProver; | ||
| use rand::{Rng, SeedableRng}; | ||
| use rand_chacha::ChaCha20Rng; | ||
|
|
@@ -869,6 +869,42 @@ async fn proven_tx_storage_maps_matches_executed_tx_for_new_account() -> anyhow: | |
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that creating a new account with a slot whose value is empty is correctly included in the | ||
| /// delta and not normalized away. | ||
| #[tokio::test] | ||
| async fn delta_for_new_account_retains_empty_value_storage_slots() -> anyhow::Result<()> { | ||
|
Comment on lines
+872
to
+875
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested this on $ git restore -s origin/pgackst-fix-new-account-delta crates/miden-testing/src/kernel_tests/tx/test_account_delta.rs
$ cargo test delta_for_new_account_retains_empty_value_storage_slotsand it fails with the error reported in #2072. 👍🏼 |
||
| let slot_value2 = Word::from([1, 2, 3, 4u32]); | ||
| let mut account = AccountBuilder::new(rand::random()) | ||
| .account_type(AccountType::RegularAccountUpdatableCode) | ||
| .storage_mode(AccountStorageMode::Network) | ||
| .with_component(MockAccountComponent::with_slots(vec![ | ||
| StorageSlot::empty_value(), | ||
| StorageSlot::Value(slot_value2), | ||
| ])) | ||
| .with_auth_component(Auth::IncrNonce) | ||
| .build()?; | ||
|
|
||
| let tx = TransactionContextBuilder::new(account.clone()).build()?.execute().await?; | ||
|
|
||
| let proven_tx = LocalTransactionProver::default().prove_dummy(tx.clone())?; | ||
|
|
||
| let AccountUpdateDetails::Delta(delta) = proven_tx.account_update().details() else { | ||
| panic!("expected delta"); | ||
| }; | ||
|
|
||
| assert_eq!(delta.storage().values().len(), 2); | ||
| assert_eq!(delta.storage().values().get(&0).unwrap(), &Word::empty()); | ||
| assert_eq!(delta.storage().values().get(&1).unwrap(), &slot_value2); | ||
|
|
||
| let recreated_account = Account::try_from(delta)?; | ||
| // The recreated account should match the original account with the nonce incremented (and the | ||
| // seed removed). | ||
| account.increment_nonce(Felt::ONE)?; | ||
| assert_eq!(recreated_account, account); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| /// Tests that adding a fungible asset with amount zero to the account vault works and does not | ||
| /// result in an account delta entry. | ||
| #[tokio::test] | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR: but we use the check
init_nonce == 0in a few places now and I wonder if we should add something likememory::is_account_newprocedure.