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

Serialized storage cache #3669

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

Serialized storage cache #3669

wants to merge 21 commits into from

Conversation

shargon
Copy link
Member

@shargon shargon commented Jan 13, 2025

Description

Close #3145
Alternative to #3146

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

How Has This Been Tested?

  • Pending

Test Configuration:

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

@shargon shargon mentioned this pull request Jan 13, 2025
15 tasks
@shargon shargon added the Blocked This issue can't be worked at the moment label Jan 13, 2025
@shargon shargon removed the Blocked This issue can't be worked at the moment label Jan 20, 2025
@shargon shargon marked this pull request as ready for review January 21, 2025 10:51
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Good, it should work this way. But I'd suggest to process existing chains with this change in order to ensure that cache persisting logic works as expected.

src/Neo/SmartContract/Native/NeoToken.cs Outdated Show resolved Hide resolved
src/Neo/Persistence/DataCache.cs Outdated Show resolved Hide resolved
/// <summary>
/// Serialized cache
/// </summary>
SerializedCache SerializedCache { get; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this to the IReadOnlyStore makes the interface more complex, and each implementation needs to be modified.

Another way:
Add a wrapper class for IStore

class SerializedCacheStore {
     private readonly IStore _store,
     public SerializedCache SerializedCache { get; } = new();

    public(IStore store) { _store = store}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

And change all the code where we define it?

Copy link
Member

Choose a reason for hiding this comment

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

@shargon
why not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think is easier and simpler like this, Why we need two different types, one with cache and other without?

Copy link
Member

Choose a reason for hiding this comment

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

If you create an additional class called SerializedCache, doesn't require IReadOnlyStore. Also its misleading and creates more problems than it solves. For example: var cache = Store.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache is that intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

SerializedCache is not IReadOnlyStore so you can't do Store.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache

Copy link
Member

@cschuchardt88 cschuchardt88 Jan 23, 2025

Choose a reason for hiding this comment

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

Than it needs to inherit from that interface. All other cache classes do. Now your limiting the class.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand you, you can't do it Store.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache.SerializedCache

Copy link
Contributor

Choose a reason for hiding this comment

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

I think is easier and simpler like this, Why we need two different types, one with cache and other without?

Multi-layer structure.
One layer one feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't needed to cast something that always will be this type, waste of time, when we want to use it we will need to cast the type, and always we will create this type, otherwise we can't use it, for other things is ok, for this use case, seems worthless to me

@Jim8y Jim8y self-assigned this Jan 23, 2025
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.

Optimize OnPersist
5 participants