-
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
KISS Peer discovery, KISS Bootstrapping, Nodes auto-stake/unstake via K8S cluster-manager, Node Finite state machine - Issues #416, #490, #429, #498, #499 #491
Conversation
…ndor/mock/etc changes
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
…-discovery-k8s-base354 Signed-off-by: Alessandro De Blasis <[email protected]>
Signed-off-by: Alessandro De Blasis <[email protected]>
…ss-peer-discovery-k8s-base354 Signed-off-by: Alessandro De Blasis <[email protected]>
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.
Took another stab and ~75% done + replied to most of the responses. I think if we just split this into 2 PRs: FSM and k8s client, we'll be good to go and the reviews should be much faster given how many back & forth we've had here.
I have to say, for a PR that is trying to KISS, these screenshot speaks for itself ;)
…-discovery-k8s-base354 Signed-off-by: Alessandro De Blasis <[email protected]>
…-discovery-k8s-base354
I am sorry this is frustrating. I should have taken action and split it when it was code complete even if you said it was OK. I am going to explain in protocol hour my reasoning for this. I have now merged in the bugfixes I worked on yesterday and I am finally going to proceed with the splitting. |
…#520) ## Description This PR has been extracted from #491 and is, hopefully, more digestible from a code-review and scope point of view. In a nutshell: - It introduces the a Finite State Machine that is meant to govern the internal state, transitions and events - It includes a refactoring of our module initialization pattern using functional options (https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis) - It improves the module registration with a first class... you might have guessed it: `ModulesRegistry` - It reduces boilerplate code making our modules more DRY with the introduction of `base_modules` that provide basic functionality (that can still be customized/extended when needed) ## Issue Fixes #499 ## Type of change Please mark the relevant option(s): - [x] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [x] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes In a nutshell: - It introduces the a Finite State Machine that is meant to govern the internal state, transitions and events - It includes a refactoring of our module initialization pattern using functional options (https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis) - It improves the module registration with a first class... you might have guessed it: `ModulesRegistry` - It reduces boilerplate code making our modules more DRY with the introduction of `base_modules` that provide basic functionality (that can still be customized/extended when needed) ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] 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](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --------- Co-authored-by: Daniel Olshansky <[email protected]>
Closing this as it has been superseded by the PRs that are the result of cherry-picking into smaller deliverables:
|
…429) (#521) ## Description This PR has been extracted from #491 and is, hopefully, more digestible from a code-review and scope point of view. The main goal is to remove hardcoded nodes and move towards a more dynamic environment. It's also highlighting the potential entry points for subsequent P2P work The code leverages the abstractions added recently (`currentHeightProvider` and `addressBookProvider`) to fetch the data from an RPC endpoint. ## Issue Fixes #416 Fixes #429 ## Type of change Please mark the relevant option(s): - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [x] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes ### CLI - Updated CLI to use to source the address book and the current height from the RPC server leveraging the `rpcAddressBookProvider` and `rpcCurrentHeightProvider` respectively and the `bus` for dependency injection ### P2P - Modules embed `base_modules.IntegratableModule` and `base_modules.InterruptableModule` for DRYness - Deprecated `debugAddressBookProvider` - Added `rpcAddressBookProvider` to source the address book from the RPC server - Leveraging `bus` for dependency injection of the `addressBookProvider` and `currentHeightProvider` - Deprecated `debugCurrentHeightProvider` - Added `rpcCurrentHeightProvider` to source the current height from the RPC server - Fixed raintree to use the `currentHeightProvider` instead of consensus (that was what we wanted to avoid in the first place) - Added `getAddrBookDelta` to calculate changes to the address book between heights and update the internal state and componentry accordingly - Reacting to `ConsensusNewHeightEventType` to update the address book - Updated tests ### RPC - Updated RPC to expose the node's address book via GET /v1/p2p/staked_actors_address_book ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` <!-- REMOVE this comment block after following the instructions If you added additional tests or infrastructure, describe it here. Bonus points for images and videos or gifs. --> ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] 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](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --------- Signed-off-by: Alessandro De Blasis <[email protected]> Co-authored-by: Dmitry K <[email protected]> Co-authored-by: Dmitry Knyazev <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]>
… (#522) ## Description This PR has been extracted from #491 and is, hopefully, more digestible from a code-review and scope point of view. ## Issue Fixes #490 ## Type of change Please mark the relevant option(s): - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - When nodes are added/removed from the Kubernetes Localnet, we stake/unstake them automatically - We achieve the above by dogfooding our own CLI inside Kubernetes ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] 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](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --------- Signed-off-by: Alessandro De Blasis <[email protected]> Co-authored-by: Dmitry Knyazev <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]> Co-authored-by: Dmitry K <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]>
…ue: #498) (#523) ## Description This PR has been extracted from #491 and is, hopefully, more digestible from a code-review and scope point of view. This simply adds entrypoints and basic logic for node bootstrapping leveraging the finite state machine ## Issue Fixes #498 ## Type of change Please mark the relevant option(s): - [x] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Ability to fetch an addressbook from a bootstrap node(s) (by convention the first validator in LocalNet) - It's possible to override bootstrap nodes via CLI flag ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] 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](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s) --------- Signed-off-by: Alessandro De Blasis <[email protected]> Co-authored-by: Dmitry K <[email protected]> Co-authored-by: Dmitry Knyazev <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]>
Description
This PR aims at implementing a KISS implementation of Peer discovery #416
TL;DR: I believe that:
This + State sync = DevNet 🚀
I still need to add the endpoints for accessing the addressbooks but this PR in the meantime shows the auto-Staking/Unstaking functionality.
It works by dogfooding our own CLI which also works as a way for testing the functionality and the "feel" of the tooling we are building.
Areas of improvement
cluster-manager
from the debug CLI, for example to turn it on/off dynamically and also to scale up and down without the need for updating thelocalnet-config.yaml
Issue
Fixes #416
Fixes #490
Fixes #429
Fixes #498
Fixes #499
Type of change
Please mark the relevant option(s):
List of changes
CLI
not_interactive
flag to allow for non-interactiveStake
andUnstake
transactions (dogfooding incluster-manager
)rpcAddressBookProvider
andrpcCurrentHeightProvider
respectively and thebus
for dependency injectionNode binary
bootstrap-nodes
flag that can be used to override the default bootstrap nodesInfra
docker-compose
to name the deployment aspocket-v1
instead ofdeployments
(default is the containing folder name)cluster-manager
that is a standalone microservice in the K8S LocalNet that takes care of (for now) staking/unstaking automatically nodes that are added/removed from the deploymentcluster-manager
additioncli-client
now waits for thev1-validator001
since its required for address book sourcingConsensus
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessCreate
to accept generic optionsresetToGenesis
clears the utility mempool as wellConsensusNewHeightEvent
on new heightLogger
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessP2P
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessdebugAddressBookProvider
rpcAddressBookProvider
to source the address book from the RPC serverbus
for dependency injection of theaddressBookProvider
andcurrentHeightProvider
debugCurrentHeightProvider
rpcCurrentHeightProvider
to source the current height from the RPC servercurrentHeightProvider
instead of consensus (that was what we wanted to avoid in the first place)getAddrBookDelta
to calculate changes to the address book between heights and update the internal state and componentry accordinglybootstrap
nodes supportConsensusNewHeightEventType
adnStateMachineTransitionEventType
to update the address book and current height and determine if a bootstrap is neededPersistence
base_modules.IntegratableModule
for DRYnessRPC
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessRuntime
bootstrap_nodes_csv
inP2PConfig
to allow for a comma separated list of bootstrap nodesmodules.ModulesRegistry
for better separation of concernsStateMachineModule
accessorsManager
embedsbase_modules.IntegratableModule
for DRYnessShared
UnmarshalText
toEd25519PrivateKey
ConsensusNewHeightEvent
andStateMachineTransitionEvent
BaseInterruptableModule
andBaseIntegratableModule
to reduce repetition and boilerpate code (DRYness)ModulesRegistry
andStateMachineModule
accessors and interfacesModuleOption
pattern to fine tune modules behaviourStateMachine
to thenode
initializationState Machine 🆕
CHANGELOG.md
andREADME.md
StateMachineModule
implementation with a POC of the finite state machine that will be used to manage the node lifecycleStateMachine
diagram generator (linked in README.md)StateMachine
with thebus
to propagateStateMachineTransitionEvent
events whenever they occurTelemetry
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessUtility
base_modules.IntegratableModule
andbase_modules.InterruptableModule
for DRYnessApplyTransaction
fails (it was completely ignored before and it was really hard to understand what was going on)Testing
make develop_test
README
Required Checklist
If Applicable Checklist
shared/docs/*
if I updatedshared/*
README(s)