Skip to content
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

IXO Impact Hub specifics added #92

Draft
wants to merge 1 commit into
base: main
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
51 changes: 51 additions & 0 deletions README-ixo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Add the IXO Impact Hub blockchain

## Requirements
- config.yaml - Edit the standard configuration to the specifications for ixolocal [(see config.yaml.ixo)](e2e-testing/config.yaml.ixo).
- create-genesis.sh - This file overrides the default create-genesis script with [the IXO create version](e2e-testing/scripts/ixo/create-genesis.sh).
- update-genesis.sh - This file overrides the default update-genesis script with [the IXO update version](e2e-testing/scripts/ixo/update-genesis.sh).

## Running locally
1. Download the latest IXO blockchain release, v3.0.0 in this example, and install the image locally.
```
docker pull ghcr.io/ixofoundation/ixo-blockchain:v3.0.0
```
2. Once the IXO Docker image is installed, run the following sequence of commands as part of the initial sequence described in the `dapp-orchestration-basics` README file.

In other words, refer to where the instructions say:
> - Follow the instructions in `agoric-sdk/multichain-testing/README.md` to setup local multi-chain environment needed to run and test dApp.

Navigate to the README file for `agoric-sdk/multichain-testing` and specifically the section that says:
> **Getting Started**

Do not use the `make start` command.
Instead, use the explicit commands in order to inject the IXO blockchain Docker image.

```
# clean up by removing the K8S cluster and all pods
make clean

# set up the cluster
make setup

# load the IXO blockchain image using Kind
kind load docker-image ghcr.io/ixofoundation/ixo-blockchain:v3.0.0 --name agship

# install helm chart and start starship service
make install

# wait for all pods to spin up
make wait-for-pods

# expose ports on your local machine (useful for testing dapps)
make port-forward

# set up Agoric testing environment
make fund-provision-pool override-chain-registry
```

From here, continue as normal and as described in the rest of the instructions.

## Notes
- The IXO blockchain Docker image does not contain the `jq` library therefore you'll notice the copious use of `sed` instead.
- Starship does not define IXO Impact Hub as a known chart and therefore we need to set the recipe name to `custom`.
77 changes: 77 additions & 0 deletions e2e-testing/config.yaml.ixo
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: agoric-multichain-testing
version: 0.2.20

chains:
- id: agoriclocal
name: agoric
image: ghcr.io/agoric/agoric-sdk:dev
numValidators: 1
env:
- name: DEBUG
value: SwingSet:vat,SwingSet:ls
genesis:
app_state:
staking:
params:
unbonding_time: '2m'
swingset:
params:
bootstrap_vat_config: '@agoric/vm-config/decentral-itest-orchestration-config.json'
scripts:
updateConfig:
file: scripts/update-config.sh
faucet:
enabled: false
ports:
rest: 1317
rpc: 26657
exposer: 38087
grpc: 9090
resources:
cpu: 1
memory: 4Gi
- id: ixolocal
name: custom
image: ghcr.io/ixofoundation/ixo-blockchain:v3.0.0
binary: ixod
denom: uixo
home: /ixo/.ixod
prefix: ixo
numValidators: 1
scripts:
createGenesis:
file: scripts/ixo/create-genesis.sh
updateGenesis:
file: scripts/ixo/update-genesis.sh
faucet:
enabled: true
type: cosmjs
concurrency: 5
ports:
rest: 1314
rpc: 26654
grpc: 9092
faucet: 8083
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 500m
memory: 512Mi

relayers:
- name: agoric-ixo
type: hermes
replicas: 1
chains:
- agoriclocal
- ixolocal

explorer:
enabled: false

registry:
enabled: true
ports:
rest: 8081
108 changes: 108 additions & 0 deletions e2e-testing/scripts/ixo/create-genesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

set -eux

echo "START OF CUSTOM CREATE-GENESIS SCRIPT"

DENOM="${DENOM:=uixo}"
COINS="100000000000000uixo"
STAKE_AMOUNT="10000000000000uixo"
CHAIN_ID="${CHAIN_ID:=ixolocal}"
CHAIN_BIN="${CHAIN_BIN:=ixod}"
CHAIN_DIR="/ixo/.ixod"
KEYS_CONFIG="${KEYS_CONFIG:=configs/keys.json}"
FAUCET_ENABLED="${FAUCET_ENABLED:=true}"
NUM_VALIDATORS="${NUM_VALIDATORS:=1}"
NUM_RELAYERS="${NUM_RELAYERS:=0}"

# check if the binary has genesis subcommand or not, if not, set CHAIN_GENESIS_CMD to empty
# v0.47 and above
CHAIN_GENESIS_CMD=$($CHAIN_BIN 2>&1 | grep -q "genesis-related subcommands" && echo "genesis" || echo "")

# initialize the chain
CHAIN_INIT_ID="$CHAIN_ID"
echo "chain init"
sed -n '/"genesis"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | tail -n1 | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN init $CHAIN_ID --chain-id $CHAIN_INIT_ID --recover

# check if the genesis file exists
ls -al $CHAIN_DIR/config

# TODO: add this once the chain id needs to be updated
# sed -i -e "s/$CHAIN_INIT_ID/$CHAIN_ID/g" $CHAIN_DIR/config/genesis.json

# Add genesis keys to the keyring and self delegate initial coins
GENESIS_NAME=$(sed -n '/"genesis"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | head -1 | sed 's/.*"name": *"\([^"]*\)".*/\1/')
echo "Adding key...." $GENESIS_NAME
sed -n '/"genesis"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | head -1 | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $GENESIS_NAME --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $GENESIS_NAME --keyring-backend="test") $COINS --keyring-backend="test"

# Add faucet key to the keyring and self delegate initial coins
FAUCET_NAME=$(sed -n '/"faucet"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | head -1 | sed 's/.*"name": *"\([^"]*\)".*/\1/')
echo "Adding key...." $FAUCET_NAME
sed -n '/"faucet"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | head -1 | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $FAUCET_NAME --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $FAUCET_NAME --keyring-backend="test") $COINS --keyring-backend="test"

# Add test keys to the keyring and self delegate initial coins
TEST_NAME=$(sed -n '/"keys"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | head -1 | sed 's/.*"name": *"\([^"]*\)".*/\1/')
echo "Adding key...." $TEST_NAME
sed -n '/"keys"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | head -1 | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $TEST_NAME --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $TEST_NAME --keyring-backend="test") $COINS --keyring-backend="test"

if [[ $FAUCET_ENABLED == "false" && $NUM_RELAYERS -gt "-1" ]];
then
## Add relayers keys and delegate tokens
for i in $(seq 0 $NUM_RELAYERS);
do
# Add relayer key and delegate tokens
RELAYER_KEY_NAME=$(sed -n '/"relayers"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | sed -n "$((i+1))p" | sed 's/.*"name": *"\([^"]*\)".*/\1/')
echo "Adding relayer key.... $RELAYER_KEY_NAME"
sed -n '/"relayers"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | sed -n "$((i+1))p" | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $RELAYER_KEY_NAME --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $RELAYER_KEY_NAME --keyring-backend="test") $COINS --keyring-backend="test"

# Add relayer-cli key and delegate tokens
RELAYER_CLI_KEY_NAME=$(sed -n '/"relayers_cli"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | sed -n "$((i+1))p" | sed 's/.*"name": *"\([^"]*\)".*/\1/')
echo "Adding relayer-cli key.... $RELAYER_CLI_KEY_NAME"
sed -n '/"relayers_cli"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | sed -n "$((i+1))p" | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $RELAYER_CLI_KEY_NAME --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $RELAYER_CLI_KEY_NAME --keyring-backend="test") $COINS --keyring-backend="test"
done
fi

## if faucet not enabled then add validator and relayer with index as keys and into gentx
if [[ $FAUCET_ENABLED == "false" && $NUM_VALIDATORS -gt "1" ]];
then
## Add validators key and delegate tokens
for i in $(seq 0 $NUM_VALIDATORS);
do
VALIDATOR_NAME=$(sed -n '/"validators"/,/}/p' "$KEYS_CONFIG" | grep '"name"' | head -1 | sed 's/.*"name": *"\([^"]*\)".*/\1/')
VAL_KEY_NAME="$VALIDATOR_NAME-$i"
echo "Adding validator key.... $VAL_KEY_NAME"
sed -n '/"validators"/,/}/p' "$KEYS_CONFIG" | grep '"mnemonic"' | head -1 | sed 's/.*"mnemonic": *"\([^"]*\)".*/\1/' | $CHAIN_BIN keys add $VAL_KEY_NAME --index $i --recover --keyring-backend="test"
$CHAIN_BIN $CHAIN_GENESIS_CMD add-genesis-account $($CHAIN_BIN keys show -a $VAL_KEY_NAME --keyring-backend="test") $COINS --keyring-backend="test"
done
fi

echo "Creating gentx..."
COIN=$(echo $COINS | cut -d ',' -f1)
AMT=$(echo ${COIN//[!0-9]/} | sed -e "s/0000$//")
$CHAIN_BIN $CHAIN_GENESIS_CMD gentx $GENESIS_NAME $STAKE_AMOUNT \
--chain-id=$CHAIN_ID \
--moniker="genesis" \
--commission-max-change-rate=0.01 \
--commission-max-rate=1.0 \
--commission-rate=0.05 \
--min-self-delegation=1 \
--keyring-backend="test"

echo "Validating genesis..."
$CHAIN_BIN validate-genesis

# Show genesis content
echo "Output of gentx"
cat $CHAIN_DIR/config/gentx/*.json

echo "Running collect-gentxs"
$CHAIN_BIN $CHAIN_GENESIS_CMD collect-gentxs

ls $CHAIN_DIR/config

echo "END OF CUSTOM CREATE-GENESIS SCRIPT"
66 changes: 66 additions & 0 deletions e2e-testing/scripts/ixo/update-genesis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

set -eux

echo "START OF CUSTOM UPDATE-GENESIS SCRIPT"

DENOM="${DENOM:=uixo}"
CHAIN_DIR="/ixo/.ixod"

ls $CHAIN_DIR/config

echo "Update genesis.json file with updated local params"
sed -i -e "s/\"stake\"/\"$DENOM\"/g" $CHAIN_DIR/config/genesis.json
sed -i "s/\"time_iota_ms\": \".*\"/\"time_iota_ms\": \"$TIME_IOTA_MS\"/" $CHAIN_DIR/config/genesis.json
# Update initial balances to match staking amount
sed -i 's/"amount": "10"/"amount": "100000000000000"/g' $CHAIN_DIR/config/genesis.json


echo "Update max gas param"
sed -i 's/"max_gas": "[^"]*"/"max_gas": "100000000000"/' $CHAIN_DIR/config/genesis.json

echo "Update staking unbonding time and slashing jail time"
sed -i 's/"unbonding_time": "[^"]*"/"unbonding_time": "300s"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"downtime_jail_duration": "[^"]*"/"downtime_jail_duration": "60s"/' $CHAIN_DIR/config/genesis.json

# overrides for older sdk versions, before 0.47
# IXO chain currently uses v45
function gov_overrides_sdk_v46() {
sed -i 's/"max_deposit_period": "[^"]*"/"max_deposit_period": "30s"/' $CHAIN_DIR/config/genesis.json
# sed -i 's/"amount": "[^"]*"/"amount": "10"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"voting_period": "[^"]*"/"voting_period": "30s"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"quorum": "[^"]*"/"quorum": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"threshold": "[^"]*"/"threshold": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"veto_threshold": "[^"]*"/"veto_threshold": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
}

# overrides for newer sdk versions, post 0.47
function gov_overrides_sdk_v47() {
sed -i 's/"max_deposit_period": "[^"]*"/"max_deposit_period": "30s"/' $CHAIN_DIR/config/genesis.json
# sed -i 's/"amount": "[^"]*"/"amount": "10"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"voting_period": "[^"]*"/"voting_period": "30s"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"quorum": "[^"]*"/"quorum": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"threshold": "[^"]*"/"threshold": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"veto_threshold": "[^"]*"/"veto_threshold": "0.000000000000000000"/' $CHAIN_DIR/config/genesis.json
}

# Check for gov params structure using grep instead of jq
if grep -q '"gov":{"params"' $CHAIN_DIR/config/genesis.json; then
gov_overrides_sdk_v47
else
gov_overrides_sdk_v46
fi

$CHAIN_BIN tendermint show-node-id

# ensure that the client.toml file exists
# this attempt causes the chain to panic
# ixod config keyring-backend test --home /ixo/.ixod
# manually creating it
echo 'chain-id = ""' > /ixo/.ixod/config/client.toml


ls $CHAIN_DIR
ls $CHAIN_DIR/config

echo "END OF CUSTOM UPDATE-GENESIS SCRIPT"