Conversation
…ndor/mock/etc changes
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
…-discovery-k8s-base354 Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
…ss-peer-discovery-k8s-base354 Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
Olshansk
left a comment
There was a problem hiding this comment.
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 <alex@deblasis.net>
…-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 <olshansky@pokt.network>
|
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 <alex@deblasis.net> Co-authored-by: Dmitry K <okdas@pm.me> Co-authored-by: Dmitry Knyazev <okdas@users.noreply.github.com> Co-authored-by: Daniel Olshansky <olshansky@pokt.network> Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
… (#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 <alex@deblasis.net> Co-authored-by: Dmitry Knyazev <okdas@users.noreply.github.com> Co-authored-by: Daniel Olshansky <olshansky@pokt.network> Co-authored-by: Dmitry K <okdas@pm.me> Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>
…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 <alex@deblasis.net> Co-authored-by: Dmitry K <okdas@pm.me> Co-authored-by: Dmitry Knyazev <okdas@users.noreply.github.com> Co-authored-by: Daniel Olshansky <olshansky@pokt.network> Co-authored-by: Daniel Olshansky <olshansky.daniel@gmail.com>


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-managerfrom 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.yamlIssue
Fixes #416
Fixes #490
Fixes #429
Fixes #498
Fixes #499
Type of change
Please mark the relevant option(s):
List of changes
CLI
not_interactiveflag to allow for non-interactiveStakeandUnstaketransactions (dogfooding incluster-manager)rpcAddressBookProviderandrpcCurrentHeightProviderrespectively and thebusfor dependency injectionNode binary
bootstrap-nodesflag that can be used to override the default bootstrap nodesInfra
docker-composeto name the deployment aspocket-v1instead ofdeployments(default is the containing folder name)cluster-managerthat 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-manageradditioncli-clientnow waits for thev1-validator001since its required for address book sourcingConsensus
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessCreateto accept generic optionsresetToGenesisclears the utility mempool as wellConsensusNewHeightEventon new heightLogger
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessP2P
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessdebugAddressBookProviderrpcAddressBookProviderto source the address book from the RPC serverbusfor dependency injection of theaddressBookProviderandcurrentHeightProviderdebugCurrentHeightProviderrpcCurrentHeightProviderto source the current height from the RPC servercurrentHeightProviderinstead of consensus (that was what we wanted to avoid in the first place)getAddrBookDeltato calculate changes to the address book between heights and update the internal state and componentry accordinglybootstrapnodes supportConsensusNewHeightEventTypeadnStateMachineTransitionEventTypeto update the address book and current height and determine if a bootstrap is neededPersistence
base_modules.IntegratableModulefor DRYnessRPC
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessRuntime
bootstrap_nodes_csvinP2PConfigto allow for a comma separated list of bootstrap nodesmodules.ModulesRegistryfor better separation of concernsStateMachineModuleaccessorsManagerembedsbase_modules.IntegratableModulefor DRYnessShared
UnmarshalTexttoEd25519PrivateKeyConsensusNewHeightEventandStateMachineTransitionEventBaseInterruptableModuleandBaseIntegratableModuleto reduce repetition and boilerpate code (DRYness)ModulesRegistryandStateMachineModuleaccessors and interfacesModuleOptionpattern to fine tune modules behaviourStateMachineto thenodeinitializationState Machine 🆕
CHANGELOG.mdandREADME.mdStateMachineModuleimplementation with a POC of the finite state machine that will be used to manage the node lifecycleStateMachinediagram generator (linked in README.md)StateMachinewith thebusto propagateStateMachineTransitionEventevents whenever they occurTelemetry
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessUtility
base_modules.IntegratableModuleandbase_modules.InterruptableModulefor DRYnessApplyTransactionfails (it was completely ignored before and it was really hard to understand what was going on)Testing
make develop_testREADMERequired Checklist
If Applicable Checklist
shared/docs/*if I updatedshared/*README(s)