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

Support updating struct fields in storage #246

Merged
merged 2 commits into from
Feb 15, 2021

Conversation

cburgdorf
Copy link
Collaborator

@cburgdorf cburgdorf commented Feb 13, 2021

What was wrong?

We did not support updating individual struct fields in storage (e.g. self.my_struct.some_field = 1)

How was it fixed?

  1. Make the traversal recognize nested attribute expressions
  2. Map them to carry the location of the entire struct
  3. Map field of storage struct to a pointer of ptr_of_storage_struct + 32 * field_index
  4. Add test

To-Do

  • OPTIONAL: Update Spec if applicable

  • Add entry to the release notes (may forgo for trivial changes)

  • Clean up commit history

let ptr = get_full_signature(nonce.to_string().as_bytes());
let ptr = literal_expression! { (ptr) };
let offset = literal_expression! { (offset) };
expression! { (add([ptr], [offset])) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@g-r-a-n-t Not sure if this is still the right thing to do after your recent findings about how to deal with storage.

But if it is, we should probably calculate the ptr manually to get rid of the add(ptr, offset). I thought that this is something that the optimizer would do for us but I ran with --optimize and it isn't optimizing the add away.

Copy link
Member

Choose a reason for hiding this comment

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

this is fine for now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 I will create an issue to track this optimization though

@cburgdorf cburgdorf changed the title Christoph/feat/struct storage Support updating struct fields in storage Feb 13, 2021
@cburgdorf cburgdorf merged commit fa7c3c1 into ethereum:master Feb 15, 2021
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.

2 participants