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

Release/v1.5.1 #1343

Merged
merged 18 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions client/protocol_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,8 @@
},
"1.5.0": {
"min": "1.0.0"
},
"1.5.1": {
"min": "1.0.0"
}
}
51 changes: 31 additions & 20 deletions config_client_api_ip_whitelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,54 @@

function usage() {
printf "\n"
printf "Usage: bash config_client_api_ip_whitelist.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [get|add|remove] [<IP Address>]\n"
printf "Example: bash config_client_api_ip_whitelist.sh dev get\n"
printf "Example: bash config_client_api_ip_whitelist.sh dev add 32.190.239.181\n"
printf "Example: bash config_client_api_ip_whitelist.sh dev add '*'\n"
printf "Example: bash config_client_api_ip_whitelist.sh dev remove 32.190.239.181\n"
printf "Usage: bash config_client_api_ip_whitelist.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem] [get|add|remove] [<IP Address>]\n"
printf "Example: bash config_client_api_ip_whitelist.sh staging onprem get\n"
printf "Example: bash config_client_api_ip_whitelist.sh staging onprem add 32.190.239.181\n"
printf "Example: bash config_client_api_ip_whitelist.sh staging onprem add '*'\n"
printf "Example: bash config_client_api_ip_whitelist.sh staging onprem remove 32.190.239.181\n"
printf "\n"
exit
}

if [[ $# -lt 2 ]] || [[ $# -gt 3 ]]; then
if [[ $# -lt 3 ]] || [[ $# -gt 4 ]]; then
usage
fi
printf "\n[[[[[ config_client_api_ip_whitelist.sh ]]]]]\n\n"

if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[ "$1" = 'exp' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'summer' ]] || [[ "$1" = 'mainnet' ]]; then
SEASON="$1"
else
printf "Invalid <Project/Season> argument: $1\n"
printf "\nInvalid <Season> argument: $1\n"
usage
fi
printf "SEASON=$SEASON\n"

if [[ "$2" = 'get' ]]; then
COMMAND="$2"
IP_ADDR="$3"
if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then
BLOCKCHAIN_HOSTING="$2"
else
printf "\nInvalid <Blockchain Hosting> argument: $2\n"
usage
fi
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"

COMMAND="$3"
IP_ADDR=""
if [[ $# = 4 ]]; then
IP_ADDR="$4"
fi

if [[ "$COMMAND" = 'get' ]]; then
if [[ ! "$IP_ADDR" = "" ]]; then
printf "\nInvalid argument: $IP_ADDR\n"
printf "\nInvalid <IP Address> argument: $IP_ADDR\n"
usage
fi
elif [[ "$2" = 'add' ]] || [[ "$2" = 'remove' ]]; then
COMMAND="$2"
IP_ADDR="$3"
elif [[ "$COMMAND" = 'add' ]] || [[ "$COMMAND" = 'remove' ]]; then
if [[ "$IP_ADDR" = "" ]]; then
printf "\nInvalid <IP Address> argument: $IP_ADDR\n"
usage
fi
else
printf "Invalid <Command> argument: $2\n"
printf "\nInvalid <Command> argument: $COMMAND\n"
usage
fi
printf "COMMAND=$COMMAND\n"
Expand All @@ -65,7 +75,7 @@ else
fi

# Read node urls
IFS=$'\n' read -d '' -r -a NODE_URL_LIST < ./ip_addresses/$SEASON.txt
IFS=$'\n' read -d '' -r -a NODE_URL_LIST < ./ip_addresses/${SEASON}_${BLOCKCHAIN_HOSTING}.txt

# Get keystore password
printf "Enter keystore password: "
Expand Down Expand Up @@ -101,16 +111,17 @@ function config_node() {
printf "\n\n<<< Configuring ip whitelist of node $node_index ($node_url) >>>\n\n"

KEYSTORE_FILE_PATH="$KEYSTORE_DIR/keystore_node_$node_index.json"
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID keystore $KEYSTORE_FILE_PATH"
if [[ ! $COMMAND = "get" ]]; then
CONFIG_NODE_CMD="$CONFIG_NODE_CMD '$IP_ADDR'"
if [[ $COMMAND = "get" ]]; then
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID keystore $KEYSTORE_FILE_PATH"
else
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID $IP_ADDR keystore $KEYSTORE_FILE_PATH"
fi

printf "\n"
printf "CONFIG_NODE_CMD=$CONFIG_NODE_CMD\n\n"
eval "echo $KEYSTORE_PW | $CONFIG_NODE_CMD"
}

for j in `seq $(( 0 )) $(( 9 ))`; do
for j in `seq $(( 0 )) $(( 4 ))`; do
config_node "$j"
done
60 changes: 35 additions & 25 deletions config_node_param.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,51 @@

function usage() {
printf "\n"
printf "Usage: bash config_node_param.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [get|add|remove] <Param> [<Value>]\n"
printf "Example: bash config_node_param.sh dev get DEV_CLIENT_API_IP_WHITELIST\n"
printf "Example: bash config_node_param.sh dev add DEV_CLIENT_API_IP_WHITELIST 32.190.239.181\n"
printf "Example: bash config_node_param.sh dev add DEV_CLIENT_API_IP_WHITELIST '*'\n"
printf "Example: bash config_node_param.sh dev remove DEV_CLIENT_API_IP_WHITELIST 32.190.239.181\n"
printf "Example: bash config_node_param.sh dev set DEV_CLIENT_API_IP_WHITELIST '*'\n"
printf "Example: bash config_node_param.sh dev get CORS_WHITELIST\n"
printf "Usage: bash config_node_param.sh [dev|staging|sandbox|exp|spring|summer|mainnet] [gcp|onprem] [get|add|remove] <Param> [<Value>]\n"
printf "Example: bash config_node_param.sh staging onprem get DEV_CLIENT_API_IP_WHITELIST\n"
printf "Example: bash config_node_param.sh staging onprem add DEV_CLIENT_API_IP_WHITELIST 32.190.239.181\n"
printf "Example: bash config_node_param.sh staging onprem add DEV_CLIENT_API_IP_WHITELIST '*'\n"
printf "Example: bash config_node_param.sh staging onprem remove DEV_CLIENT_API_IP_WHITELIST 32.190.239.181\n"
printf "Example: bash config_node_param.sh staging onprem set DEV_CLIENT_API_IP_WHITELIST '*'\n"
printf "Example: bash config_node_param.sh staging onprem get CORS_WHITELIST\n"
printf "\n"
exit
}

if [[ $# -lt 3 ]] || [[ $# -gt 4 ]]; then
if [[ $# -lt 4 ]] || [[ $# -gt 5 ]]; then
usage
fi
printf "\n[[[[[ config_node_param.sh ]]]]]\n\n"

if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[ "$1" = 'exp' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'summer' ]] || [[ "$1" = 'mainnet' ]]; then
SEASON="$1"
else
printf "Invalid <Project/Season> argument: $1\n"
printf "\nInvalid <Season> argument: $1\n"
usage
fi
printf "SEASON=$SEASON\n"

if [[ "$2" = 'get' ]]; then
COMMAND="$2"
PARAM="$3"
VALUE="$4"
if [[ "$2" = 'gcp' ]] || [[ "$2" = 'onprem' ]]; then
BLOCKCHAIN_HOSTING="$2"
else
printf "\nInvalid <Blockchain Hosting> argument: $2\n"
usage
fi
printf "BLOCKCHAIN_HOSTING=$BLOCKCHAIN_HOSTING\n"

COMMAND="$3"
PARAM="$4"
VALUE=""
if [[ $# = 5 ]]; then
VALUE="$5"
fi

if [[ "$COMMAND" = 'get' ]]; then
if [[ ! "$VALUE" = "" ]]; then
printf "\nInvalid argument: $VALUE\n"
printf "\nInvalid <Value> argument: $VALUE\n"
usage
fi
elif [[ "$2" = 'add' ]] || [[ "$2" = 'remove' ]] || [[ "$2" = 'set' ]]; then
COMMAND="$2"
PARAM="$3"
VALUE="$4"
elif [[ "$COMMAND" = 'add' ]] || [[ "$COMMAND" = 'remove' ]] || [[ "$COMMAND" = 'set' ]]; then
if [[ "$PARAM" = "" ]]; then
printf "\nInvalid <Param> argument: $PARAM\n"
usage
Expand All @@ -47,7 +56,7 @@ elif [[ "$2" = 'add' ]] || [[ "$2" = 'remove' ]] || [[ "$2" = 'set' ]]; then
usage
fi
else
printf "Invalid <Command> argument: $2\n"
printf "\nInvalid <Command> argument: $COMMAND\n"
usage
fi
printf "COMMAND=$COMMAND\n"
Expand All @@ -74,7 +83,7 @@ else
fi

# Read node urls
IFS=$'\n' read -d '' -r -a NODE_URL_LIST < ./ip_addresses/$SEASON.txt
IFS=$'\n' read -d '' -r -a NODE_URL_LIST < ./ip_addresses/${SEASON}_${BLOCKCHAIN_HOSTING}.txt

# Get keystore password
printf "Enter keystore password: "
Expand Down Expand Up @@ -109,19 +118,20 @@ function config_node() {
local node_index="$1"
local node_url=${NODE_URL_LIST[${node_index}]}

printf "\n\n<<< Configuring ip whitelist of node $node_index ($node_url) >>>\n\n"
printf "\n\n<<< Configuring node params of node $node_index ($node_url) >>>\n\n"

KEYSTORE_FILE_PATH="$KEYSTORE_DIR/keystore_node_$node_index.json"
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID keystore $KEYSTORE_FILE_PATH $PARAM"
if [[ ! $COMMAND = "get" ]]; then
CONFIG_NODE_CMD="$CONFIG_NODE_CMD '$VALUE'"
if [[ $COMMAND = "get" ]]; then
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID $PARAM $VALUE keystore $KEYSTORE_FILE_PATH"
else
CONFIG_NODE_CMD="node tools/api-access/$COMMAND_NODE_JS_FILE $node_url $CHAIN_ID $PARAM $VALUE keystore $KEYSTORE_FILE_PATH"
fi

printf "\n"
printf "CONFIG_NODE_CMD=$CONFIG_NODE_CMD\n\n"
eval "echo $KEYSTORE_PW | $CONFIG_NODE_CMD"
}

for j in `seq $(( 0 )) $(( 9 ))`; do
for j in `seq $(( 0 )) $(( 4 ))`; do
config_node "$j"
done
38 changes: 33 additions & 5 deletions copy_blockchain_data_gcp.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

function usage() {
printf "Usage: bash copy_blockchain_data_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <Node Index> [download|upload]\n"
printf "Usage: bash copy_blockchain_data_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <Node Index> [download|upload] [<Old Port Number> <New Port Number>]\n"
printf "Example: bash copy_blockchain_data_gcp.sh spring 0 download\n"
printf "Example: bash copy_blockchain_data_gcp.sh spring 1 upload\n"
printf "Example: bash copy_blockchain_data_gcp.sh spring 1 upload 8079 8080\n"
printf "\n"
exit
}

if [[ $# -lt 3 ]] || [[ $# -gt 3 ]]; then
if [[ $# != 3 ]] && [[ $# != 5 ]]; then
usage
fi

Expand All @@ -22,7 +22,7 @@ if [[ "$1" = 'dev' ]] || [[ "$1" = 'staging' ]] || [[ "$1" = 'sandbox' ]] || [[
PROJECT_ID="testnet-$1-ground"
fi
else
printf "Invalid <Project/Season> argument: $1\n"
printf "Invalid <Season> argument: $1\n"
exit
fi
printf "\n"
Expand Down Expand Up @@ -56,6 +56,28 @@ else
fi
printf "COMMAND=$COMMAND\n"

if [[ "$COMMAND" = 'download' ]]; then
if [[ $# != 3 ]]; then
printf "\n"
printf "<Old Port Number> and <New Port Number> can be used only with 'upload' command.\n"
printf "\n"
usage
fi
OLD_PORT=""
NEW_PORT=""
else
if [[ $# != 5 ]]; then
printf "\n"
printf "<Old Port Number> and <New Port Number> should be specified with 'upload' command.\n"
printf "\n"
usage
fi
OLD_PORT="$4"
NEW_PORT="$5"
fi
printf "OLD_PORT=$OLD_PORT\n"
printf "NEW_PORT=$NEW_PORT\n"

# Get confirmation.
if [[ "$SEASON" = "mainnet" ]]; then
printf "\n"
Expand Down Expand Up @@ -151,7 +173,13 @@ function upload_data() {
printf "TGZ_CMD=$TGZ_CMD\n\n"
eval $TGZ_CMD

# 3. Clean up tgz file for node
# 3. Change port number directory
printf "\n\n<<< Changing port number directory for node $node_index >>>\n\n"
MV_CMD="gcloud compute ssh $node_target_addr --command 'mv /home/ain_blockchain_data/chains/${OLD_PORT} /home/ain_blockchain_data/chains/${NEW_PORT}; mv /home/ain_blockchain_data/snapshots/${OLD_PORT} /home/ain_blockchain_data/snapshots/${NEW_PORT}' --project $PROJECT_ID --zone $node_zone"
printf "MV_CMD=$MV_CMD\n\n"
eval $MV_CMD

# 4. Clean up tgz file for node
printf "\n\n<<< Cleaning up tgz file for node $node_index >>>\n\n"
CLEANUP_CMD="gcloud compute ssh $node_target_addr --command 'rm ~/ain_blockchain_data.tar.gz' --project $PROJECT_ID --zone $node_zone"
printf "CLEANUP_CMD=$CLEANUP_CMD\n\n"
Expand Down
38 changes: 33 additions & 5 deletions copy_blockchain_data_onprem.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash

function usage() {
printf "Usage: bash copy_blockchain_data_onprem.sh [staging|spring|mainnet] <Node Index> [download|upload]\n"
printf "Usage: bash copy_blockchain_data_onprem.sh [staging|spring|mainnet] <Node Index> [download|upload] [<Old Port Number> <New Port Number>]\n"
printf "Example: bash copy_blockchain_data_onprem.sh staging 0 download\n"
printf "Example: bash copy_blockchain_data_onprem.sh staging 1 upload\n"
printf "Example: bash copy_blockchain_data_onprem.sh staging 1 upload 8080 8079\n"
printf "\n"
exit
}

if [[ $# -lt 3 ]] || [[ $# -gt 3 ]]; then
if [[ $# != 3 ]] && [[ $# != 5 ]]; then
usage
fi

if [[ "$1" = 'staging' ]] || [[ "$1" = 'spring' ]] || [[ "$1" = 'mainnet' ]]; then
SEASON="$1"
else
printf "Invalid <Project/Season> argument: $1\n"
printf "Invalid <Season> argument: $1\n"
exit
fi
printf "\n"
Expand Down Expand Up @@ -48,6 +48,28 @@ else
fi
printf "COMMAND=$COMMAND\n"

if [[ "$COMMAND" = 'download' ]]; then
if [[ $# != 3 ]]; then
printf "\n"
printf "<Old Port Number> and <New Port Number> can be used only with 'upload' command.\n"
printf "\n"
usage
fi
OLD_PORT=""
NEW_PORT=""
else
if [[ $# != 5 ]]; then
printf "\n"
printf "<Old Port Number> and <New Port Number> should be specified with 'upload' command.\n"
printf "\n"
usage
fi
OLD_PORT="$4"
NEW_PORT="$5"
fi
printf "OLD_PORT=$OLD_PORT\n"
printf "NEW_PORT=$NEW_PORT\n"

# Get confirmation.
if [[ "$SEASON" = "mainnet" ]]; then
printf "\n"
Expand Down Expand Up @@ -120,7 +142,13 @@ function upload_data() {
printf "TGZ_CMD=$TGZ_CMD\n\n"
eval "echo ${node_login_pw} | sshpass -f <(printf '%s\n' ${node_login_pw}) ${TGZ_CMD}"

# 3. Clean up tgz file for node
# 3. Change port number directory
printf "\n\n<<< Changing port number directory for node $node_index >>>\n\n"
MV_CMD="ssh $node_target_addr 'mv /home/${SEASON}/ain_blockchain_data/chains/${OLD_PORT} /home/${SEASON}/ain_blockchain_data/chains/${NEW_PORT}; mv /home/${SEASON}/ain_blockchain_data/snapshots/${OLD_PORT} /home/${SEASON}/ain_blockchain_data/snapshots/${NEW_PORT}'"
printf "MV_CMD=$MV_CMD\n\n"
eval "sshpass -f <(printf '%s\n' ${node_login_pw}) ${MV_CMD}"

# 4. Clean up tgz file for node
printf "\n\n<<< Cleaning up tgz file for node $node_index >>>\n\n"
CLEANUP_CMD="ssh $node_target_addr 'rm ~/ain_blockchain_data.tar.gz'"
printf "CLEANUP_CMD=$CLEANUP_CMD\n\n"
Expand Down
6 changes: 4 additions & 2 deletions db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,8 @@ class DB {
return {
code: TxResultCode.GAS_EXCEED_STATE_BUDGET_LIMIT_FOR_FREE_TIER,
message: `Exceeded state budget limit for free tier ` +
`(${stateFreeTierUsage[StateLabelProperties.TREE_BYTES]} > ${budgets.freeStateBudget})`
`(${stateFreeTierUsage[StateLabelProperties.TREE_BYTES]} > ${budgets.freeStateBudget}).\n` +
`For more information see https://docs.ainetwork.ai/ain-blockchain/staking`
};
}
// else, we allow apps without stakes
Expand All @@ -1688,7 +1689,8 @@ class DB {
return {
code: TxResultCode.GAS_EXCEED_STATE_BUDGET_LIMIT_FOR_APP,
message: `Exceeded state budget limit for app ${appName} ` +
`(${appStateUsage[StateLabelProperties.TREE_BYTES]} > ${singleAppStateBudget})`
`(${appStateUsage[StateLabelProperties.TREE_BYTES]} > ${singleAppStateBudget}).\n` +
`For more information see https://docs.ainetwork.ai/ain-blockchain/staking`
};
}
}
Expand Down
Loading
Loading