Skip to content
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

[Core] Node finite state machine #499

Closed
11 tasks
deblasis opened this issue Feb 8, 2023 · 1 comment · Fixed by #520
Closed
11 tasks

[Core] Node finite state machine #499

deblasis opened this issue Feb 8, 2023 · 1 comment · Fixed by #520
Assignees
Labels
consensus Consensus specific changes core Core infrastructure - protocol related p2p P2P specific changes

Comments

@deblasis
Copy link
Contributor

deblasis commented Feb 8, 2023

Objective

Have a FSM (Finite State Machine) that we can leverage to have different operating modes for the node depending on its internal state.

Origin Document

While developing #416, I identified the first real use case for different operating modes.

Specifically, when a new node joins the cluster, it doesn't know anything about the world and needs bootstrapping #498

Goals

  • Develop a simple state machine integrated with the bus
  • Have a way to visualize it easily

Deliverable

  • FSM implementation
  • Make target to generate a mermaid diagram of the current state machine
  • Initial working state machine that handles the P2P bootstrapping and the synched state for nodes that are already part of consensus (the first 4 in Localnet)

Non-goals / Non-deliverables

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • Task specific tests or benchmarks: make ...
  • New tests or benchmarks: make ...
  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md

Creator: @deblasis
Co-Owners: @Olshansk

@deblasis deblasis added core Core infrastructure - protocol related p2p P2P specific changes consensus Consensus specific changes labels Feb 8, 2023
@deblasis deblasis self-assigned this Feb 8, 2023
@deblasis deblasis moved this to In Progress in V1 Dashboard Feb 8, 2023
@deblasis
Copy link
Contributor Author

deblasis commented Feb 8, 2023

This is already done, just tracking the work done.

Specifically the implementation is here 1a92565

I have added a make target to generate a mermaid diagram and the first implementation of the FSM looks like this:

image

@deblasis deblasis moved this from In Progress to In Review in V1 Dashboard Feb 9, 2023
deblasis added a commit that referenced this issue Feb 17, 2023
…#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>
@github-project-automation github-project-automation bot moved this from In Review to Done in V1 Dashboard Feb 17, 2023
bryanchriswhite added a commit that referenced this issue Feb 20, 2023
* pokt/main:
  [Infra] KISS 3 - Cluster Manager [Merge me after #521] - (Issues: #490) (#522)
  Refactor/fix state sync logs (#515)
  [P2P] KISS 2 - Peer discovery [Merge me after #520] - (Issues: #416, #429) (#521)
  [Core] KISS 1 - Finite State Machine [Merge me first] - (Issue: #499) (#520)
  [CLI] Stake command bugfix (#518)
  [CLI] Cannot run make localnet_client_debug: Cannot initialise the keybase with the validator keys: Unable to find YAML file (#517)
  Fix the link shown by `make go_doc`
  Fixed duplicate GITHUB_WIKI tag
  [Documentation] Update Devlog Formatting (#512)
  [Docs & Bugs] Minor fixes post keybase changes (#513)
  [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) (#503)
  [Tooling] Integrate Keybase w/ CLI (Issue #484 ) (#501)
  update devlog2.md
  update devlog2.md
  Update devlog1.md
bryanchriswhite added a commit that referenced this issue Feb 20, 2023
* pokt/main:
  [Infra] KISS 3 - Cluster Manager [Merge me after #521] - (Issues: #490) (#522)
  Refactor/fix state sync logs (#515)
  [P2P] KISS 2 - Peer discovery [Merge me after #520] - (Issues: #416, #429) (#521)
  [Core] KISS 1 - Finite State Machine [Merge me first] - (Issue: #499) (#520)
  [CLI] Stake command bugfix (#518)
  [CLI] Cannot run make localnet_client_debug: Cannot initialise the keybase with the validator keys: Unable to find YAML file (#517)
  Fix the link shown by `make go_doc`
  Fixed duplicate GITHUB_WIKI tag
  [Documentation] Update Devlog Formatting (#512)
  [Docs & Bugs] Minor fixes post keybase changes (#513)
  [Utility] Foundational bugs, tests, code cleanup and improvements (1 / 2) (#503)
  [Tooling] Integrate Keybase w/ CLI (Issue #484 ) (#501)
  update devlog2.md
  update devlog2.md
  Update devlog1.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment