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

mostly cosmetic changes wrt. storage layout handling #194

Merged
merged 2 commits into from
Sep 16, 2023

Conversation

karmacoma-eth
Copy link
Collaborator

  • --custom-storage-layout -> --storage-layout=generic (I think it's a bit more intuitive and future proof if we want to add more models in the future)
  • rename CustomStorage to GenericStorage
  • set the storage model at SEVM creation time, rather than on every store/load

- `--custom-storage-layout` -> `--storage-layout=generic` (I think it's a bit more intuitive and future proof if we want to add more models in the future)
- rename CustomStorage to GenericStorage
- set the storage model at SEVM creation time, rather than on every store/load
if self.options["custom_storage_layout"]:
return CustomStorage.load(ex, addr, loc)
else:
return SolidityStorage.load(ex, addr, loc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, is it that a new class instance is created whenever a class method is called?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, it just passes the class reference. Here is my reasoning for moving this logic to the SEVM constructor:

  • it is a tiny bit more efficient to only check the "custom_storage_layout" at config time (rather than every time we process an sload/sstore)
  • it reduces code duplication a wee bit
  • it feels more conceptually clean: you configure the SEVM class with a specific storage model, and then that SEVM instance will always work with that storage model

Copy link
Collaborator

@daejunpark daejunpark left a comment

Choose a reason for hiding this comment

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

looks great, thank you!

@daejunpark daejunpark enabled auto-merge (squash) September 16, 2023 00:02
@daejunpark daejunpark merged commit 59ebac8 into main Sep 16, 2023
108 checks passed
@daejunpark daejunpark deleted the nits-and-suggestions branch September 16, 2023 01:39
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