Add playbook to generate mainnet genesis from exported testnet state
This commit is contained in:
parent
be5258c732
commit
cc0a325da6
40
playbooks/first-validator/generate-genesis.yml
Normal file
40
playbooks/first-validator/generate-genesis.yml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
- name: Generate Mainnet Genesis File
|
||||||
|
hosts: localhost
|
||||||
|
vars_files:
|
||||||
|
- first-validator-vars.yml
|
||||||
|
connection: local
|
||||||
|
tasks:
|
||||||
|
- name: Fetch repositories
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull"
|
||||||
|
|
||||||
|
- name: Build containers
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: "laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers"
|
||||||
|
|
||||||
|
- name: Copy exported testnet state file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ exported_state_path }}"
|
||||||
|
dest: "~/cerc/laconicd-stack/testnet-state.json"
|
||||||
|
remote_src: true # Set to true if exported_state_path is on the target host
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Run script to generate genesis file
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: "CHAIN_ID={{ cerc_chain_id }} EARLY_SUPPORTS_ACC_ADDRESS={{ early_supports_acc_address }} ~/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh ~/cerc/laconicd-stack/testnet-state.json"
|
||||||
|
always:
|
||||||
|
- name: Clean up temporary genesis directory
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ ansible_env.HOME }}/cerc/laconicd-stack/playbooks/first-validator/mainnet-genesis"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Remove temporary copied state file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "~/cerc/laconicd-stack/testnet-state.json"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Display genesis file location
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Mainnet genesis file generated at output/genesis.json"
|
@ -2,7 +2,7 @@
|
|||||||
- name: Run mainnet validator node
|
- name: Run mainnet validator node
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
vars_files:
|
vars_files:
|
||||||
- run-first-validator-vars.yml
|
- first-validator-vars.yml
|
||||||
vars:
|
vars:
|
||||||
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
data_directory: "{{ lookup('env', 'DATA_DIRECTORY') }}"
|
||||||
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
mainnet_deployment_dir: "{{ lookup('env', 'MAINNET_DEPLOYMENT_DIR') }}"
|
||||||
|
@ -22,34 +22,25 @@
|
|||||||
- The file will be generated in `<path-to-testnet-deployment>/export/testnet-state.json`
|
- The file will be generated in `<path-to-testnet-deployment>/export/testnet-state.json`
|
||||||
|
|
||||||
|
|
||||||
<!-- TODO: Create playbook to run steps below -->
|
|
||||||
|
|
||||||
- If mainnet node will be setup in new machine, fetch the stack again
|
- If mainnet node will be setup in new machine, fetch the stack again
|
||||||
|
|
||||||
- Build container image
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Fetch laconicd repo specified in stack
|
laconic-so fetch-stack git.vdb.to/cerc-io/laconicd-stack --git-ssh --pull
|
||||||
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd setup-repositories --git-ssh --pull
|
|
||||||
|
|
||||||
# Build image
|
|
||||||
laconic-so --stack ~/cerc/laconicd-stack/stack-orchestrator/stacks/mainnet-laconicd build-containers
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- Copy the generated exported state from earlier
|
- Copy over the exported `testnet-state.json` file to target machine
|
||||||
|
|
||||||
|
- Set envs
|
||||||
|
```
|
||||||
|
export EXPORTED_STATE_PATH=<absolute-path-to-exported-testnet-state-json>
|
||||||
|
export EARLY_SUPPORTS_ACC_ADDR=<account-address-controlled-by-laconic-foundation>
|
||||||
|
|
||||||
|
- Run playbook to use exported state for generating mainnet genesis
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp <path-to-exported-testnet-state> ~/cerc/laconicd-stack/testnet-state.json
|
ansible-playbook -i localhost, -c local ~/cerc/laconicd-stack/playbooks/first-validator/generate-genesis.yml -e "exported_state_path=$EXPORTED_STATE_PATH" -e "early_supports_acc_address=$EARLY_SUPPORTS_ACC_ADDR" --ask-become-pass
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run script to generate genesis file using the exported state
|
|
||||||
|
|
||||||
```bash
|
|
||||||
~/cerc/laconicd-stack/scripts/generate-mainnet-genesis.sh ~/cerc/laconicd-stack/testnet-state.json
|
|
||||||
```
|
|
||||||
|
|
||||||
- Genesis file will generated in `output/genesis.json`
|
|
||||||
|
|
||||||
## Run node
|
## Run node
|
||||||
|
|
||||||
- Update [run-first-validator-vars.yml](playbooks/first-validator/run-first-validator-vars.yml) with required values:
|
- Update [run-first-validator-vars.yml](playbooks/first-validator/run-first-validator-vars.yml) with required values:
|
||||||
|
@ -23,10 +23,12 @@ cp $TESTNET_STATE_FILE $MAINNET_GENESIS_DIR/testnet-state.json
|
|||||||
|
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
echo "Initializing a new empty chain with chain-id $CHAIN_ID..."
|
echo "Initializing a new empty chain with chain-id $CHAIN_ID..."
|
||||||
docker run -it \
|
docker run \
|
||||||
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
||||||
-v ./scripts:/scripts \
|
-v $script_dir:/scripts \
|
||||||
-e "CHAIN_ID=$CHAIN_ID" \
|
-e "CHAIN_ID=$CHAIN_ID" \
|
||||||
cerc/laconicd:local bash -c "/scripts/init-mainnet.sh"
|
cerc/laconicd:local bash -c "/scripts/init-mainnet.sh"
|
||||||
|
|
||||||
@ -34,17 +36,16 @@ docker run -it \
|
|||||||
|
|
||||||
# Carry over state from testnet to mainnet
|
# Carry over state from testnet to mainnet
|
||||||
echo "Carrying over state from testnet state to mainnet genesis..."
|
echo "Carrying over state from testnet state to mainnet genesis..."
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
python3 $script_dir/transfer-state.py
|
||||||
python $script_dir/transfer-state.py
|
|
||||||
|
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
# Run a script with cerc/laconicd:local to generate the genesis file
|
# Run a script with cerc/laconicd:local to generate the genesis file
|
||||||
# with onboarding module state and given allocations
|
# with onboarding module state and given allocations
|
||||||
echo "Performing alps allocations..."
|
echo "Performing alps allocations..."
|
||||||
docker run -it \
|
docker run \
|
||||||
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
-v ./$MAINNET_GENESIS_DIR:/root/.laconicd \
|
||||||
-v ./scripts:/scripts \
|
-v $script_dir:/scripts \
|
||||||
-e "CHAIN_ID=$CHAIN_ID" \
|
-e "CHAIN_ID=$CHAIN_ID" \
|
||||||
-e "EARLY_SUPPORTS_ACC_ADDRESS=$EARLY_SUPPORTS_ACC_ADDRESS" \
|
-e "EARLY_SUPPORTS_ACC_ADDRESS=$EARLY_SUPPORTS_ACC_ADDRESS" \
|
||||||
cerc/laconicd:local bash -c "/scripts/genesis.sh"
|
cerc/laconicd:local bash -c "/scripts/genesis.sh"
|
||||||
|
Loading…
Reference in New Issue
Block a user