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

[Infrastructure] LocalNet on Kubernetes #354

Merged
merged 77 commits into from
Feb 6, 2023
Merged

Conversation

okdas
Copy link
Member

@okdas okdas commented Nov 14, 2022

Description

Implements LocalNet that is powered by Kubernetes.

Issue

pocket-operator issue: pokt-network/pocket-operator#7 not using operator currently, just utilizing Kubernetes directly.

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other

List of changes

Introducing new dependencies to run localnet developer environment

Testing

  • tilt up should bring the whole stack online.
  • LocalNet w/ all of the steps outlined in the README

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • 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 diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@okdas okdas added the infra Core infrastructure - not protocol related label Nov 14, 2022
@okdas okdas requested a review from a team as a code owner November 14, 2022 19:30
@okdas okdas self-assigned this Nov 14, 2022
@okdas okdas requested a review from Gustavobelfort November 14, 2022 20:03
Copy link

@ManInWeb3 ManInWeb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm
Great job

@Olshansk
Copy link
Member

lgtm Great job

Before we merge this in, @okdas can you show (gif, video, demo, instructions) of it working?

Also, please make sure to follow the LocalNet test steps to make sure it works.

@okdas
Copy link
Member Author

okdas commented Nov 23, 2022

@Olshansk of course, I'm adding the instructions! :)

@Olshansk Olshansk added the do not merge Prevent merging even with sufficient approvals label Nov 29, 2022
@Olshansk Olshansk marked this pull request as draft November 29, 2022 16:45
@Olshansk
Copy link
Member

Olshansk commented Dec 6, 2022

@Olshansk of course, I'm adding the instructions! :)

@okdas Lmk when this is ready for a spin.

@okdas
Copy link
Member Author

okdas commented Dec 7, 2022

@Olshansk of course, I'm adding the instructions! :)

@okdas Lmk when this is ready for a spin.

Still in progress, but if you want to check it out locally and provide feedback/see if you catch any issues please make sure to follow the doc and also utilize the dk-localnet-pocket-operator branch from pocket-operator (the second repo is needed - more info in docs).

@okdas okdas marked this pull request as ready for review December 10, 2022 00:37
@okdas okdas changed the title [WIP] LocalNet controlled by pocket-operator LocalNet controlled by pocket-operator Dec 10, 2022

### How to change configuration files

LocalNet resources are managed by pocket-operator, so if you'd like to change a config file (e.g. genesis file), you can do it by modifying the corresponding CRD in `pocket-operator` repo.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I should expand on that, but this should probably go into the pocket-operator documentation and linked here.

@okdas okdas requested a review from Olshansk February 3, 2023 01:46
@Olshansk
Copy link
Member

Olshansk commented Feb 3, 2023

f75fde2

I really like the until nc -z trick. Brilliant.

  • I am thinking about a way to stake and unstake validators when they come online/go offline during the scale-up scale-down operations. My idea is to write a simple program that interacts with client-go to react to k8s events and stake/unstake accordingly (obviously I'd have to change the genesis so that the validators have POKT to stake and also provide access to the keys of the validators to this program, parsing the private-keys.yaml I guess).

@okdas My understanding is this:

  1. We couldn't get pocket-operator working on LocalNet (for now)
  2. We'll use pocket-operator in DevNet
  3. The current configuration scales the number of validators (e.g. services) but doesn't actually trigger the stake/unstake command based on k8s events

The flow @deblasis described might literally let us scale (and discover) validators in a local environment next week, so I'd support going in that approach unless I'm missing something?

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small set of minor NITs and comments and we're good to go!

The only major point I wanted to discuss is why we shouldn't move forward with the approach outlined by Alessandro.

build/localnet/README.md Outdated Show resolved Hide resolved
Tiltfile Outdated
])

# # Exposes postgres port to 5432 on the host machine.
# k8s_resource(new_name='postgres',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, just need to update the comment.

@@ -0,0 +1,71 @@
apiVersion: apps/v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deblasis put this together. See field #6 in P2PConfig. Because of the prefix we use with viper + the change in case POCKET_P2P_IS_CLIENT_ONLY maps to is_client_only in the proto.

message P2PConfig {
  string private_key = 1;
  uint32 consensus_port = 2;
  bool use_rain_tree = 3;
  conn.ConnectionType connection_type = 4;
  uint64 max_mempool_count = 5; // this is used to limit the number of nonces that can be stored in the mempool, after which a FIFO mechanism is used to remove the oldest nonces and make space for the new ones
  bool is_client_only = 6;
}

build/localnet/README.md Outdated Show resolved Hide resolved
build/localnet/README.md Outdated Show resolved Hide resolved
build/localnet/README.md Outdated Show resolved Hide resolved
@@ -3,25 +3,29 @@ load("ext://helm_resource", "helm_resource", "helm_repo")
load("ext://namespace", "namespace_create")
load("ext://restart_process", "docker_build_with_restart")

tiltfile_dir = os.path.dirname(config.main_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this! I think it's going to make the codebase much easier to understand

build/localnet/Tiltfile Outdated Show resolved Hide resolved
build/localnet/Tiltfile Outdated Show resolved Hide resolved
@@ -69,6 +71,15 @@ spec:
subPath: genesis.json
- name: validator-storage
mountPath: /validator-storage
initContainers:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this :)

okdas and others added 10 commits February 3, 2023 12:35
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
Co-authored-by: Daniel Olshansky <olshansky@pokt.network>
@okdas
Copy link
Member Author

okdas commented Feb 3, 2023

The only major point I wanted to discuss is why we shouldn't move forward with the approach outlined by Alessandro.

We totally should! I love what @deblasis did!

I think I've addressed all of your suggestions, let me resolve conflicts and it'll be ready for another round.

@okdas okdas requested a review from Olshansk February 3, 2023 22:36
Addresses begin with `YYYXX` number, where `YYY` is a number of an actor and `XX` is [a type of actor](../../shared/core/types/proto/actor.proto#L7). For example:
* `420043b854e78f2d5f03895bba9ef16972913320` is a validator #420.
* `66603bc4082281b7de23001ffd237da62c66a839` is a fisherperson #666.
* `0010297b55fc9278e4be4f1bcfe52bf9bd0443f8` is a service node (a servicer) #001.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI: We're going to rename all Service Node like instances to Servicer soon

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor suggestion, but otherwise, LGTM!

build/localnet/README.md Outdated Show resolved Hide resolved
@deblasis deblasis mentioned this pull request Feb 6, 2023
14 tasks
@okdas okdas removed the do not merge Prevent merging even with sufficient approvals label Feb 6, 2023
@okdas okdas merged commit 6728d6f into main Feb 6, 2023
@okdas okdas deleted the dk-localnet-pocket-operator branch February 6, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra Core infrastructure - not protocol related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants