Skip to content

Commit

Permalink
fix: add single-node subcommand on the Docker entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Apr 1, 2020
1 parent deed754 commit 210edb6
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/cosmic-swingset/scripts/chain-entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/bash
# chain-entry.sh - decide whether to run ibc test setup or our chain
set -e
DIR=$(dirname -- "${BASH_SOURCE[0]}")
DIR=`cd "$DIR" && pwd`

CMD=$1
case $CMD in
single-node)
# Run the IBC test script.
shift
cd
export DAEMON=ag-chain-cosmos
export CLI=ag-cosmos-helper
export STAKE=10000000000uagstake
exec "$DIR/single-node.sh" ${1+"$@"}
;;
*)
# Just run our chain.
exec "$DIR/../lib/ag-chain-cosmos" ${1+"$@"}
;;
esac
70 changes: 70 additions & 0 deletions packages/cosmic-swingset/scripts/single-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

set -e

DAEMON=${DAEMON-gaiad}
CLI=${CLI-gaiacli}
STAKE=${STAKE-10000000000stake}
coins="${STAKE},100000000000samoleans,100000agmedallion"

CMD=$1
if [ "$CMD" = single-node ]; then
# Yes, we really want to start the single node.
# Just ignore this command and parse arguments
# as usual.
shift
fi

CHAINID=$1
GENACCT=$2

if [ -z "$1" ]; then
echo "Need to input chain id..."
exit 1
fi

if [ -z "$2" ]; then
echo "Need to input genesis account address..."
exit 1
fi

# Build genesis file incl account for passed address
$DAEMON init --chain-id $CHAINID $CHAINID
$CLI keys add validator --keyring-backend="test"
$DAEMON add-genesis-account validator $coins --keyring-backend="test"
$DAEMON add-genesis-account $GENACCT $coins --keyring-backend="test"
$DAEMON gentx --name validator --amount=$STAKE --keyring-backend="test"
$DAEMON collect-gentxs

# Silly old Darwin
case `sed --help 2>&1 | sed -n 2p` in
"usage: sed script"*"[-i extension]"*) sedi () {
sed -i '' ${1+"$@"}
}
;;
*) sedi () {
sed -i ${1+"$@"}
}
;;
esac

case $DAEMON in
ag-chain-cosmos)
# For Agoric
DIR=$(dirname -- "${BASH_SOURCE[0]}")
"$DIR/../../deployment/set-json.js" ~/.$DAEMON/config/genesis.json --agoric-genesis-overrides

export BOOTSTRAP_ADDRESS=$GENACCT
export ROLE=two_chain
;;
esac

# Set proper defaults and change ports
sedi 's/"leveldb"/"goleveldb"/g' ~/.$DAEMON/config/config.toml
sedi 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.$DAEMON/config/config.toml
sedi 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.$DAEMON/config/config.toml
sedi 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.$DAEMON/config/config.toml
sedi 's/index_all_keys = false/index_all_keys = true/g' ~/.$DAEMON/config/config.toml

# Start the chain
$DAEMON start --pruning=nothing
2 changes: 1 addition & 1 deletion packages/deployment/Dockerfile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ RUN ln -s /usr/src/app/lib/ag-chain-cosmos /usr/local/bin/
# By default, run the daemon with specified arguments.
WORKDIR /root
EXPOSE 26657
ENTRYPOINT [ "ag-chain-cosmos" ]
ENTRYPOINT [ "/usr/src/agoric-sdk/packages/cosmic-swingset/scripts/chain-entry.sh" ]

0 comments on commit 210edb6

Please sign in to comment.