-
Notifications
You must be signed in to change notification settings - Fork 115
fix: new account map delta #2077
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
8 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 e2e4eb4
fix: empty storage map representation in full state deltas
PhilippGackstatter 92199c5
chore: add changelog
PhilippGackstatter 42b80d8
fix: typo
PhilippGackstatter f29204f
Merge branch 'main' into pgackst-fix-new-account-map-delta
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
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 |
|---|---|---|
|
|
@@ -95,6 +95,13 @@ impl AccountStorageDelta { | |
| self.maps.entry(slot_index).or_default().insert(key, new_value); | ||
| } | ||
|
|
||
| /// Inserts an empty storage map delta for the provided slot index. | ||
| /// | ||
| /// This is useful for full state deltas to represent an empty map in the delta. | ||
| pub fn insert_empty_map_delta(&mut self, slot_index: u8) { | ||
| self.maps.entry(slot_index).or_default(); | ||
| } | ||
|
Comment on lines
+101
to
+103
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. Does the logic of this method align with its name? |
||
|
|
||
| /// Merges another delta into this one, overwriting any existing values. | ||
| pub fn merge(&mut self, other: Self) -> Result<(), AccountDeltaError> { | ||
| self.values.extend(other.values); | ||
|
|
@@ -162,10 +169,6 @@ impl AccountStorageDelta { | |
| }, | ||
| None => { | ||
| if let Some(map_delta) = self.maps().get(&slot_idx) { | ||
| if map_delta.is_empty() { | ||
| continue; | ||
| } | ||
|
|
||
| for (key, value) in map_delta.entries() { | ||
| elements.extend_from_slice(key.inner().as_elements()); | ||
| elements.extend_from_slice(value.as_elements()); | ||
|
|
||
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.
I can't remember whether full state deltas ALWAYS implies the account is new? Or can we have full state delta for an existing account, too?
I'm bringing this up because there's a small inconsistency in the naming for this fix vs. for #2075.
Here, we make special adjustments "for full state deltas" (always include the map header, analogous to always including the value entry even if empty).
In #2075, we make special adjustments "for new accounts".
So if full state deltas =ALWAYS= new account, then maybe we could refer to new account vs. existing accounts here, too?
lmk if this makes sense or whether I missed the point completely :D
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.
Yes, full state delta always means new account - so, we should have probably used "new account" here as well. But I also think it is fine as is because we'll rework it relatively soon with #2078.
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.
I agree the terminology is inconsistent here, mostly a result of doing these PRs as "quick fixes" and in sequence instead of as one unified feature.
I added your comments to #2078 (comment), thanks for raising it! We could refer to new/existing accounts, but as mentioned in the issue comment, full state and partial state is more well-defined in the delta context than new/existing account, so this seems a bit better. Also open to a rename of the full / partial state notion, but can't think of anything better immediately.