-
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
[P2P] refactor: peerstore provider (part 1) #804
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
I threw together a mindmap of my initial thinking, which was mainly focusd on whether this new API should be a debug-only thing (as it's being used in a "debug CLI" scenario). TLDR; I think "no" is the answer I landed on (plus some additional thinking): mindmap
Q: should p2p peerstore provider be debug only?
NO
REASONING
Will likely fit better with future versions / refactors
r1(**Perhaps it would and/or already does make sense to split PeerstoreProvider into StakedPeerstoreProvider and UnstakedPeerstoreProvider)
CONSEQUENCES
c1[MUST design a non-debug way to access p2p module's peerstores]
eg[e.g.: add GetUnstakedPeerstore method to modules.P2PModule]
Does this fight against peerstore provider / modular design?
YES because...
p[provides multiple ways to access the same thing: un/staked-actor-router peerstore]
NO because...
allows any module to get either peerstore without having to know anything about p2p module
no other single module can support this interface
justified by the need in the CLI
Alternatives
?
Makes Peerstore interface type "module shared"; i.e. it must be moved to another package avoid potential import cycles
w[WORKAROUND: in #804, I'm working around the need for this change by defining a consumer-side interface which I assert that the P2P module implements, in addition to its module interface]
YES
REASONING
r1[Only currently needed in a low-level / debug scenarios]
CONSEQUENCES
c1[Simpler implementation; no need for PeerstoreProvider interface refactor #804]
c2[Harder to maintain and more complex to reason about; would likely rely on build tags]
** Here's what splitting classDiagram
class IntegratableModule {
<<interface>>
+SetBus(bus Bus)
+GetBus() Bus
}
class PeerstoreProvider {
<<interface>>
}
class StakedPeerstoreProvider {
<<interface>>
+GetStakedPeerstoreAtHeight(height int) (Peerstore, error)
}
class UnstakedPeerstoreProvider {
<<interface>>
+GetUnstakedPeerstore() (Peerstore, error)
}
class persistencePeerstoreProvider
class rpcPeerstoreProvider
class p2pPeerstoreProvider {
-persistencePeerstoreProvider
-p2pModule P2PModule
}
class p2pModule
p2pPeerstoreProvider --o p2pModule
p2pPeerstoreProvider --* persistencePeerstoreProvider
p2pPeerstoreProvider --|> PeerstoreProvider
rpcPeerstoreProvider --|> StakedPeerstoreProvider
persistencePeerstoreProvider --|> StakedPeerstoreProvider
PeerstoreProvider --* StakedPeerstoreProvider
PeerstoreProvider --* UnstakedPeerstoreProvider
PeerstoreProvider --|> IntegratableModule
StakedPeerstoreProvider --|> IntegratableModule
UnstakedPeerstoreProvider --|> IntegratableModule
|
9209358
to
968be5f
Compare
968be5f
to
4bc605a
Compare
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.
First round feedback, waiting for E2E test results 👍
|
||
p2pModule := bus.GetP2PModule() | ||
if p2pModule == nil { | ||
return nil, fmt.Errorf("p2p module is not registered to bus and is required") |
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.
Nit: consider passing the bus to the Errrof for debugging purposes.
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.
The bus doesn't implement Stringer
, what do you expect/want the DX to look/feel like?
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.
☝️ The bus is just a point to our "DI framework" and "pubsub" so curious what you had in mind for this @dylanlott?
b802e1e
to
2489b92
Compare
0749b80
to
4589585
Compare
4589585
to
22ff0fd
Compare
_ persistencePStoreProviderFactory = &persistencePeerstoreProvider{} | ||
) | ||
|
||
type persistencePStoreProviderOption func(*persistencePeerstoreProvider) |
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.
On the topic of "not being afraid to change everything", take into consideration that maybe "providers" aren't the best approach with our bus based system.
Not making a comment on removing/extending them, but just sharing that it is not set in stone so don't feel constrained.
(cherry picked from commit 5254967bbe067e30c02fb63d40bc263f3d6def22)
* pokt/main: [P2P] refactor: peerstore provider (part 1) (#804)
Description
PeerstoreProvider
interfacepersistencePeerstoreProvider
Before
After
Issue
Realted:
Dependants:
Type of change
Please mark the relevant option(s):
List of changes
modules.Module
with simplermodules.IntegratableModule
inPeerstoreProvider
interfacePeerstoreProvider#GetP2PConfig()
methodPeerstoreProvider#GetUnstakedPeerstore()
methodp2pPeerstoreProvider
implementation ofPeerstoreProvider
interfaceFactory
generic typeTesting
make develop_test
; if any code changes were mademake test_e2e
on k8s LocalNet; if any code changes were madee2e-devnet-test
passes tests on DevNet; if any code was changedRequired Checklist
godoc
format comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)