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

Refactor storage domains to prevent import cycles and simplify maintenance #3673

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

fxamacker
Copy link
Member

Closes #3672
Updates #3584

Description

Currently, various storage domains are defined in different packages, such as:

  • common
  • runtime
  • stdlib

Also, domain string is used to get StorageMap. Although we use pre-defined domain strings, this can still be error-prone.

Solution

This PR moves storage domains from different packages to a single place:

  • common/storagedomain.go.

While at it, this PR also modifies GetStorageMap() to use common.StorageDomain instead of string.

Context

This refactoring is needed for upcoming storage optimization to replace domain name string with domain integer in account storage map. Without this PR, we would run into import cycles.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Currently, various storage domains are defined in
different packages, such as:
- common
- runtime
- stdlib

This commit moves storage domains from different
packages to a single place: common/storagedomain.go.

This change will help us avoid import cycles when
using domains across different packages.
Currently, we use domain string to get StorageMap.  Even though
we use pre-defined domain strings, this can still be error-prone.

This commit modifies GetStorageMap() to use common.StorageDomain
instead of string.
Copy link

github-actions bot commented Nov 8, 2024

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit a56e521
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -benchmem -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Collapsed results for better readability

@fxamacker fxamacker changed the title Refactor storage domains to prevent import cycles and simplilfy maintenance Refactor storage domains to prevent import cycles and simplify maintenance Nov 12, 2024
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

👍

@fxamacker fxamacker merged commit 33c0ded into master Nov 12, 2024
10 of 12 checks passed
@fxamacker
Copy link
Member Author

I didn't see additional review was requested. Although this PR was merged, please feel free to share additional feedback and I will take a look. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor domains to prevent import cycles and simplify maintenance
2 participants