-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Shared] Config and genesis handling refactoring idea #235
[Shared] Config and genesis handling refactoring idea #235
Conversation
utility/test/module_test.go
Outdated
@@ -8,6 +8,7 @@ import ( | |||
"os" | |||
"testing" | |||
|
|||
typesPers "github.com/pokt-network/pocket/persistence/types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utility mod
added import from Persistence mod
.
We're trying to get rid of this cross module sharing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could move module creation for testing purposes under test_artifacts to hide away the implementation details of the other modules when we are testing one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 This will enable the "composable testing blocks", so the testing framework will simply evolve over time.
Probably outside the scope of this one PR, but we could create a ticket just to remove this.
It would include doing greps like this:
grep --exclude-dir='./persistence' -r "github.com/pokt-network/pocket/persistence"
grep --exclude-dir='./consensus' -r "github.com/pokt-network/pocket/consensus"
...
@okdas Can even add this as a custom linter once #190 is done. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #239
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Olshansk that is likely going to be a somewhat sophisticated AST rule but should be doable! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this was resolved. We just added an issue to automatically check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my review is a bit outdated but figured I'd publish the comments I have as an interim iteration. Looking great so far
…s_refactoring1 Signed-off-by: Alessandro De Blasis <[email protected]>
The only blocker from my end is fixing the unit tests. Some of it might be resolved after we merge in #282, so let's aim to get that in first. I took another look through the PR. With the goal of unblocking downstream work. the 3 biggest action items remaining IMO are (see screenshots below):
@deblasis Can you create a "235 follow ups" to track it? @andrewnguyen22 Assuming we merge in #282 and create the follow-up for that work, can we merge this in? |
I will review it again @Olshansk |
…s_refactoring1 Signed-off-by: Alessandro De Blasis <[email protected]>
I have created the issues to track the open items as requested. They are not assigned to me and I put them in QoL, please change that as you see fit.
I have to point out that tests are not failing in this PR... what's failing is the CI because of the new linting: and also for the build / push part: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for creating the follow up work.
👍 from my POV. Not perfect but I was to prevent the scope of the PR from increasing and it's already a big improvement over what we had.
Let's wait to hear if @andrewnguyen22 has any blockers though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much there, a few blockers and a few discussion items.
Resolve conflicts and blockers and I'll approve
@@ -21,6 +24,21 @@ type InterruptableModule interface { | |||
|
|||
type InitializableModule interface { | |||
GetModuleName() string | |||
InitConfig(pathToConfigJSON string) (IConfig, error) | |||
InitGenesis(pathToGenesisJSON string) (IGenesis, error) | |||
Create(runtime RuntimeMgr) (Module, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-Blocker:
The granularity here is getting a bit sticky for me. Consider mental load vs. verbosity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. If it sounds like over-optimization or premature optimization let's consider the fact that soon we'll have modules that are very simple and only implement a subset of the Module interface. Logging for example, which is coming soon. Keybase as well I guess.
Maybe my .Net background surfaces here. I am used to very small and targeted interfaces.
I am open to suggestions.
serviceNodes, snPrivateKeys := NewActors(types.ActorType_ServiceNode, numServiceNodes) | ||
fish, fishPrivateKeys := NewActors(types.ActorType_Fisherman, numFisherman) | ||
|
||
genesisState := runtime.NewGenesis( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-Blocker:
Is there no way to use runtime
for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean to move test_artifacts under runtime. I have done it.
@@ -1,9 +1,11 @@ | |||
package test_artifacts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-Blocker:
Can we move this to the runtime package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
telemetry/noop_module.go
Outdated
@@ -62,6 +59,14 @@ func (m *NoopTelemetryModule) GetBus() modules.Bus { | |||
return m.bus | |||
} | |||
|
|||
func (*NoopTelemetryModule) ValidateConfig(cfg modules.Config) error { | |||
// DISCUSS (team): we cannot cast if we want to use mocks and rely on interfaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, see applicable comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe addressed with #235 (comment)
utility/module.go
Outdated
if u.bus == nil { | ||
log.Fatalf("Bus is not initialized") | ||
} | ||
return u.bus | ||
} | ||
|
||
func (*utilityModule) ValidateConfig(cfg modules.Config) error { | ||
// DISCUSS (team): we cannot cast if we want to use mocks and rely on interfaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree see applicable comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe addressed with #235 (comment)
…s_refactoring1 Signed-off-by: Alessandro De Blasis <[email protected]>
It was causing test failures because of inconsistent Postgresql state
Goland is the offender... weird format on save rules... investigate
return mgr | ||
} | ||
|
||
func NewManagerFromReaders(configReader, genesisReader io.Reader, options ...func(*Manager)) *Manager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could potentially remove this. I have used during development and forgot to clean after myself
@andrewnguyen22 thank you for your time and feedback reviewing this :) I have addressed all the comments that I have marked with a 👍 and left comments otherwise. There are a couple of questions from me but nothing major, I guess. Regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @deblasis
Description
This PR is a way to convey a design idea for the refactoring of the way we handle
config
andgenesis
as highlighted in a couple of Protocol Hours and also summarized, along with more context that should help us making the right decisions, into the discussion #234Issue
There's no issue per-se, this is basically TECHDEBT handling I guess. Let me know if I should create one.
Type of change
Please mark the options that are relevant.
List of changes
interfaces
instead of paths.runtime
package (runtime because what we do in there affects the runtime of the application)Testing
make test_all
README
Checklist