-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: local-env with wizard-spawned network (#443)
Refs: ETCM-9298
- Loading branch information
Showing
5 changed files
with
381 additions
and
3 deletions.
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
dev/local-environment/configurations/wizard/governance-authority/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
#!/bin/bash | ||
|
||
echo "Installing dependencies..." | ||
|
||
apt -qq update &> /dev/null | ||
apt -qq -y install expect curl jq ncat &> /dev/null | ||
|
||
cp /usr/local/bin/partner-chains-node /partner-chains-node | ||
|
||
echo "Beginning configuration..." | ||
|
||
|
||
echo "Generating keys..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards generate-keys | ||
set timeout 60 | ||
expect "node base path (./data)" | ||
send "\r" | ||
expect eof | ||
EOF | ||
|
||
|
||
echo "Waiting for the Cardano network to sync and for Ogmios to start..." | ||
|
||
while true; do | ||
if nc -z ogmios $OGMIOS_PORT; then | ||
break | ||
else | ||
sleep 1 | ||
fi | ||
done | ||
|
||
|
||
echo "Preparing configuration..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards prepare-configuration | ||
set timeout 180 | ||
expect "node base path (./data)" | ||
send "\r" | ||
expect "Your bootnode should be accessible via:" | ||
send "\r" | ||
expect "Enter bootnode TCP port (3033)" | ||
send "30333\r" | ||
expect "Enter bootnode hostname (localhost)" | ||
send "partner-chains-wizard-1\r" | ||
expect "Ogmios protocol (http/https)" | ||
send "\r" | ||
expect "Ogmios hostname (localhost)" | ||
send "ogmios\r" | ||
expect "Ogmios port (1337)" | ||
send "\r" | ||
expect "path to the payment verification file (payment.vkey)" | ||
send "keys/funded_address.vkey\r" | ||
expect "Select an UTXO to use as the genesis UTXO" | ||
send "\r" | ||
expect "path to the payment signing key file (payment.skey)" | ||
send "keys/funded_address.skey\r" | ||
expect "Do you want to configure a native token for you Partner Chain? (Y/n)" | ||
send "n\r" | ||
expect eof | ||
EOF | ||
|
||
|
||
echo "Waiting for permissioned candidate's keys to be generated..." | ||
while true; do | ||
if [ -f "/shared/partner-chains-wizard-2.ready" ]; then | ||
break | ||
else | ||
sleep 1 | ||
fi | ||
done | ||
|
||
|
||
echo "Inserting permissioned candidates' keys into configuration..." | ||
governance_authority_public_keys=$(cat partner-chains-public-keys.json) | ||
permissioned_candidate_public_keys=$(cat /shared/partner-chains-public-keys.json) | ||
jq '.initial_permissioned_candidates = [ | ||
'"$governance_authority_public_keys"', | ||
'"$permissioned_candidate_public_keys"' | ||
]' pc-chain-config.json > tmp.json && mv tmp.json pc-chain-config.json | ||
|
||
|
||
echo "Creating chain spec..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards create-chain-spec | ||
expect "Do you want to continue? (Y/n)" | ||
send "\r" | ||
expect eof | ||
EOF | ||
|
||
|
||
echo "Configuring Balances..." | ||
jq '.genesis.runtimeGenesis.config.balances.balances = [ | ||
["5C7C2Z5sWbytvHpuLTvzKunnnRwQxft1jiqrLD5rhucQ5S9X", 1000000000000000], | ||
["5D9eDKbFt4JKaEndQvMmbJYnpX9ENUj8U9UUg1AxSa64FJxE", 1000000000000000] | ||
]' chain-spec.json > tmp.json && mv tmp.json chain-spec.json | ||
|
||
echo "Configuring Epoch Length..." | ||
jq '.genesis.runtimeGenesis.config.sidechain.slotsPerEpoch = 5' chain-spec.json > tmp.json && mv tmp.json chain-spec.json | ||
|
||
echo "Copying chain-spec.json file to /shared/chain-spec.json..." | ||
cp chain-spec.json /shared/chain-spec.json | ||
echo "chain-spec.json generation complete." | ||
|
||
|
||
echo "Copying pc-chain-config.json file to /shared/pc-chain-config.json..." | ||
cp pc-chain-config.json /shared/pc-chain-config.json | ||
|
||
touch /shared/chain-spec.ready | ||
|
||
|
||
echo "Setting up main chain state..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards setup-main-chain-state | ||
set timeout 300 | ||
expect "DB-Sync Postgres connection string (postgresql://postgres-user:postgres-password@localhost:5432/cexplorer)" | ||
send "postgresql://postgres:$POSTGRES_PASSWORD@postgres:$POSTGRES_PORT/cexplorer\r" | ||
expect "Do you want to set/update the permissioned candidates on the main chain with values from configuration file? (y/N)" | ||
send "y\r" | ||
expect "Ogmios protocol (http/https)" | ||
send "\r" | ||
expect "Ogmios hostname (ogmios)" | ||
send "\r" | ||
expect "Ogmios port (1337)" | ||
send "\r" | ||
expect "path to the payment signing key file (keys/funded_address.skey)" | ||
send "\r" | ||
expect "Do you want to set/update the D-parameter on the main chain? (y/N)" | ||
send "y\r" | ||
expect "Ogmios protocol (http/https)" | ||
send "\r" | ||
expect "Ogmios hostname (ogmios)" | ||
send "\r" | ||
expect "Ogmios port (1337)" | ||
send "\r" | ||
expect "Enter P, the number of permissioned candidates seats, as a non-negative integer. (0)" | ||
send "2\r" | ||
expect "Enter R, the number of registered candidates seats, as a non-negative integer. (0)" | ||
send "1\r" | ||
expect "path to the payment signing key file (keys/funded_address.skey)" | ||
send "\r" | ||
expect "Done. Main chain state is set." | ||
expect eof | ||
EOF | ||
|
||
|
||
echo "Partner Chain configuration is complete, and will be able to start after two mainchain epochs." | ||
|
||
echo "Starting the node..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards start-node | ||
expect "Proceed? (Y/n)" | ||
send "\r" | ||
set timeout -1 | ||
expect eof | ||
EOF |
52 changes: 52 additions & 0 deletions
52
dev/local-environment/configurations/wizard/permissioned/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
echo "Installing dependencies..." | ||
|
||
apt -qq update &> /dev/null | ||
apt -qq -y install expect jq &> /dev/null | ||
|
||
cp /usr/local/bin/partner-chains-node /partner-chains-node | ||
|
||
echo "Beginning configuration..." | ||
|
||
|
||
echo "Generating keys..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards generate-keys | ||
set timeout 60 | ||
expect "node base path (./data)" | ||
send "\r" | ||
expect "All done!" | ||
expect eof | ||
EOF | ||
|
||
cp partner-chains-public-keys.json /shared/partner-chains-public-keys.json | ||
touch /shared/partner-chains-wizard-2.ready | ||
|
||
|
||
echo "Waiting for chain-spec.json and pc-chain-config.json to be ready..." | ||
while true; do | ||
if [ -f "/shared/chain-spec.ready" ]; then | ||
break | ||
else | ||
sleep 1 | ||
fi | ||
done | ||
|
||
cp /shared/chain-spec.json . | ||
cp /shared/pc-chain-config.json . | ||
|
||
|
||
echo "Configuring Node P2P port..." | ||
jq '.node_p2p_port = 30334' pc-resources-config.json > tmp.json && mv tmp.json pc-resources-config.json | ||
|
||
echo "Starting the node..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards start-node | ||
expect "DB-Sync Postgres connection string (postgresql://postgres-user:postgres-password@localhost:5432/cexplorer)" | ||
send "postgresql://postgres:$POSTGRES_PASSWORD@postgres:$POSTGRES_PORT/cexplorer\r" | ||
expect "Proceed? (Y/n)" | ||
send "Y\r" | ||
set timeout -1 | ||
expect eof | ||
EOF |
106 changes: 106 additions & 0 deletions
106
dev/local-environment/configurations/wizard/registered/entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/bash | ||
|
||
echo "Installing dependencies..." | ||
|
||
apt -qq update &> /dev/null | ||
apt -qq -y install expect jq &> /dev/null | ||
|
||
cp /usr/local/bin/partner-chains-node /partner-chains-node | ||
|
||
echo "Beginning configuration..." | ||
|
||
|
||
echo "Generating keys..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards generate-keys | ||
set timeout 60 | ||
expect "node base path (./data)" | ||
send "\r" | ||
expect eof | ||
EOF | ||
|
||
|
||
echo "Waiting for chain-spec.json and pc-chain-config.json to be ready..." | ||
while true; do | ||
if [ -f "/shared/chain-spec.ready" ]; then | ||
break | ||
else | ||
sleep 1 | ||
fi | ||
done | ||
|
||
cp /shared/chain-spec.json . | ||
cp /shared/pc-chain-config.json . | ||
|
||
|
||
echo "Registering candidate..." | ||
register1_output=$(expect <<EOF | ||
spawn ./partner-chains-node wizards register1 | ||
set timeout 60 | ||
expect "Ogmios protocol (http/https)" | ||
send "\r" | ||
expect "Ogmios hostname (localhost)" | ||
send "ogmios\r" | ||
expect "Ogmios port (1337)" | ||
send "\r" | ||
expect "path to the payment verification file (payment.vkey)" | ||
send "keys/funded_address.vkey\r" | ||
expect "Select UTXO to use for registration" | ||
send "\r" | ||
expect eof | ||
catch wait result | ||
exit [lindex \$result 3] | ||
EOF | ||
) | ||
|
||
register2_command=$(echo "$register1_output" | sed -n '/\/partner-chains-node wizards register2 \\/,$p' | tr -d '\\\n') | ||
echo "$register2_command" | ||
|
||
echo "Running register2 command..." | ||
register2_output=$(expect <<EOF | ||
spawn $register2_command | ||
set timeout 60 | ||
expect "Path to mainchain signing key file (cold.skey)" | ||
send "keys/cold.skey\r" | ||
expect "/partner-chains-node wizards register3" | ||
expect eof | ||
catch wait result | ||
exit [lindex \$result 3] | ||
EOF | ||
) | ||
|
||
register3_command=$(echo "$register2_output" | sed -n '/\/partner-chains-node wizards register3 \\/,$p' | tr -d '\\\n') | ||
echo "$register3_command" | ||
|
||
echo "Running register3 command..." | ||
expect <<EOF | ||
spawn $register3_command | ||
set timeout 300 | ||
expect "Path to mainchain payment signing key file (payment.skey)" | ||
send "keys/funded_address.skey\r" | ||
expect "Ogmios protocol (http/https)" | ||
send "\r" | ||
expect "Ogmios hostname (ogmios)" | ||
send "\r" | ||
expect "Ogmios port (1337)" | ||
send "\r" | ||
expect "Show registration status? (Y/n)" | ||
send "Y\r" | ||
expect "DB-Sync Postgres connection string (postgresql://postgres-user:postgres-password@localhost:5432/cexplorer)" | ||
send "postgresql://postgres:$POSTGRES_PASSWORD@postgres:$POSTGRES_PORT/cexplorer\r" | ||
expect eof | ||
EOF | ||
|
||
echo "Configuring Node P2P port..." | ||
jq '.node_p2p_port = 30335' pc-resources-config.json > tmp.json && mv tmp.json pc-resources-config.json | ||
|
||
echo "Starting the node..." | ||
expect <<EOF | ||
spawn ./partner-chains-node wizards start-node | ||
expect "Proceed? (Y/n)" | ||
send "Y\r" | ||
set timeout -1 | ||
expect eof | ||
EOF | ||
|
||
# tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
partner-chains-wizard-1: | ||
container_name: partner-chains-wizard-1 | ||
image: ${PARTNER_CHAINS_NODE_IMAGE} | ||
platform: linux/amd64 | ||
user: "0:0" | ||
volumes: | ||
- shared-volume:/shared | ||
- ./configurations/cardano/keys/funded_address.skey:/keys/funded_address.skey | ||
- ./configurations/cardano/keys/funded_address.vkey:/keys/funded_address.vkey | ||
- ./configurations/wizard/governance-authority/entrypoint.sh:/entrypoint.sh | ||
environment: | ||
- OGMIOS_PORT=${OGMIOS_PORT} | ||
- POSTGRES_PORT=${POSTGRES_PORT} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
ports: | ||
- "30333:30333" | ||
- "9933:9944" | ||
entrypoint: ["/bin/bash", "/entrypoint.sh"] | ||
|
||
partner-chains-wizard-2: | ||
container_name: partner-chains-wizard-2 | ||
image: ${PARTNER_CHAINS_NODE_IMAGE} | ||
platform: linux/amd64 | ||
user: "0:0" | ||
volumes: | ||
- shared-volume:/shared | ||
- ./configurations/wizard/permissioned/entrypoint.sh:/entrypoint.sh | ||
environment: | ||
- POSTGRES_PORT=${POSTGRES_PORT} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
ports: | ||
- "30334:30334" | ||
- "9934:9944" | ||
entrypoint: ["/bin/bash", "/entrypoint.sh"] | ||
|
||
partner-chains-wizard-3: | ||
container_name: partner-chains-wizard-3 | ||
image: ${PARTNER_CHAINS_NODE_IMAGE} | ||
platform: linux/amd64 | ||
user: "0:0" | ||
volumes: | ||
- shared-volume:/shared | ||
- ./configurations/cardano/keys/funded_address.skey:/keys/funded_address.skey | ||
- ./configurations/cardano/keys/funded_address.vkey:/keys/funded_address.vkey | ||
- ./configurations/cardano/keys/cold.skey:/keys/cold.skey | ||
- ./configurations/cardano/keys/cold.vkey:/keys/cold.vkey | ||
- ./configurations/wizard/registered/entrypoint.sh:/entrypoint.sh | ||
environment: | ||
- POSTGRES_PORT=${POSTGRES_PORT} | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD} | ||
ports: | ||
- "30335:30335" | ||
- "9935:9944" | ||
entrypoint: ["/bin/bash", "/entrypoint.sh"] |
Oops, something went wrong.