Compare commits

...

5 Commits

Author SHA1 Message Date
IshaVenikar
62450f7a70 Replace cosmos_address with laconic_address 2024-08-14 14:51:36 +05:30
81a3141db4 Fix default moniker config in laconicd stack (#12)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) and cerc-io/laconicd#51

Reviewed-on: cerc-io/fixturenet-laconicd-stack#12
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
2024-08-10 06:39:45 +00:00
fb7f074059 Add environment variable for node moniker (#11)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: cerc-io/fixturenet-laconicd-stack#11
2024-08-09 11:06:30 +00:00
b35a42f229 Add a script to generate genesis file using given allocation amounts (#10)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Reviewed-on: cerc-io/fixturenet-laconicd-stack#10
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-08-08 07:44:18 +00:00
a9ebd14276 Remove create-fixturenet script and use init script from laconicd repo instead (#8)
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: cerc-io/fixturenet-laconicd-stack#8
2024-08-01 12:10:57 +00:00
6 changed files with 104 additions and 130 deletions

View File

@ -2,15 +2,21 @@ services:
laconicd:
restart: unless-stopped
image: cerc/laconicd:local
command: ["bash", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
command: ["bash", "/scripts/init.sh"]
environment:
TEST_AUCTION_ENABLED: ${TEST_AUCTION_ENABLED:-false}
TEST_REGISTRY_EXPIRY: ${TEST_REGISTRY_EXPIRY:-false}
ONBOARDING_ENABLED: ${ONBOARDING_ENABLED:-false}
STAKING_AMOUNT: ${STAKING_AMOUNT:-1000000000000000}
AUTHORITY_AUCTION_ENABLED: ${AUTHORITY_AUCTION_ENABLED}
AUTHORITY_AUCTION_COMMITS_DURATION: ${AUTHORITY_AUCTION_COMMITS_DURATION}
AUTHORITY_AUCTION_REVEALS_DURATION: ${AUTHORITY_AUCTION_REVEALS_DURATION}
AUTHORITY_GRACE_PERIOD: ${AUTHORITY_GRACE_PERIOD}
GENESIS_FILE: /var/tmp/genesis.json
MONIKER: ${MONIKER:-localtestnet}
volumes:
- laconicd-data:/root/.laconicd
- genesis-config:/var/tmp
- ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
ports:
- "6060"
- "26657"

View File

@ -1,119 +0,0 @@
#!/bin/bash
KEY="alice"
CHAINID="laconic_9000-1"
MONIKER="localtestnet"
KEYRING="test"
LOGLEVEL="${LOGLEVEL:-info}"
input_genesis_file=/var/tmp/genesis.json
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
# validate dependencies are installed
command -v jq > /dev/null 2>&1 || {
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
exit 1
}
# remove existing daemon and client
rm -rf $HOME/.laconicd/*
if [ -n "`which make`" ]; then
make install
fi
laconicd config set client chain-id $CHAINID
laconicd config set client keyring-backend $KEYRING
# if $KEY exists it should be deleted
laconicd keys add $KEY --keyring-backend $KEYRING
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
laconicd init $MONIKER --chain-id $CHAINID --default-denom alnt
if [ -f ${input_genesis_file} ]; then
# Use provided genesis config
cp $input_genesis_file $HOME/.laconicd/config/genesis.json
fi
update_genesis() {
jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json &&
mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
}
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
echo "Setting timers for expiry tests."
update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"'
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"'
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
fi
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
echo "Enabling auction and setting timers."
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"'
update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"'
update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"'
fi
if [[ "$ONBOARDING_ENABLED" == "true" ]]; then
echo "Enabling validator onboarding."
update_genesis '.app_state["onboarding"]["params"]["onboarding_enabled"]=true'
fi
# increase block time (?)
update_genesis '.consensus["params"]["block"]["time_iota_ms"]="1000"'
# Set gas limit in genesis
update_genesis '.consensus["params"]["block"]["max_gas"]="10000000"'
# disable produce empty block
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
else
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
fi
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
sed -i '' 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
else
sed -i 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
sed -i 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
fi
# Run this to allow requests from any origin
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
# Allocate genesis accounts (cosmos formatted addresses)
# 10^30 alnt | 10^12 lnt
laconicd genesis add-genesis-account $KEY 1000000000000000000000000000000alnt --keyring-backend $KEYRING
# Sign genesis transaction
# 10^24 alnt | 10^6 lnt
laconicd genesis gentx $KEY 1000000000000000000000000alnt --keyring-backend $KEYRING --chain-id $CHAINID
# Collect genesis tx
laconicd genesis collect-gentxs
# Run this to ensure everything worked and that the genesis file is setup correctly
laconicd genesis validate
else
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
fi
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
laconicd start \
--pruning=nothing \
--log_level $LOGLEVEL \
--minimum-gas-prices=1alnt \
--api.enable \
--rpc.laddr="tcp://0.0.0.0:26657" \
--gql-server --gql-playground

View File

@ -96,9 +96,26 @@ Instructions for running a laconicd fixturenet along with registry CLI and conso
```bash
# Optional
# Set to true to enable adding participants functionality of the onboarding module
# (default: false)
# Set to true to enable adding participants functionality of the onboarding module (default: false)
ONBOARDING_ENABLED=
# Staking amount to use for the default validator account (default: 1000000000000000)
STAKING_AMOUNT=
# Enable authority auctions (default: false)
AUTHORITY_AUCTION_ENABLED=true
# Authority auctions commits duration (in secs) (default: 24hrs)
AUTHORITY_AUCTION_COMMITS_DURATION=3600
# Authority auctions reveals duration (in secs) (default: 24hrs)
AUTHORITY_AUCTION_REVEALS_DURATION=3600
# Authority grace period (set bond to authority within this) (in secs) (default: 2 * 24hrs)
AUTHORITY_GRACE_PERIOD=7200
# Node moniker (default: "localtestnet")
MONIKER=
```
* Inside the `laconic-console-deployment` deployment directory, open `config.env` file and set following env variables:
@ -179,5 +196,5 @@ laconic-so deployment --dir laconic-console-deployment start
laconic-so deployment --dir fixturenet-laconicd-deployment stop --delete-volumes
# Remove deployment directory (deployment will have to be recreated for a re-run)
rm -r fixturenet-laconicd-deployment
sudo rm -r fixturenet-laconicd-deployment
```

View File

@ -0,0 +1,70 @@
#!/bin/bash
# Exit on error
set -e
set -u
# Check args
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <stage0-deployment-dir-absolute> <participant-allocation> <validator-allocation>"
echo "Example: $0 /home/user/stage0-deployment 1000000 1000000000000"
exit 1
fi
STAGE0_DEPLOYMENT_DIR="$1"
PARTICIPANT_ALLOCATION="$2"
VALIDATOR_ALLOCATION="$3"
STAGE1_GENESIS_DIR=stage1-genesis
# Create a temporary target directory
mkdir -p $STAGE1_GENESIS_DIR
# --------
# Export onboarding module state from stage0 laconicd chain
onboarding_state_file="$STAGE1_GENESIS_DIR/stage0-onboarding-state.json"
docker run -it \
-v ${STAGE0_DEPLOYMENT_DIR}/data/laconicd-data:/root/stage0-deployment/.laconicd \
cerc/laconicd:local bash -c "laconicd export --home /root/stage0-deployment/.laconicd" \
| jq .app_state.onboarding > "$onboarding_state_file"
stage0_participants=$(cat "$onboarding_state_file" | jq .participants)
echo "Exported onboarding module state from stage 0 chain"
# --------
# For each participant, using ETH account holdings, figure out balance allocation for stage1
stage1_allocations_file="$STAGE1_GENESIS_DIR/stage1-allocations.json"
jq -n --argjson participants "$stage0_participants" --arg participant_allocation "$PARTICIPANT_ALLOCATION" --arg validator_allocation "$VALIDATOR_ALLOCATION" '
[
$participants[] |
{
laconic_address: .laconic_address,
balance: (if .role == "validator" then $validator_allocation else $participant_allocation end)
}
]' > $stage1_allocations_file
echo "Calculated allocations for stage 1 chain"
# --------
# Run a script with cerc/laconicd:local to generate the genesis file
# with onboarding module state and given allocations
docker run -it \
-v ./$STAGE1_GENESIS_DIR:/root/.laconicd \
-v ./scripts:/scripts \
cerc/laconicd:local bash -c "/scripts/genesis.sh"
# Copy over the genesis file to output folder
OUTPUT_DIR=output
mkdir -p $OUTPUT_DIR
cp ./$STAGE1_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
echo "Genesis file for stage1 written to $OUTPUT_DIR/genesis.json"
# --------
# Clean up
echo "Please remove the temporary data directory: sudo rm -rf $STAGE1_GENESIS_DIR"

View File

@ -49,7 +49,7 @@ jq -n --argjson holdings "$eth_account_holdings" --argjson participants "$stage0
$participants[] |
select((.nitro_address | ascii_downcase) == ($holding.nitro_address | ascii_downcase)) |
{
cosmos_address: .cosmos_address,
laconic_address: .laconic_address,
balance: $holding.balance
}
]' > $stage1_allocations_file
@ -61,18 +61,18 @@ echo "Calculated allocations for stage 1 chain"
# Run a script with cerc/laconicd:local to generate the genesis file
# with onboarding module state and given allocations
docker run -it \
-v ./stage1-genesis:/root/.laconicd \
-v ./$STAGE1_GENESIS_DIR:/root/.laconicd \
-v ./scripts:/scripts \
cerc/laconicd:local bash -c "/scripts/genesis.sh"
# Copy over the genesis file to output folder
OUTPUT_DIR=output
mkdir -p $OUTPUT_DIR
cp ./stage1-genesis/config/genesis.json $OUTPUT_DIR/genesis.json
cp ./$STAGE1_GENESIS_DIR/config/genesis.json $OUTPUT_DIR/genesis.json
echo "Genesis file for stage1 written to $OUTPUT_DIR/genesis.json"
# --------
# Clean up
echo "Please remove the temporary data directory: sudo rm -rf stage1-genesis"
echo "Please remove the temporary data directory: sudo rm -rf $STAGE1_GENESIS_DIR"

View File

@ -25,11 +25,11 @@ jq '.app_state["bank"]["params"]["default_send_enabled"]=false' "$stage1_genesis
# Read and assign allocations
jq -c '.[]' "$stage1_allocations_file" | while IFS= read -r line; do
cosmos_address=$(jq -r '.cosmos_address' <<< "$line")
laconic_address=$(jq -r '.laconic_address' <<< "$line")
balance=$(jq -r '.balance' <<< "$line")
# Add a genesis account for participant's laconic address with required balance
laconicd genesis add-genesis-account $cosmos_address ${balance}alnt
laconicd genesis add-genesis-account $laconic_address ${balance}alnt
done
# Ensure that resulting genesis file is valid