[Core] Consolidate all node configurations into a new configs package - (Issue #396)#403
[Core] Consolidate all node configurations into a new configs package - (Issue #396)#403
Conversation
|
@Olshansk I would appreciate a quick scan on this, just to make sure it's getting where it's supposed to be. Please point out blatant gaps (apart from the fact that I need to centralize genesis as well but I am waiting for this initial feedback on the design before proceeding). 🙏 |
Olshansk
left a comment
There was a problem hiding this comment.
tl;dr I ❤️ where this is going
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
| poolFriendlyNames = map[Pools]string{ | ||
| Pools_POOLS_UNSPECIFIED: "Unspecified", | ||
| Pools_POOLS_DAO: "DAO", | ||
| Pools_POOLS_FEE_COLLECTOR: "FeeCollector", |
There was a problem hiding this comment.
| Pools_POOLS_FEE_COLLECTOR: "FeeCollector", | |
| Pools_POOLS_FEE_COLLECTOR: "FeeCollectorPool", |
There was a problem hiding this comment.
Are you sure you want to change this? The current values reflect what's currently on main, also, I could argue that they are entities in the table pool so the suffix is redundant.
| func init() { | ||
| poolFriendlyNames = map[Pools]string{ | ||
| Pools_POOLS_UNSPECIFIED: "Unspecified", | ||
| Pools_POOLS_DAO: "DAO", |
There was a problem hiding this comment.
| Pools_POOLS_DAO: "DAO", | |
| Pools_POOLS_DAO: "DAOPool", |
persistence/genesis.go
Outdated
| stakedActorsInsertConfigs := []struct { | ||
| Name string | ||
| Getter func() []*coreTypes.Actor | ||
| InsertFn func(address []byte, publicKey []byte, output []byte, paused bool, status int32, serviceURL string, stakedTokens string, chains []string, pausedHeight int64, unstakingHeight int64) error |
There was a problem hiding this comment.
I would say yes but if we want to enforce a style I would say let's be consistent and scout the whole codebase for similar instances and rectify accordingly otherwise it becomes a mix and match.
Agreed. I was trying to be consistent with line 83 of this file (just local consistency).
I believe we can enforce not specifying types (when they're the same) using the automatic linters @okdas set-up since these are standard golang suggestions. They're currently off because we need to do a one-time cleanup.
You are correct that #295 encompasses this.
Another thing we could do is adding newlines when the signatures are particularly long. I think you did that somewhere in the codebase and I like it since it allows the reader to avoid horizontal scrolling.
I do like it but think it's overkill here because the function is anonymous.
Let me know how you want to go about your suggestion and, more generally, about styling guidelines, perhaps this could be related to linting? (https://github.com/pokt-network/pocket/issues/295)
Let's just be consistent between this and line 83 and #295 will encompass the work of enforcing repo-wide guidelines.
persistence/shared_sql.go
Outdated
| return | ||
| } | ||
|
|
||
| actor.ActorType = actorSchema.GetActorType() |
There was a problem hiding this comment.
getActor uses getActorFromRow under the hood
BUT
GetAllXXX uses getActorFromRow directly
So this won't actually fully work.
I'm okay with leaving it as is because we have a ton of scope creep, but could you add a TODO to fix it (in a follow up PR). I also think this is a really good opportunity to do some TDD to be future-proof.
| ## [0.0.0.10] - 2022-12-21 | ||
| ## [0.0.0.17] - 2022-12-28 | ||
|
|
||
| - Added missing `ActorType` in `GetAllXXXX()` functions |
There was a problem hiding this comment.
Left a comment in persistence/shared_sql.go
|
|
||
| ## [0.0.0.14] - 2022-12-28 | ||
|
|
||
| - `ActorsToAddrBook` now skips actors that are not validators since they don't have a serviceUrl generic parameter |
There was a problem hiding this comment.
Regarding libp2p - makes sense when we get there.
Regarding the val filtering - see the comment I left in p2p/addrbook_provider/persistence.go
Also, what is this concept of generic parameter? Where can I learn more about it?
This is just a poor design decision that was the result of a compromise during the shared module refactor.
We (currently) have 4 protocol actor types:
- Fisherman
- Validator
- Servicer
- Application
There are things they all share (e.g. an address) and there are things that are specific:
- Servicers need a "serviceURL" to service nodes
- Fisherman need a "serviceURL" to enable QoS
- Applications need a 'maxRelaysCount' which is only specific to them
The two potential future paths we take are:
- One Protobuf per actor
- One
BaseActorprotobuf that's embedded in each ProtocolActor type
See #313 for the origin document.
| config modules.PersistenceConfig | ||
| genesisState modules.PersistenceGenesisState | ||
| config *configs.PersistenceConfig | ||
| genesisState *genesis.GenesisState |
There was a problem hiding this comment.
Ditto - fair point.
Given what you said, I don't love either approach but prefer what we have for now over the alternative.
| book := make(typesP2P.AddrBook, 0) | ||
| for _, v := range actors { | ||
| // only add validator actors since they are the only ones having a service url in their generic param at the moment | ||
| if v.ActorType != coreTypes.ActorType_ACTOR_TYPE_VAL { |
There was a problem hiding this comment.
TL;DR: The way I see it, NO...
Like you said, it looks like these serviceUrls have a different meaning depending on the actor type and therefore using them to connect to a node for consensus related messaging/structured broadcast is a... shortcut.
Nodes are listening on the ConsensuPort which by default is 8080 and it seems that serviceUrl has been used to have an easy way to address them.
I guess this is because we don't have -yet- a full-fledged P2P module that owns the addressbook and can be relied upon for routing and messaging (that will come with peer discovery and churn).
We won't address messages via serviceUrl but rather by address or nodeId, then P2P would figure out how to reach that peer.
In LocalNet we spin up 4 validator nodes and the debug commands are all related to consensus.
This explains why previously we had 👇👈 while now we have 👉👇

If we consider other actors I can only imagine that since we have overlaps (eg: node1.consensus:8080 in genesis.json is a Validator, a ServiceNode and also a Fisherman) we would have duplicate messages at a minimum.
I wish Brian was here to pick his brain on this :) the ways I see it, structured gossip happens under the hood in the P2P module, when you say "broadcast to all validators" you don't know/care if the message is also handled and retransmitted by a Fisherman in order to reach a "nearby" Validator. That's implementation detail of the P2P algorithm.
I would say that for now we have to filter. Happy to discuss further even offline.
Just let me know how to proceed here.
There was a problem hiding this comment.
Solid explanation. I'm convinced.
Excited to see what our next steps are going to be here :)
Olshansk
left a comment
There was a problem hiding this comment.
One tiny comment about the addition of val1.json and val2.json to the root dir.
- Add it to
.gitignore - Update
docs/demos/iteration_3_end_to_end_tx.mdto move it into/tmpand reference that directly.
|
|
||
| ## [0.0.0.14] - 2022-12-28 | ||
|
|
||
| - `ActorsToAddrBook` now skips actors that are not validators since they don't have a serviceUrl generic parameter |
val1.json
Outdated
| @@ -0,0 +1 @@ | |||
| "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4" | |||
There was a problem hiding this comment.
nope. Genuine mistake
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestGetAllStakedActors(t *testing.T) { |
| book := make(typesP2P.AddrBook, 0) | ||
| for _, v := range actors { | ||
| // only add validator actors since they are the only ones having a service url in their generic param at the moment | ||
| if v.ActorType != coreTypes.ActorType_ACTOR_TYPE_VAL { |
There was a problem hiding this comment.
Solid explanation. I'm convinced.
Excited to see what our next steps are going to be here :)

Description
The main goal of this PR is to centralize configurations into a single
configspackage.The feedback received was that the previous implementation was probably overly abstracted. Mockability is still preserved thanks to the fact that we are ultimately just dealing with structs without any logic attached to them.
It also tends to address:
https://github.com/pokt-network/pocket/compare/issue/396-consolidate-config?expand=1#diff-ee06bf613911836fdf48424397b7ec556c2e1a8ddba5adecca4c1782aea24087L30
Issue
configspackage #396Type of change
Please mark the relevant option(s):
List of changes
configspackagecoretypes (Actor, Account, etc) undercoreTypesmax_mempool_countin config (it was causing P2P instabilities in LocalNet)Testing
make develop_testREADMERequired Checklist
If Applicable Checklist
shared/docs/*if I updatedshared/*README(s)