Skip to content
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

feat: merge account updates details #797

Merged
merged 12 commits into from
Jul 24, 2024
Merged

Conversation

Mirko-von-Leipzig
Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig commented Jul 17, 2024

This PR adds AccountUpdateDetails::merge which combines two update details. This is required by the node to support merging multiple transactions on the same account.

I implemented the merging using hashmaps to ensure only the final update is applied. This required Hash on several structs, and unfortunately Felt does not implement Hash itself so this required manually implementing it in some cases. Use BTreeMap instead which doesn't require Hash and is nostd compliant.

The structs themselves actually look like they should contain hashmaps instead of vectors as this would be more type safe imo. However, since they aren't this makes me question my approach. I'll ask more specific questions inline so that the conversation is easier to track.

I also have some todo!() which I don't know how to implement.

As a side-note we could also use something like Slot type, similar to NonZeroU8 but which disallows the "illegal" slots.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks good. I left some comments inline. Also, I think we need to finish implementing merging of StorageMapDelta structs.

objects/src/accounts/delta/mod.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/mod.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/storage.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/storage.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/vault.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/vault.rs Outdated Show resolved Hide resolved
objects/src/assets/fungible.rs Outdated Show resolved Hide resolved
objects/src/assets/nonfungible.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a comment

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 did leave a few more comments/questions inline.

objects/src/accounts/delta/mod.rs Outdated Show resolved Hide resolved
objects/src/assets/mod.rs Outdated Show resolved Hide resolved
objects/src/accounts/delta/vault.rs Show resolved Hide resolved
objects/src/accounts/delta/vault.rs Show resolved Hide resolved
@Mirko-von-Leipzig
Copy link
Contributor Author

I believe I've addressed all review comments. I've added tests - though note that I used rstest to reduce boiler-plate. In general I find this to be a useful dependency but I can understand if you prefer I write the cases out instead.

This enables creating mappings for related types.

Some types required manual impls as Felt does not implement Hash. This
feels like an oversight.
The latter is not nostd compliant.
Address review comments
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left just a couple of minor comments inline. Once these are addressed, we can merge.

objects/src/errors.rs Outdated Show resolved Hide resolved
objects/src/assets/fungible.rs Outdated Show resolved Hide resolved
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.

3 participants