Skip to content

Mainnet support for ancillary nodes #645

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

Draft
wants to merge 2 commits into
base: v1.0-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions ansible/mainnet-support.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---

# Bootstrap

- name: Set up swap and aws environment vars
hosts: all
gather_facts: true
become: true
pre_tasks:
- name: Check if inside AWS
ansible.builtin.uri:
url: http://169.254.169.254/latest/meta-data
timeout: 2
register: aws_uri_check
failed_when: false
- name: Set AWS environment variable
ansible.builtin.set_fact:
is_aws_environment: '{{ aws_uri_check.status == 200 }}'
roles:
- role: aws
when: is_aws_environment
- swap

- name: Setup VPN
hosts: vpn
become: true
roles:
- role: openvpn
when: openvpn_enabled
tags: vpn

- name: Setup jq, Python, CWAgent and Docker
hosts: all
become: true
pre_tasks:
- name: Update apt cache and install jq
ansible.builtin.apt:
pkg:
- jq
- unzip
update_cache: true
vars:
pip_package: python3-pip
pip_install_packages:
- name: docker
version: "6.0.1"
- name: docker-compose
version: "1.29.2"
- name: requests
version: "2.31"
roles:
- geerlingguy.pip
- role: geerlingguy.docker
vars:
docker_apt_arch: "{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}"
docker_install_compose: false
docker_users:
- ubuntu
- docker_options
- eternal_terminal
- cwagent

- name: Setup logs
hosts: logs_nodes
become: true
roles:
- elastic_stack

- name: Setup metrics
hosts: metrics
become: true
roles:
- role: metrics

- name: Set up tenderdash on seed nodes
hosts: seed_nodes
become: true
pre_tasks:
- name: Set node variables for seed nodes
ansible.builtin.set_fact:
node: "{{ seed_nodes[inventory_hostname] }}"
mode: "seed"
tags: always
when: inventory_hostname in seed_nodes
roles:
- role: tenderdash
- role: elastic_beats
core_container_name: dashd


# Leaving this commented in here

# - name: Register HP masternodes
# hosts: wallet_nodes
# become: true
# roles:
# - role: mn_init
# mnlist: "{{ hp_masternodes }}"
# funding_amount: "{{ masternode_collaterals.hpmn | int }}"

# - name: Update inventory with HPMN protx values
# hosts: wallet_nodes
# roles:
# - role: mn_protx_config
# mnlist: "{{ hp_masternodes }}"

- name: Set up core and platform on HP masternodes
hosts: hp_masternodes
become: true
pre_tasks:
- name: Check inventory for HP masternodes
ansible.builtin.set_fact:
node: "{{ hp_masternodes[inventory_hostname] }}"
tags: always
when: inventory_hostname in hp_masternodes
roles:
- role: dash_cli
- role: dashmate
- role: mn_status_report
- role: elastic_beats
core_container_name: core
abci_logs_path: "{{ dashmate_logs_dir }}"

# - name: Clean up
# hosts: all
# become: true
# tasks:
# - name: Prune unused Docker images
# community.docker.docker_prune:
# containers: true
# images: true
# images_filters:
# dangling: false
# networks: true
# volumes: false
# builder_cache: true
12 changes: 10 additions & 2 deletions lib/cli/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Validate network name

networks=("regtest testnet devnet mainnet")
NETWORK_NAME=$1
networks=("regtest" "testnet" "devnet" "mainnet" "mainnet-support")

print_error() {
echo "$1" >&2
exit 1
}

if grep -q "devnet-" <<< "$NETWORK_NAME"; then
NETWORK="devnet"
Expand All @@ -11,9 +17,11 @@ if grep -q "devnet-" <<< "$NETWORK_NAME"; then
elif [[ " ${networks[@]} " =~ " ${NETWORK_NAME} " ]]; then
NETWORK="$NETWORK_NAME"
else
print_error "Invalid network name '$NETWORK_NAME'. Supported networks: regtest, devnet-<name>, testnet, mainnet"
print_error "Invalid network name '$NETWORK_NAME'. Supported networks: regtest, devnet-<name>, testnet, mainnet, mainnet-support"
fi

echo "Selected network: $NETWORK"

INVENTORY_FILE="networks/$NETWORK_NAME.inventory"
ANSIBLE_CONFIG_PATH="networks/$NETWORK_NAME.yml"
TERRAFORM_CONFIG_PATH="networks/$NETWORK_NAME.tfvars"
Expand Down
17 changes: 12 additions & 5 deletions lib/configGenerator/generateAnsibleConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
config.main_domain = '';
config.tenderdash_chain_id = networkName;

if (network === 'mainnet-support') {
network = 'mainnet';

Check failure on line 62 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Assignment to function parameter 'network'
support = true;

Check failure on line 63 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

'support' is not defined
}

Check failure on line 64 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Trailing spaces not allowed

const {
hdPrivateKey: dpnsHDPrivateKey,
derivedMasterPrivateKey: dpnsDerivedMasterPK,
Expand Down Expand Up @@ -99,23 +104,19 @@
network = 'testnet';
}

if (!support) {

Check failure on line 107 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

'support' is not defined
// Faucet
const faucetPrivateKey = new PrivateKey(undefined, network);

Check failure on line 109 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2

config.faucet_address = faucetPrivateKey.toAddress(network).toString();

Check failure on line 111 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2
config.faucet_privkey = faucetPrivateKey.toWIF();

Check failure on line 112 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2

// Spork

Check failure on line 114 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2
const sporkPrivateKey = new PrivateKey(undefined, network);

Check failure on line 115 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2

config.dashd_sporkaddr = sporkPrivateKey.toAddress(network).toString();

Check failure on line 117 in lib/configGenerator/generateAnsibleConfig.js

View workflow job for this annotation

GitHub Actions / Test package

Expected indentation of 4 spaces but found 2
config.dashd_sporkkey = sporkPrivateKey.toWIF();

// Elastic keys
config.elastic_password = crypto.randomBytes(32).toString('base64').slice(0, 32);
config.kibana_password = crypto.randomBytes(32).toString('base64').slice(0, 32);
config.kibana_encryptionkey = crypto.randomBytes(32).toString('base64').slice(0, 32);

// Governance proposals
config.governance_proposal_count = 2;

Expand Down Expand Up @@ -153,6 +154,12 @@
.privateKey.toPublicKey().toString();
config.withdrawals_hd_second_public_key = withdrawalsDerivedSecondPK
.privateKey.toPublicKey().toString();
}

// Elastic keys
config.elastic_password = crypto.randomBytes(32).toString('base64').slice(0, 32);
config.kibana_password = crypto.randomBytes(32).toString('base64').slice(0, 32);
config.kibana_encryptionkey = crypto.randomBytes(32).toString('base64').slice(0, 32);

// Dashd
config.dashd_debug = 0;
Expand Down
Loading