Skip to content

Comments

[Chore] Submodule pattern updates to TreeStore#896

Merged
dylanlott merged 21 commits intomainfrom
persistence/tree-store-submodule
Jul 20, 2023
Merged

[Chore] Submodule pattern updates to TreeStore#896
dylanlott merged 21 commits intomainfrom
persistence/tree-store-submodule

Conversation

@dylanlott
Copy link
Contributor

@dylanlott dylanlott commented Jul 11, 2023

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):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

  • Makes the TreeStore take proper advantage of the new Submodule interface

Testing

  • make develop_test; if any code changes were made
  • make test_e2e on k8s LocalNet; if any code changes were made
  • e2e-devnet-test passes tests on DevNet; if any code was changed
  • Docker Compose LocalNet; if any major functionality was changed or introduced
  • k8s LocalNet; 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 on touched members (see: 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 diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@reviewpad reviewpad bot added the medium Pull request is medium label Jul 11, 2023
@dylanlott dylanlott self-assigned this Jul 11, 2023
@dylanlott dylanlott added the code health Nice to have code improvement label Jul 11, 2023
@dylanlott dylanlott marked this pull request as ready for review July 11, 2023 21:11
@dylanlott dylanlott force-pushed the persistence/tree-store-submodule branch from 3741a01 to 7165f7c Compare July 11, 2023 21:22
@dylanlott dylanlott requested review from Olshansk and h5law July 11, 2023 21:52
@dylanlott dylanlott added the e2e-devnet-test Runs E2E tests on devnet label Jul 11, 2023
Copy link
Contributor

@h5law h5law left a comment

Choose a reason for hiding this comment

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

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 ;)

@dylanlott dylanlott force-pushed the persistence/tree-store-submodule branch from 7165f7c to 6181db1 Compare July 12, 2023 14:56
@dylanlott
Copy link
Contributor Author

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 ;)

Updated to use the Submodule type as the title suggests, I had a bad merge somewhere that I didn't catch. Fixed now 👍

@dylanlott dylanlott added the do not merge Prevent merging even with sufficient approvals label Jul 12, 2023
@dylanlott dylanlott changed the title [chore] submodule pattern updates to TreeStore [WIP][Chore] Submodule pattern updates to TreeStore Jul 12, 2023
// of the underlying trees by utilizing the lazy loading
// functionality provided by the underlying smt library.
type treeStore struct {
type TreeStore struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

  1. Why not update TreeStoreModule?
  2. What needs to happen to not expose this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Collaborator

@bryanchriswhite bryanchriswhite Jul 13, 2023

Choose a reason for hiding this comment

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

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!

Copy link
Collaborator

@bryanchriswhite bryanchriswhite Jul 13, 2023

Choose a reason for hiding this comment

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

There is also section in the Testutils notion doc about this ("Testing unexported members").

Copy link
Collaborator

@bryanchriswhite bryanchriswhite Jul 13, 2023

Choose a reason for hiding this comment

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

Can you add details on the import errors in #880? I'm guessing they're related.

💯 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@dylanlott I created a branch #920 and ran the tests and everything worked out fine.

Where are the tests that are blocking this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@reviewpad reviewpad bot added large Pull request is large and removed medium Pull request is medium labels Jul 12, 2023
@dylanlott dylanlott changed the title [WIP][Chore] Submodule pattern updates to TreeStore [Chore] Submodule pattern updates to TreeStore Jul 12, 2023
@dylanlott dylanlott removed the do not merge Prevent merging even with sufficient approvals label Jul 12, 2023
@dylanlott dylanlott requested review from Olshansk and h5law July 12, 2023 21:41
// of the underlying trees by utilizing the lazy loading
// functionality provided by the underlying smt library.
type treeStore struct {
type TreeStore struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

@dylanlott
Copy link
Contributor Author

PTAL at #896 (files) as well

Okay, I believe I addressed all comments 👍

dylanlott and others added 18 commits July 20, 2023 10:56
* 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
@dylanlott dylanlott force-pushed the persistence/tree-store-submodule branch from 64c9e92 to c9dfe00 Compare July 20, 2023 16:57
Copy link
Collaborator

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

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

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for adding this!

@dylanlott dylanlott merged commit 021dba4 into main Jul 20, 2023
@dylanlott dylanlott deleted the persistence/tree-store-submodule branch July 20, 2023 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code health Nice to have code improvement e2e-devnet-test Runs E2E tests on devnet large Pull request is large waiting-for-review

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants