Skip to content

Commit

Permalink
Use latest cheqd node
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Dec 3, 2024
1 parent 1125140 commit f864b39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cheqd-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
runs-on: ubuntu-latest
env:
CHEQD_MNEMONIC: "steak come surprise obvious remain black trouble measure design volume retreat float coach amused match album moment radio stuff crack orphan ranch dose endorse"
IMAGE_TAG: 3.0.2
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
27 changes: 20 additions & 7 deletions scripts/cheqd_entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ CHAIN_ID="cheqd-dev"
NODE_NAME="cheqd-dev"
KEY_NAME="my-key"
MONIKER="local-node"
STAKE_DENOM="stake"
CHAIN_DIR="$HOME/.testnode"
GENESIS_AMOUNT="100000000000000000000000000000ncheq,8246428745600000$STAKE_DENOM" # Very large amount
STAKE_AMOUNT="8246428745600000$STAKE_DENOM" # Ensure this is >= DefaultPowerReduction
GENESIS_AMOUNT="100000000000000000000000000000ncheq" # Very large amount
STAKE_AMOUNT="8246428745600000ncheq" # Ensure this is >= DefaultPowerReduction
COMMAND="cheqd-noded"

# Install Cosmos SDK if not installed (replace this with your specific chain's SDK)
Expand All @@ -22,7 +21,17 @@ rm -rf $CHAIN_DIR

# Step 1: Initialize the chain
echo "Initializing chain..."
$COMMAND init $NODE_NAME --chain-id $CHAIN_ID --home $CHAIN_DIR
$COMMAND init $NODE_NAME --chain-id $CHAIN_ID --home $CHAIN_DIR --default-denom ncheq

# Step 1.a: Replace the default "stake" with "ncheq" in the genesis file
echo "Replacing default 'stake' with 'ncheq' in genesis file..."
sed -i 's/"stake"/"ncheq"/' $CHAIN_DIR/config/genesis.json

# Step 1.b: Configure feemarket
echo "Configuring feemarket..."
sed -i 's/"fee_denom": "stake"/"fee_denom": "ncheq"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"min_base_gas_price": "1.000000000000000000"/"min_base_gas_price": "0.005000000000000000"/' $CHAIN_DIR/config/genesis.json
sed -i 's/"base_gas_price": "1.000000000000000000"/"base_gas_price": "0.005000000000000000"/' $CHAIN_DIR/config/genesis.json

# Step 2: Generate a keypair (if it doesn't exist already)
if [ -z "$CHEQD_MNEMONIC" ]; then
Expand All @@ -35,7 +44,7 @@ fi

# Step 3: Add the generated key as a genesis account
echo "Adding genesis account..."
$COMMAND genesis add-genesis-account $($COMMAND keys show $KEY_NAME -a --keyring-backend test --home $CHAIN_DIR) $GENESIS_AMOUNT --home $CHAIN_DIR
$COMMAND genesis add-genesis-account $($COMMAND keys show $KEY_NAME -a --keyring-backend test --home $CHAIN_DIR) $GENESIS_AMOUNT --keyring-backend test --home $CHAIN_DIR

# Step 4: Generate a genesis transaction
echo "Generating genesis transaction..."
Expand All @@ -49,9 +58,13 @@ $COMMAND genesis collect-gentxs --home $CHAIN_DIR
echo "Validating genesis file..."
$COMMAND genesis validate-genesis --home $CHAIN_DIR

# Step 6.a: Cat genesis file
echo "Modified genesis file..."
cat $CHAIN_DIR/config/genesis.json

# Step 7: Copy custom configuration
cp /tmp/cheqd_config.toml $CHAIN_DIR/config/config.toml

# Step 8: Starting the node
echo "Starting Cosmos node..."
$COMMAND start --home $CHAIN_DIR --moniker $MONIKER --log_level info
echo "Starting cheqd node..."
$COMMAND start --home $CHAIN_DIR --moniker $MONIKER --log_level info
16 changes: 11 additions & 5 deletions scripts/with_cheqd_docker_test_node
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ entrypoint="$(realpath $(dirname $0)/cheqd_entrypoint)"
config="$(realpath $(dirname $0)/cheqd_config.toml)"

# pre-pull
docker pull --platform linux/amd64 ghcr.io/cheqd/cheqd-node:2.0.2
docker pull --platform linux/amd64 ghcr.io/cheqd/cheqd-node:$IMAGE_TAG

# start a pos alice node
alice_container_id=$(docker run --platform linux/amd64 -d --rm --name cheqd-dev -p 26656:26656 -p 26657:26657 -p 1317:1317 -p 9090:9090 -e CHEQD_MNEMONIC="$CHEQD_MNEMONIC" -v $entrypoint:/usr/local/bin/entrypoint.sh -v $config:/tmp/cheqd_config.toml --entrypoint /usr/local/bin/entrypoint.sh ghcr.io/cheqd/cheqd-node:2.0.2 start)
alice_container_id=$(docker run --platform linux/amd64 -d --rm --name cheqd-dev -p 26656:26656 -p 26657:26657 -p 1317:1317 -p 9090:9090 -e CHEQD_MNEMONIC="$CHEQD_MNEMONIC" -v $entrypoint:/usr/local/bin/entrypoint.sh -v $config:/tmp/cheqd_config.toml --entrypoint /usr/local/bin/entrypoint.sh ghcr.io/cheqd/cheqd-node:$IMAGE_TAG start)

# locate the node's home directory
alice_home=$(docker exec $alice_container_id sh -c 'echo $HOME')

# tail logs, if necessary
# docker logs -f $alice_container_id

cleanup() {
docker kill $alice_container_id 2> /dev/null
}

try_with_node() {
sleep 10;
# Execute the commands, potentially against the nodes
$@
# Execute the commands, potentially against the nodes
$@
}

trap cleanup EXIT SIGINT SIGTERM
Expand All @@ -29,4 +35,4 @@ else
exit_code=$?
fi

exit $exit_code
exit $exit_code

0 comments on commit f864b39

Please sign in to comment.