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

[Improve]: use IReadOnlyStoreView instead. #3683

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

nan01ab
Copy link
Contributor

@nan01ab nan01ab commented Jan 21, 2025

Description

Using IReadOnlyStoreView instead of DataCache to make the semantics clearer in some read-only cases.

Fixes # (issue)

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y
Copy link
Contributor

Jim8y commented Jan 21, 2025

I think the name is still misleading,,, and confusing, storeview,,, snapshot,,,, datacache,,,,

@Jim8y
Copy link
Contributor

Jim8y commented Jan 21, 2025

I think the name is still misleading,,, and confusing, storeview,,, snapshot,,,, datacache,,,,

@shargon maybe you can have a pr to standardize the class/param names

@nan01ab
Copy link
Contributor Author

nan01ab commented Jan 21, 2025

I think the name is still misleading,,, and confusing, storeview,,, snapshot,,,, datacache,,,,

The name “StoreView” already exists, and no new things have been added.
If you have a better name, you can submit a pr

@cschuchardt88
Copy link
Member

cschuchardt88 commented Jan 21, 2025

Just note that, Datacache should be removed. It is faster to get the data from leveldb database than with Datacache.

@nan01ab
Copy link
Contributor Author

nan01ab commented Jan 21, 2025

I think the name is still misleading,,, and confusing, storeview,,, snapshot,,,, datacache,,,,

@shargon maybe you can have a pr to standardize the class/param names

I think it's better to separate read-only APIs as an interface(for example, there are already IStore, IReadOnlyStore.).
And the interface name, do you have a better one? @Jim8y

shargon
shargon previously approved these changes Jan 23, 2025
Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

Require testing to ensure that both types are detected by the native contract calls

@shargon shargon self-requested a review January 23, 2025 10:53
@nan01ab
Copy link
Contributor Author

nan01ab commented Jan 23, 2025

I think the name is still misleading,,, and confusing, storeview,,, snapshot,,,, datacache,,,,

@Jim8y
Why add this interface?

  1. Separating read-only APIs as an independent interface is a good practice (for example, there are already IStore and IReadOnlyStore.);

  2. Most cases of using DataCache are read-only access, and the read-only interface makes these cases clearer;

  3. On-chain data can only be modified by transaction execution.
    DataCache is also used by the p2p network and other modules, and these modules should access it in a read-only way.

  4. The current caching mechanism is not working very well. The DataCache is often created and accessed only once and a key isn't accessed multiple times.

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.

4 participants