Skip to content

Commit

Permalink
ADD: devnet (#2014)
Browse files Browse the repository at this point in the history
* init

* test ansible

* ADD: init genesis

* EDIT: copy & init genesis role

* ADD: timeout after initiating genesis

* EDIT: molecule verify

* MODIFY: separate functions

* ADD: devnet parent modal

* ADD: import/create genesis modal

* ADD: genesis file to pinia

* ADD: createSetup modal component for devnet first step

* ADD: multi-steps setup devnet

* ADD: devnet store

* REMOVE: ansible role - copy genesis

* ADD: engine.jwt for devnet

* MODIFY: geth for devnet

* REMOVE: outdated fn

* ADD: geth devnet port & modifying write genesis fn

* MODIFY: prysm CL & VL for devnet

* format check

* FIX: genesis config modal

* ADD: alloc modal & func

* format

* REFACTOR: create genesis, aaloc , select client

* ADD: summary modal

* REFACTOR: genesis parent modal

* format

* FIX: prysm validator volume for devnet

* ADD: setup devnet function

* REFACTOR: format

* REFACTOR: entrypoint

* copy initiated datas to service dir

* ADD: devnet services monitoring & image for prysm & ignore validator list

* FIX: image version

* ADD: no image update for devnet prysm

* REFACTOR: molecule test

* format check

* ADD: devnet icons

* FIX: devnet setup layout

* ADD: advance allocation config

* REFACTOR: some devnet steps

* FIX: setup layout for devnet on node page

* REFACTOR: devnet text

* ADD: devnet to network list

* REFACTOR: clean devnet components

* format check

* ADD: delete account & update alloc

* REFACTOR: format

* ADD: chainID & feeRecipient prysm CL

* format check

* FIX: export modal in devnet mode

* FIX: drawer services filter in devnet network

* FIX: control page with the devnet

* format check

* FIX: devnet filter for client switch

* FIX: copying init files at starting

* ADD: suto start devnet services & after remove init files

* REFACTOR: set default fee recipient

* FIX: common services expert window

* ADD: no switch network for devnet

* ADD: import genesis & setup devnet

* FIX: format

* FIX: config.yaml formatting

* FIX: reverse change for the test

* FIX: support only POS

* FIX: genesis.json update

* FIX: geth POW depracation

* FIX: keep geth old version for devnet

* @gbayasgalan
FIX: keep geth old version for devnet

* Revert "@gbayasgalan"

This reverts commit c5b5e51.

* FIX: typo and image version

* FIX: geth image for devnet (specific version)

* FIX: change function name for more clarity

* IMPROVEMENT: devnet ports

* FIX: reduce duplication of services cmd

* FIX: image from defaults

* FIX: image versions for devnet

* ADD: devnet version exception

* FIX: format

---------

Co-authored-by: Max Behzadi <[email protected]>
Co-authored-by: mabasian <[email protected]>
  • Loading branch information
3 people authored Nov 21, 2024
1 parent 90a196e commit 5781c91
Show file tree
Hide file tree
Showing 62 changed files with 2,279 additions and 439 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
},
"vue3snippets.enable-compile-vue-file-on-did-save-code": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
"cSpell.words": ["devnet"]
}
7 changes: 7 additions & 0 deletions controls/defaults/stereum_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ stereum_static:
prometheus: v2.47.2
notifications: v1.1.0

devnet:
# consensus clients
prysm: v5.0.4

# execution clients
geth: v1.14.10-amd64

# mevboost - relay
relay:
goerli: https://0xafa4c6985aa049fb79dd37010438cfebeb0f2bd42b115b89dd678dab0670c1de38da0c4e9138c9290a398ecd9a0b3110@builder-relay-goerli.flashbots.net
29 changes: 29 additions & 0 deletions controls/roles/initiate-devnet-genesis/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
language: python
python: "2.7"

# Use the new container infrastructure
sudo: false

# Install ansible
addons:
apt:
packages:
- python-pip

install:
# Install ansible
- pip install ansible

# Check ansible version
- ansible --version

# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg

script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
33 changes: 33 additions & 0 deletions controls/roles/initiate-devnet-genesis/.yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Converge
hosts: all
vars_files:
- ../../../../defaults/stereum_defaults.yaml

tasks:
- name: "initiate-devnet-genesis"
include_role:
name: "initiate-devnet-genesis"
vars:
working_dir: "{{ stereum_static.defaults.controls_install_path }}"
#EOF
88 changes: 88 additions & 0 deletions controls/roles/initiate-devnet-genesis/molecule/default/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
vars:
ssh_port: 22
ssh_user: root
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
tasks:
- name: Create SSH key
user:
name: "{{ lookup('env', 'USER') }}"
generate_ssh_key: true
ssh_key_file: "{{ ssh_path }}"
force: true
register: generated_ssh_key

- name: Register the SSH key name
set_fact:
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"

- name: Register SSH key for test instance(s)
hcloud_ssh_key:
name: "{{ ssh_key_name }}"
public_key: "{{ generated_ssh_key.ssh_public_key }}"
state: present

- name: Create molecule instance(s)
hcloud_server:
name: "{{ item.name }}"
server_type: "{{ item.server_type }}"
ssh_keys:
- "{{ ssh_key_name }}"
volumes: "{{ item.volumes | default(omit) }}"
image: "{{ item.image }}"
datacenter: "{{ item.datacenter | default(omit) }}"
user_data: "{{ item.user_data | default(omit) }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: present
register: server
with_items: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0

- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
with_items: "{{ server.results }}"

- name: Populate instance config dict
set_fact:
instance_conf_dict:
{
"instance": "{{ item.hcloud_server.name }}",
"ssh_key_name": "{{ ssh_key_name }}",
"address": "{{ item.hcloud_server.ipv4_address }}",
"user": "{{ ssh_user }}",
"port": "{{ ssh_port }}",
"identity_file": "{{ ssh_path }}",
}
with_items: "{{ hetzner_jobs.results }}"
register: instance_config_dict
when: server.changed | bool

- name: Convert instance config dict to a list
set_fact:
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
when: server.changed | bool

- name: Dump instance config
copy:
content: "{{ instance_conf | to_json | from_json | to_yaml }}"
dest: "{{ molecule_instance_config }}"
when: server.changed | bool

- name: Wait for SSH
wait_for:
port: "{{ ssh_port }}"
host: "{{ item.address }}"
search_regex: SSH
delay: 10
with_items: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
#EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- name: Destroy
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ molecule_no_log }}"
tasks:
- name: Populate the instance config
block:
- name: Populate instance config from file
set_fact:
instance_conf: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
skip_instances: false
rescue:
- name: Populate instance config when file missing
set_fact:
instance_conf: {}
skip_instances: true

- name: Destroy molecule instance(s)
hcloud_server:
name: "{{ item.instance }}"
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
state: absent
register: server
with_items: "{{ instance_conf }}"
when: not skip_instances
async: 7200
poll: 0

- name: Wait for instance(s) deletion to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: hetzner_jobs
until: hetzner_jobs.finished
retries: 300
with_items: "{{ server.results }}"

- name: Remove registered SSH key
hcloud_ssh_key:
name: "{{ instance_conf[0].ssh_key_name }}"
state: absent
when:
- not skip_instances
- instance_conf | length # must contain at least one instance

- name: Populate instance config
set_fact:
instance_conf: {}

- name: Dump instance config
copy:
content: "{{ instance_conf | to_yaml }}"
dest: "{{ molecule_instance_config }}"
when: server.changed | bool
#EOF
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: molecule_hetznercloud
platforms:
- name: "initiate-devnet-genesis--default--ubuntu-22.04"
server_type: cx22
image: ubuntu-22.04
provisioner:
name: ansible
config_options:
ssh_connection:
ssh_args: -o ServerAliveInterval=30 -o ControlMaster=auto -o ControlPersist=60s
lint: |
set -e
yamllint .
ansible-lint .
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
#- idempotence
- verify
- destroy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include initiate-devnet-genesis"
include_role:
name: "initiate-devnet-genesis"
#EOF
Loading

0 comments on commit 5781c91

Please sign in to comment.