[Persistence] Refactors TreeStore to Use Module Pattern#808
[Persistence] Refactors TreeStore to Use Module Pattern#808dylanlott merged 32 commits intopersistence/tree-storefrom
Conversation
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## persistence/tree-store #808 +/- ##
==========================================================
- Coverage 30.86% 30.80% -0.06%
==========================================================
Files 108 109 +1
Lines 9228 9245 +17
==========================================================
Hits 2848 2848
- Misses 6040 6057 +17
Partials 340 340
☔ View full report in Codecov by Sentry. |
d10be2a to
66a6a98
Compare
c79087e to
4332e96
Compare
|
|
||
| func (t *treeStore) GetModuleName() string { | ||
| return modules.TreeStoreModuleName | ||
| } |
There was a problem hiding this comment.
Here's a brief code review of the provided patch. The code seems to implement a treeStore module as part of a larger package dealing with trees. It has three methods: Create, GetModuleName, and the exported function Create.
Potential issues and suggestions for improvement:
-
Error handling: There isn't any explicit error handling in the provided code, which might be okay if the functionality is simple and doesn't require error checking. However, it's worth considering if any errors should be caught or returned by the functions.
-
Struct definition: Since
treeStorestruct is used here (as a pointer receiver in methods), its definition should also be added in this package. Make sure the corresponding struct definition is in the same package, or import it if necessary. -
Comments and documentation: The code lacks comments and documentation. Providing descriptions for each function and their input parameters can make the code easier to understand, maintain, and use.
-
Consistent naming: In this code snippet, the
Createmethod is implemented with a pointer receiver while the exportedCreatefunction creates an instance oftreeStore. To avoid potential confusion, consider naming the exported function differently from the method. For example, you might rename it toNewTreeStore. -
Module registration:
bus.RegisterModule(m)doesn't seem to accept any error feedback. Ensure that proper error handling is performed within theRegisterModule()method or refactor the code to allow error reporting if registration fails.
There was a problem hiding this comment.
@Olshansk occasionally, I meant to turn it off earlier though, it's less useful when they're repeated
52e18e3 to
758798e
Compare
| option(m) | ||
| } | ||
|
|
||
| m.SetBus(bus) |
There was a problem hiding this comment.
| m.SetBus(bus) | |
| bus.RegisterModule(m) |
Is there a difference in these calls? I think doing this way and adding a method to the Bus interface would allow for TreeStore access outside of persistence, seeing as the method GetTreeStore was removed from the interface is this the intended way?
treeStore := bus.GetTreeStore()There was a problem hiding this comment.
@bryanchriswhite would be able to explain the difference better. I just followed his pointers on how to get my module working.
|
|
||
| // TreeStore manages atomic access to a set of merkle trees | ||
| // that compose the state hash. | ||
| GetTreeStore() TreeStore |
There was a problem hiding this comment.
As we are removing this from the persistence context how can we access the TreeStore module from outside of the persistence package if needed?
There was a problem hiding this comment.
It can't be accessed from the outside, which is the desired outcome. Only the PersistenceContext should be exposed for external calls.
persistence/module.go
Outdated
| } | ||
|
|
||
| func (m *persistenceModule) GetTreeStore() modules.TreeStore { | ||
| func (m *persistenceModule) GetTreeStore() modules.TreeStoreModule { |
There was a problem hiding this comment.
I am confused as this is present but has been removed from the PersistenceModule interface?
There was a problem hiding this comment.
Good catch, this was dead code, it's removed now. 👍
This reverts commit f45db36.
## Description Refactors the TreeStore to use the Module pattern and register it on the Bus. Addresses comment from #756 by @Olshansk about making the TreeStore a full module. ## Issue <img width="836" alt="image" src="https://github.com/pokt-network/pocket/assets/5915948/30fae7fb-26b3-49ed-a8b5-f336bcf43707"> Addresses refactor from #756 mentioned above. ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Adds the TreeStore module plumbing - Creates the TreeStoreModule interface in shared/modules ## Testing - [x] `make develop_test`; if any code changes were made - [ ] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made <!-- REMOVE this comment block after following the instructions If you added additional tests or infrastructure, describe it here. Bonus points for images and videos or gifs. --> ## Required Checklist - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --------- Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
## Description Loads the TreeStore from a proper module and allows it access to the bus. ## Issue Refactor related to #756 This PR is the sum of feedback from #808. ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Makes the TreeStore component into a proper module. - Removes the txIndexer from the Update method interface. ## Testing - [x] `make develop_test`; if any code changes were made - [x] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
## Description - [Persistence] Adds a logger to TreeStore module ## Issue Enabled by changes introduced in #756 and #808 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Adds a logger to the tree store ## Testing - [x] `make develop_test`; if any code changes were made - [x] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
Description
Refactors the TreeStore to use the Module pattern and register it on the Bus.
Addresses comment from #756 by @Olshansk about making the TreeStore a full module.
Issue
Addresses refactor from #756 mentioned above.
Type of change
Please mark the relevant option(s):
List of changes
Testing
make develop_test; if any code changes were mademake test_e2eon k8s LocalNet; if any code changes were madee2e-devnet-testpasses tests on DevNet; if any code was changedRequired Checklist
godocformat comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*if I updatedshared/*README(s)