Skip to content

Commit

Permalink
style: a3p+multichain in repo format
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 8, 2024
1 parent ca80dd2 commit da0fa6c
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const body = {
give: {
Price: {
brand: smallCaps.ref(brand.IST),
value: smallCaps.Nat(5n * ISTunit) }
value: smallCaps.Nat(5n * ISTunit),
},
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions multichain-testing/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ chains:
app_state:
staking:
params:
unbonding_time: "2m"
unbonding_time: '2m'
swingset:
params:
bootstrap_vat_config: "@agoric/vm-config/decentral-itest-orchestration-config.json"
bootstrap_vat_config: '@agoric/vm-config/decentral-itest-orchestration-config.json'
scripts:
updateConfig:
file: scripts/update-config.sh
Expand All @@ -34,17 +34,17 @@ chains:
app_state:
staking:
params:
unbonding_time: "2m"
unbonding_time: '2m'
interchain_accounts:
host_genesis_state:
params:
host_enabled: true
allow_messages: ["*"]
allow_messages: ['*']
interchainquery:
host_port: "icqhost"
host_port: 'icqhost'
params:
host_enabled: true
allow_queries: ["*"]
allow_queries: ['*']
faucet:
enabled: true
type: starship
Expand All @@ -63,12 +63,12 @@ chains:
app_state:
staking:
params:
unbonding_time: "2m"
unbonding_time: '2m'
interchain_accounts:
host_genesis_state:
params:
host_enabled: true
allow_messages: ["*"]
allow_messages: ['*']
faucet:
enabled: true
ports:
Expand Down
12 changes: 1 addition & 11 deletions multichain-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
"ava": "^6.1.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"execa": "^9.2.0",
"fs-extra": "^11.2.0",
"patch-package": "^8.0.0",
"prettier": "^3.3.2",
"starshipjs": "2.0.0",
"tsimp": "^2.0.10",
"tsx": "^4.15.6",
Expand All @@ -63,29 +61,21 @@
"serial": true,
"timeout": "125s"
},
"prettier": {
"arrowParens": "avoid",
"semi": true,
"singleQuote": true,
"trailingComma": "all"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier"
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand Down
56 changes: 27 additions & 29 deletions multichain-testing/scripts/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,46 @@ function color() {

# Define a function to install a binary on macOS
install_macos() {
case $1 in
kubectl) brew install kubectl ;;
helm) brew install helm ;;
yq) brew install yq ;;
kind) brew install kind ;;
esac
case $1 in
kubectl) brew install kubectl ;;
helm) brew install helm ;;
yq) brew install yq ;;
kind) brew install kind ;;
esac
}

# Define a function to install a binary on Linux
install_linux() {
color green "Installing $1 at ~/.local/bin, please add it to PATH"
mkdir -p ~/.local/bin
case $1 in
kubectl) curl -Lks "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" > ~/.local/bin/kubectl && chmod +x ~/.local/bin/kubectl ;;
helm) curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash ;;
yq) curl -Lks "https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64" > ~/.local/bin/yq && chmod +x ~/.local/bin/yq ;;
kind) curl -Lks https://kind.sigs.k8s.io/dl/v0.18.1/kind-linux-amd64 > ~/.local/bin/kind && chmod +x ~/.local/bin/kind ;;
esac
color green "Installing $1 at ~/.local/bin, please add it to PATH"
mkdir -p ~/.local/bin
case $1 in
kubectl) curl -Lks "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" > ~/.local/bin/kubectl && chmod +x ~/.local/bin/kubectl ;;
helm) curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash ;;
yq) curl -Lks "https://github.com/mikefarah/yq/releases/download/v4.33.3/yq_linux_amd64" > ~/.local/bin/yq && chmod +x ~/.local/bin/yq ;;
kind) curl -Lks https://kind.sigs.k8s.io/dl/v0.18.1/kind-linux-amd64 > ~/.local/bin/kind && chmod +x ~/.local/bin/kind ;;
esac
}

# Define a function to install a binary
install_binary() {
if [[ $(uname -s) == "Darwin" ]]; then
install_macos $1
else
install_linux $1
fi
if [[ $(uname -s) == "Darwin" ]]; then
install_macos $1
else
install_linux $1
fi
}

# Define a function to check for the presence of a binary
check_binary() {
if ! command -v $1 &> /dev/null
then
echo "$1 is not installed"
install_binary $1
if ! command -v $1 &> /dev/null
then
color red "Installation of $1 failed, exiting..."
color red "Please install $1 manually, then run me again to verify the installation"
exit 1
fi
if ! command -v $1 &> /dev/null; then
echo "$1 is not installed"
install_binary $1
if ! command -v $1 &> /dev/null; then
color red "Installation of $1 failed, exiting..."
color red "Please install $1 manually, then run me again to verify the installation"
exit 1
fi
fi
}

# Check the binaries
Expand Down
24 changes: 13 additions & 11 deletions multichain-testing/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -euo pipefail
# read config file from args into variable
CONFIGFILE="config.yaml"

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
echo "Script dir: ${SCRIPT_DIR}"

# default values
Expand All @@ -29,8 +29,7 @@ HELM_NAME="agoric-multichain-testing"

# check_helm function verifies the helm binary is installed
function check_helm() {
if ! command -v helm &> /dev/null
then
if ! command -v helm &> /dev/null; then
echo "helm could not be found; please install it first!!!"
exit
fi
Expand Down Expand Up @@ -68,7 +67,10 @@ function set_helm_args() {
if [[ "$scripts" == "null" ]]; then
return 0
fi
datadir="$(cd "$(dirname -- "${CONFIGFILE}")" >/dev/null; pwd -P)"
datadir="$(
cd "$(dirname -- "${CONFIGFILE}")" > /dev/null
pwd -P
)"
for script in $(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE}); do
args="$args --set-file chains[$i].scripts.$script.data=$datadir/$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})"
done
Expand All @@ -84,19 +86,19 @@ function install_chart() {

while [ $# -gt 0 ]; do
case "$1" in
-c|--config)
-c | --config)
CONFIGFILE="$2"
shift 2 # past argument=value
;;
-v|--version)
-v | --version)
HELM_CHART_VERSION="$2"
shift 2 # past argument
;;
-t|--timeout)
-t | --timeout)
TIMEOUT="$2"
shift 2 # past argument
;;
-n|--name)
-n | --name)
HELM_NAME="$2"
shift 2 # past argument
;;
Expand All @@ -112,12 +114,12 @@ while [ $# -gt 0 ]; do
DRY_RUN=1
shift # past argument
;;
-*|--*)
-* | --*)
echo "Unknown option $1"
exit 1
;;
*)
;;
*) ;;

esac
done

Expand Down
38 changes: 16 additions & 22 deletions multichain-testing/scripts/port-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ MONITORING_GRAFANA_PORT=8080

for i in "$@"; do
case $i in
-c=*|--config=*)
-c=* | --config=*)
CONFIGFILE="${i#*=}"
shift # past argument=value
;;
-*|--*)
-* | --*)
echo "Unknown option $i"
exit 1
;;
*)
;;
*) ;;

esac
done

Expand All @@ -60,16 +60,15 @@ if [[ $num_chains -gt -1 ]]; then
for i in $(seq 0 $num_chains); do
# derive chain pod name from chain id
# https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56
chain=$(yq -r ".chains[$i].id" ${CONFIGFILE} )
chain=$(yq -r ".chains[$i].id" ${CONFIGFILE})
chain=${chain/_/"-"}
localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE} )
localgrpc=$(yq -r ".chains[$i].ports.grpc" ${CONFIGFILE} )
locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE} )
localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE})
localgrpc=$(yq -r ".chains[$i].ports.grpc" ${CONFIGFILE})
locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE})
localexp=$(yq -r ".chains[$i].ports.exposer" ${CONFIGFILE})
localfaucet=$(yq -r ".chains[$i].ports.faucet" ${CONFIGFILE})
color yellow "chains: forwarded $chain"
if [[ $(yq -r ".chains[$i].cometmock.enabled" $CONFIGFILE) == "true" ]];
then
if [[ $(yq -r ".chains[$i].cometmock.enabled" $CONFIGFILE) == "true" ]]; then
[[ "$localrpc" != "null" ]] && color yellow " cometmock rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-cometmock-0 $localrpc:$CHAIN_COMETMOCK_PORT > /dev/null 2>&1 &
else
[[ "$localrpc" != "null" ]] && color yellow " rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-genesis-0 $localrpc:$CHAIN_RPC_PORT > /dev/null 2>&1 &
Expand All @@ -84,17 +83,16 @@ else
echo "No chains to port-forward: num: $num_chains"
fi


echo "Port forward relayers"
num_relayers=$(yq -r ".relayers | length - 1" ${CONFIGFILE})
if [[ $num_relayers -gt -1 ]]; then
for i in $(seq 0 $num_relayers); do
# derive chain pod name from chain id
# https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56
relayer=$(yq -r ".relayers[$i].name" ${CONFIGFILE} )
relayer=$(yq -r ".relayers[$i].type" ${CONFIGFILE} )-${relayer/_/"-"}
localrest=$(yq -r ".relayers[$i].ports.rest" ${CONFIGFILE} )
localexposer=$(yq -r ".relayers[$i].ports.exposer" ${CONFIGFILE} )
relayer=$(yq -r ".relayers[$i].name" ${CONFIGFILE})
relayer=$(yq -r ".relayers[$i].type" ${CONFIGFILE})-${relayer/_/"-"}
localrest=$(yq -r ".relayers[$i].ports.rest" ${CONFIGFILE})
localexposer=$(yq -r ".relayers[$i].ports.exposer" ${CONFIGFILE})
color yellow "relayers: forwarded $relayer"
[[ "$localrest" != "null" ]] && color yellow " rpc to http://localhost:$localrest" && kubectl port-forward pods/$relayer-0 $localrest:$RELAYER_REST_PORT > /dev/null 2>&1 &
[[ "$localexposer" != "null" ]] && color yellow " rpc to http://localhost:$localexposer" && kubectl port-forward pods/$relayer-0 $localexposer:$RELAYER_EXPOSER_PORT > /dev/null 2>&1 &
Expand All @@ -104,26 +102,22 @@ else
echo "No relayer to port-forward: num: $num_relayers"
fi


echo "Port forward services"

if [[ $(yq -r ".registry.enabled" $CONFIGFILE) == "true" ]];
then
if [[ $(yq -r ".registry.enabled" $CONFIGFILE) == "true" ]]; then
kubectl port-forward service/registry 8081:$REGISTRY_LCD_PORT > /dev/null 2>&1 &
kubectl port-forward service/registry 9091:$REGISTRY_GRPC_PORT > /dev/null 2>&1 &
sleep 1
color yellow "registry: forwarded registry lcd to grpc http://localhost:8081, to http://localhost:9091"
fi

if [[ $(yq -r ".explorer.enabled" $CONFIGFILE) == "true" ]];
then
if [[ $(yq -r ".explorer.enabled" $CONFIGFILE) == "true" ]]; then
kubectl port-forward service/explorer 8080:$EXPLORER_LCD_PORT > /dev/null 2>&1 &
sleep 1
color green "Open the explorer to get started.... http://localhost:8080"
fi

if [[ $(yq -r ".monitoring.enabled" $CONFIGFILE) == "true" ]];
then
if [[ $(yq -r ".monitoring.enabled" $CONFIGFILE) == "true" ]]; then
color yellow "monitoring port forward:"
localgrafana=$(yq -r ".monitoring.ports.grafana" ${CONFIGFILE})
localprometheus=$(yq -r ".monitoring.ports.prometheus" ${CONFIGFILE})
Expand Down
4 changes: 1 addition & 3 deletions multichain-testing/scripts/update-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ set -eux

ls $CHAIN_DIR


echo "Update config.toml file"
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $CHAIN_DIR/config/config.toml
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/config/config.toml
sed -i -e 's/seeds = ".*"/seeds = ""/g' $CHAIN_DIR/config/config.toml
sed -i -e 's#cors_allowed_origins = \[\]#cors_allowed_origins = \["*"\]#g' $CHAIN_DIR/config/config.toml

echo "Increase `*_bytes` parameters for MsgInstallBundle"
echo "Increase $(*_bytes) parameters for MsgInstallBundle"
# See https://github.com/Agoric/agoric-sdk/blob/7b684a6268c999b082a326fdb22f63e4575bac4f/packages/agoric-cli/src/chain-config.js#L66
RPC_MAX_BODY_BYTES=15000000
MAX_HEADER_BYTES=$((RPC_MAX_BODY_BYTES / 10))
Expand All @@ -41,7 +40,6 @@ sed -i -e 's#swagger = false#swagger = true#g' $CHAIN_DIR/config/app.toml
sed -i -e 's/enable-unsafe-cors = false/enable-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml
sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml


function get_next_line_number() {
local txt=$1
local file=$2
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"lerna": "lerna",
"link-cli": "yarn run create-agoric-cli",
"create-agoric-cli": "node ./scripts/create-agoric-cli.cjs",
"format": "yarn prettier --write .github golang packages scripts",
"lint:format": "yarn prettier --check .github golang packages scripts",
"format": "yarn prettier --write .github golang packages scripts a3p-integration multichain-testing",
"lint:format": "yarn prettier --check .github golang packages scripts a3p-integration multichain-testing",
"lint-fix": "yarn lerna run --no-bail lint-fix",
"lint": "run-s --continue-on-error lint:*",
"lint:packages": "yarn lerna run --no-bail lint",
Expand Down

0 comments on commit da0fa6c

Please sign in to comment.