[Chore] Submodule pattern updates to TreeStore#896
Conversation
3741a01 to
7165f7c
Compare
h5law
left a comment
There was a problem hiding this comment.
I am unsure why you have moved away from TreeStore being a submodule but instead making it a full module. Other than that the changes are good I have actually addressed this in my ibc/host_module branch.
👍🏼 for the new mockgen line ;)
7165f7c to
6181db1
Compare
Updated to use the Submodule type as the title suggests, I had a bad merge somewhere that I didn't catch. Fixed now 👍 |
persistence/trees/trees.go
Outdated
| // of the underlying trees by utilizing the lazy loading | ||
| // functionality provided by the underlying smt library. | ||
| type treeStore struct { | ||
| type TreeStore struct { |
There was a problem hiding this comment.
Given that we have an interface TreeStoreModule, we shouldn't need to publically expose the implementation as well. Otherwise, feels like we're not encapsulating/defining logic correctly.
- Why not update TreeStoreModule?
- What needs to happen to not expose this?
There was a problem hiding this comment.
This is necessary for testing. If we don't do this, then we can't access the right methods, and if we keep the tests in the same package as trees, then we get import errors because we haven't ironed out some of the dependencies.
There was a problem hiding this comment.
In the future, I think that if we're making a design decision solely for testing, we should add a TECHDEBT comment that says something along the lines of "exposed for testing purposes.
This is necessary for testing. If we don't do this, then we can't access the right methods
Can you look at ConsensusDebugModule and expose the functions we need in a testing interface with a TECHDEBT(#880) comment above it?
then we get import errors because we haven't ironed out some of the dependencies.
Can you add details on the import errors in #880? I'm guessing they're related. cc @bryanchriswhite
There was a problem hiding this comment.
If testing is the only place where this would be imported you can add a file to this package which includes the //go:build test build tag and exports it for usage in any test package:
type TreeStore = treeStore
func (ts *treeStore) SomeTestHelperMethod(...) { ... }
See p2p/raintree/testutil.go or p2p/testutil.go for examples.
Don't forget to add a second test build tag to the test which is doing the importing!
There was a problem hiding this comment.
There is also section in the Testutils notion doc about this ("Testing unexported members").
There was a problem hiding this comment.
Can you add details on the import errors in #880? I'm guessing they're related.
💯 🙏
There was a problem hiding this comment.
@Olshansk I added a techdebt comment linking to #880 and will include the test tag changes in a future PR that incorporates the tests. The capitalization is in this PR because I split the branch into multiple PRs after I had written the tests.
@bryanchriswhite I'll include the tag and custom struct technique in the TestUtils doc as well, because it's mentioned but not detailed and it's a smart trick to get around import errors for now until we fix the deeper issue, and might still be useful later on anyway.
There was a problem hiding this comment.
@dylanlott I created a branch #920 and ran the tests and everything worked out fine.
Where are the tests that are blocking this?
There was a problem hiding this comment.
They're in a WIP PR that was based off of the branch that I split up to make these first three commits, so this will work right now, and I'll use the approach @bryanchriswhite suggested to adjust the package scope for the names later, that works fine by me.
persistence/trees/trees.go
Outdated
| // of the underlying trees by utilizing the lazy loading | ||
| // functionality provided by the underlying smt library. | ||
| type treeStore struct { | ||
| type TreeStore struct { |
There was a problem hiding this comment.
In the future, I think that if we're making a design decision solely for testing, we should add a TECHDEBT comment that says something along the lines of "exposed for testing purposes.
This is necessary for testing. If we don't do this, then we can't access the right methods
Can you look at ConsensusDebugModule and expose the functions we need in a testing interface with a TECHDEBT(#880) comment above it?
then we get import errors because we haven't ironed out some of the dependencies.
Can you add details on the import errors in #880? I'm guessing they're related. cc @bryanchriswhite
Okay, I believe I addressed all comments 👍 |
…hes them at runtime
* fixes treestore module tests to use the bus for fetching the height provider instead of accessing it from the package
* this commit updates persistence module to only fetch the TreeStore from the bus instead of maintaining a reference to it at Create time.
* renames TreeStoreModuleName to TreeStoreSubmoduleName
* renames the tree store's factory function to treeStoreFactory instead of TreeStoreFactory to keep it private.
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Small commit to reduce visibility of a type for in progress PR
64c9e92 to
c9dfe00
Compare
Olshansk
left a comment
There was a problem hiding this comment.
Approving with one minor change request. PTAL
| This is useful not only for prototyping but also for different use cases such as the `p1` CLI and the `pocket` binary where different implementations of the same module are necessary due to the fact that the `p1` CLI doesn't have a persistence module but still needs to know what's going on in the network. | ||
|
|
||
| **Registration**: Submodules can be registered the same way full Modules by passing the Submodule to the `RegisterModule` function. Submodules should typically be registered to the bus for dependency injection reasons. | ||
| **Registration**: Submodules can be registered the same way full Modules by passing the Submodule to the `RegisterModule` function. Submodules should typically be registered to the bus for dependency injection reasons. Registration should occur _after_ processing the module's options. |
There was a problem hiding this comment.
Thank you for adding this!
Description
This PR updates the TreeStore submodule to use the latest submodule pattern updates.
Issue
Part of the work of implementing #562
Type of change
Please mark the relevant option(s):
List of changes
SubmoduleinterfaceTesting
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)