Skip to content

Commit

Permalink
Merge pull request #1098 from ainblockchain/release/v1.0.9
Browse files Browse the repository at this point in the history
Release/v1.0.9
  • Loading branch information
minsulee2 authored Aug 30, 2022
2 parents c4d762b + 0d035fa commit ad9c720
Show file tree
Hide file tree
Showing 34 changed files with 854 additions and 150 deletions.
3 changes: 2 additions & 1 deletion blockchain-configs/afan-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 15000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/base/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/he-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 15000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/mainnet-prod/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/sim-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/testnet-dev/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/testnet-exp/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/testnet-prod/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/testnet-sandbox/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
3 changes: 2 additions & 1 deletion blockchain-configs/testnet-staging/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
"ENABLE_REST_FUNCTION_CALL": false,
"ENABLE_STATUS_REPORT_TO_TRACKER": true,
"ENABLE_TX_SIG_VERIF_WORKAROUND": false,
"EVENT_HANDLER_PORT": 6000,
"EVENT_HANDLER_FILTER_DELETION_TIMEOUT_MS": 100000,
"EVENT_HANDLER_HEARTBEAT_INTERVAL_MS": 15000,
"EVENT_HANDLER_PORT": 6000,
"EXPRESS_RATE_LIMIT_WINDOW_SECS": 60,
"FREE_TX_POOL_SIZE_LIMIT_RATIO": 0.1,
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
Expand Down
11 changes: 7 additions & 4 deletions blockchain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Blockchain {
// NOTE(platfowner): This write is not awaited.
FileUtil.writeSnapshotFile(snapshotDir, blockNumber, snapshot, snapshotChunkSize);
// Write the block from the snapshot to the blockchain dir.
this.writeBlock(snapshot[BlockchainSnapshotProperties.BLOCK]);
this.writeBlock(snapshot[BlockchainSnapshotProperties.BLOCK], 'initBlockchain:snapshot');
}
}
const wasBlockDirEmpty = FileUtil.createBlockchainDir(this.blockchainPath);
Expand All @@ -58,7 +58,7 @@ class Blockchain {
logger.info('############################################################');
logger.info('\n');
// Copy the genesis block from the genesis configs dir to the blockchain dir.
this.writeBlock(this.genesisBlock);
this.writeBlock(this.genesisBlock, 'initBlockchain:genesis');
} else {
logger.info('\n');
logger.info('#############################################################');
Expand Down Expand Up @@ -212,7 +212,7 @@ class Blockchain {
this.addBlockToChain(block);
this.updateNumberToBlockInfo(block);
if (writeToDisk) {
this.writeBlock(block);
this.writeBlock(block, 'addBlockToChainAndWriteToDisk');
}
return true;
}
Expand Down Expand Up @@ -243,8 +243,11 @@ class Blockchain {
return true;
}

writeBlock(block) {
writeBlock(block, from = '') {
const LOG_HEADER = 'writeBlock';
if (!block) {
logger.error(`[${LOG_HEADER}] Writing an empty block ${block} from ${from}`);
}

if (FileUtil.hasBlockFile(this.blockchainPath, block)) {
logger.error(
Expand Down
10 changes: 4 additions & 6 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const express = require('express');
const jayson = require('jayson/promise');
const BlockchainNode = require('../node');
const P2pClient = require('../p2p');
const EventHandler = require('../event-handler');
const CommonUtil = require('../common/common-util');
const VersionUtil = require('../common/version-util');
const { sendGetRequest } = require('../common/network-util');
Expand All @@ -33,8 +32,7 @@ app.use(middleware.expressUrlencdedRequestBodySizeLimiter());
app.use(middleware.corsLimiter());
app.use(middleware.blockchainApiRateLimiter);

const eventHandler = NodeConfigs.ENABLE_EVENT_HANDLER === true ? new EventHandler() : null;
const node = new BlockchainNode(null, eventHandler);
const node = new BlockchainNode(null);
// NOTE(platfowner): This is very useful when the server dies without any logs.
process.on('uncaughtException', function(err) {
logger.error(err);
Expand All @@ -54,7 +52,7 @@ const p2pClient = new P2pClient(node, minProtocolVersion, maxProtocolVersion);
const p2pServer = p2pClient.server;

const jsonRpcApis = require('../json_rpc')(
node, p2pServer, eventHandler, minProtocolVersion, maxProtocolVersion);
node, p2pServer, minProtocolVersion, maxProtocolVersion);

app.post(
'/json-rpc',
Expand Down Expand Up @@ -823,10 +821,10 @@ if (NodeConfigs.ENABLE_DEV_CLIENT_SET_API) {
});
}

if (eventHandler) {
if (node.eh) {
// NOTE(cshcomcom): For event handler load balancer! It doesn't mean healthy.
app.get('/eh_load_balancer_health_check', (req, res, next) => {
const result = eventHandler.getEventHandlerHealth();
const result = node.eh.getEventHandlerHealth();
res.status(200)
.set('Content-Type', 'text/plain')
.send(result)
Expand Down
3 changes: 3 additions & 0 deletions client/protocol_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,8 @@
},
"1.0.8": {
"min": "1.0.0"
},
"1.0.9": {
"min": "1.0.0"
}
}
16 changes: 16 additions & 0 deletions common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,13 @@ function isTxInBlock(state) {
return state === TransactionStates.FINALIZED || state === TransactionStates.REVERTED;
}

function isEndState(state) {
return state === TransactionStates.FINALIZED ||
state === TransactionStates.REVERTED ||
state === TransactionStates.FAILED ||
state === TransactionStates.TIMED_OUT;
}

/**
* State versions.
*
Expand Down Expand Up @@ -650,6 +657,8 @@ const TrafficEventTypes = {
const BlockchainEventTypes = {
BLOCK_FINALIZED: 'BLOCK_FINALIZED',
VALUE_CHANGED: 'VALUE_CHANGED',
TX_STATE_CHANGED: 'TX_STATE_CHANGED',
FILTER_DELETED: 'FILTER_DELETED',
};

const BlockchainEventMessageTypes = {
Expand All @@ -664,6 +673,11 @@ const ValueChangedEventSources = {
USER: 'USER',
};

const FilterDeletionReasons = {
FILTER_TIMEOUT: 'FILTER_TIMEOUT',
END_STATE_REACHED: 'END_STATE_REACHED',
}

// ** Lists & Sets **

/**
Expand Down Expand Up @@ -825,13 +839,15 @@ module.exports = {
WriteDbOperations,
TransactionStates,
isTxInBlock,
isEndState,
StateVersions,
getBlockchainConfig,
SyncModeOptions,
TrafficEventTypes,
BlockchainEventTypes,
BlockchainEventMessageTypes,
ValueChangedEventSources,
FilterDeletionReasons,
isServiceType,
isServiceAccountServiceType,
isReservedServiceName,
Expand Down
4 changes: 4 additions & 0 deletions common/result-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ const EventHandlerErrorCode = {
MISSING_FILTER_ID_IN_FILTER_ID_TO_PARSED_PATH: 70250,
MISSING_FILTER_ID_SET: 70251,
MISSING_FILTER_ID_IN_FILTER_ID_SET: 70252,
// TX_STATE_CHANGED (703XX)
MISSING_TX_HASH_IN_CONFIG: 70300,
INVALID_TX_HASH: 70301,
INVALID_TIMEOUT: 70302,
};

/**
Expand Down
38 changes: 23 additions & 15 deletions deploy_blockchain_genesis_gcp.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

if [[ $# -lt 3 ]] || [[ $# -gt 8 ]]; then
printf "Usage: bash deploy_blockchain_genesis_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username> <# of Shards> [--setup] [--keystore|--mnemonic|--private-key] [--keep-code|--no-keep-code] [--keep-data|--no-keep-data] [--full-sync|--fast-sync] [--kill-only|--skip-kill]\n"
printf "Example: bash deploy_blockchain_genesis_gcp.sh dev my_username 0 --setup --keystore --no-keep-code\n"
if [[ $# -lt 3 ]] || [[ $# -gt 9 ]]; then
printf "Usage: bash deploy_blockchain_genesis_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username> <# of Shards> [--setup] [--keystore|--mnemonic|--private-key] [--keep-code|--no-keep-code] [--keep-data|--no-keep-data] [--full-sync|--fast-sync] [--chown-data|--no-chown-data] [--kill-only|--skip-kill]\n"
printf "Example: bash deploy_blockchain_genesis_gcp.sh dev gcp_user 0 --setup --keystore --no-keep-code --no-chown-data\n"
printf "\n"
exit
fi
Expand Down Expand Up @@ -59,6 +59,10 @@ function parse_options() {
SYNC_MODE_OPTION="$option"
elif [[ $option = '--fast-sync' ]]; then
SYNC_MODE_OPTION="$option"
elif [[ $option = '--chown-data' ]]; then
CHOWN_DATA_OPTION="$option"
elif [[ $option = '--no-chown-data' ]]; then
CHOWN_DATA_OPTION="$option"
elif [[ $option = '--kill-only' ]]; then
if [[ "$KILL_OPTION" ]]; then
printf "You cannot use both --skip-kill and --kill-only\n"
Expand All @@ -83,6 +87,7 @@ ACCOUNT_INJECTION_OPTION="--private-key"
KEEP_CODE_OPTION="--keep-code"
KEEP_DATA_OPTION="--keep-data"
SYNC_MODE_OPTION="--fast-sync"
CHOWN_DATA_OPTION="--chown-data"
KILL_OPTION=""

ARG_INDEX=4
Expand All @@ -95,6 +100,7 @@ printf "ACCOUNT_INJECTION_OPTION=$ACCOUNT_INJECTION_OPTION\n"
printf "KEEP_CODE_OPTION=$KEEP_CODE_OPTION\n"
printf "KEEP_DATA_OPTION=$KEEP_DATA_OPTION\n"
printf "SYNC_MODE_OPTION=$SYNC_MODE_OPTION\n"
printf "CHOWN_DATA_OPTION=$CHOWN_DATA_OPTION\n"
printf "KILL_OPTION=$KILL_OPTION\n"

if [[ "$ACCOUNT_INJECTION_OPTION" = "" ]]; then
Expand Down Expand Up @@ -242,14 +248,14 @@ fi
# install node modules on GCP instances
if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
printf "\n* >> Installing node modules for parent tracker (${TRACKER_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh $TRACKER_TARGET_ADDR --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone $TRACKER_ZONE
gcloud compute ssh $TRACKER_TARGET_ADDR --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone $TRACKER_ZONE

for node_index in `seq 0 $(( $NUM_NODES - 1 ))`; do
NODE_TARGET_ADDR=NODE_${node_index}_TARGET_ADDR
NODE_ZONE=NODE_${node_index}_ZONE

printf "\n* >> Installing node modules for parent node $node_index (${!NODE_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh ${!NODE_TARGET_ADDR} --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone ${!NODE_ZONE}
gcloud compute ssh ${!NODE_TARGET_ADDR} --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone ${!NODE_ZONE}
done
fi

Expand Down Expand Up @@ -319,7 +325,7 @@ printf "\n* >> Starting parent tracker (${TRACKER_TARGET_ADDR}) ****************
printf "\n"
printf "KEEP_CODE_OPTION=$KEEP_CODE_OPTION\n"
printf "KEEP_DATA_OPTION=$KEEP_DATA_OPTION\n"
START_TRACKER_CMD="gcloud compute ssh $TRACKER_TARGET_ADDR --command '$START_TRACKER_CMD_BASE $KEEP_CODE_OPTION' --project $PROJECT_ID --zone $TRACKER_ZONE"
START_TRACKER_CMD="gcloud compute ssh $TRACKER_TARGET_ADDR --command '$START_TRACKER_CMD_BASE $GCP_USER $KEEP_CODE_OPTION' --project $PROJECT_ID --zone $TRACKER_ZONE"
printf "START_TRACKER_CMD=$START_TRACKER_CMD\n"
eval $START_TRACKER_CMD

Expand Down Expand Up @@ -350,15 +356,17 @@ for node_index in `seq 0 $(( $NUM_NODES - 1 ))`; do
printf "KEEP_CODE_OPTION=$KEEP_CODE_OPTION\n"
printf "KEEP_DATA_OPTION=$KEEP_DATA_OPTION\n"
printf "SYNC_MODE_OPTION=$SYNC_MODE_OPTION\n"
printf "CHOWN_DATA_OPTION=$CHOWN_DATA_OPTION\n"
printf "JSON_RPC_OPTION=$JSON_RPC_OPTION\n"
printf "UPDATE_FRONT_DB_OPTION=$UPDATE_FRONT_DB_OPTION\n"
printf "REST_FUNC_OPTION=$REST_FUNC_OPTION\n"
printf "EVENT_HANDLER_OPTION=$EVENT_HANDLER_OPTION\n"

printf "\n"
START_NODE_CMD="gcloud compute ssh ${!NODE_TARGET_ADDR} --command '$START_NODE_CMD_BASE $SEASON 0 $node_index $KEEP_CODE_OPTION $KEEP_DATA_OPTION $SYNC_MODE_OPTION $ACCOUNT_INJECTION_OPTION $JSON_RPC_OPTION $UPDATE_FRONT_DB_OPTION $REST_FUNC_OPTION $EVENT_HANDLER_OPTION' --project $PROJECT_ID --zone ${!NODE_ZONE}"
START_NODE_CMD="gcloud compute ssh ${!NODE_TARGET_ADDR} --command '$START_NODE_CMD_BASE $SEASON $GCP_USER 0 $node_index $KEEP_CODE_OPTION $KEEP_DATA_OPTION $SYNC_MODE_OPTION $CHOWN_DATA_OPTION $ACCOUNT_INJECTION_OPTION $JSON_RPC_OPTION $UPDATE_FRONT_DB_OPTION $REST_FUNC_OPTION $EVENT_HANDLER_OPTION' --project $PROJECT_ID --zone ${!NODE_ZONE}"
printf "START_NODE_CMD=$START_NODE_CMD\n"
eval $START_NODE_CMD
sleep 5
inject_account "$node_index"
done

Expand Down Expand Up @@ -411,30 +419,30 @@ if [[ $NUM_SHARDS -gt 0 ]]; then
# install node modules on GCP instances
if [[ $KEEP_CODE_OPTION = "--no-keep-code" ]]; then
printf "\n* >> Installing node modules for shard_$i tracker (${SHARD_TRACKER_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh $SHARD_TRACKER_TARGET_ADDR --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone $TRACKER_ZONE
gcloud compute ssh $SHARD_TRACKER_TARGET_ADDR --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone $TRACKER_ZONE
printf "\n* >> Installing node modules for shard_$i node 0 (${SHARD_NODE_0_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh $SHARD_NODE_0_TARGET_ADDR --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_0_ZONE
gcloud compute ssh $SHARD_NODE_0_TARGET_ADDR --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_0_ZONE
printf "\n* >> Installing node modules for shard_$i node 1 (${SHARD_NODE_1_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh $SHARD_NODE_1_TARGET_ADDR --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_1_ZONE
gcloud compute ssh $SHARD_NODE_1_TARGET_ADDR --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_1_ZONE
printf "\n* >> Installing node modules for shard_$i node 2 (${SHARD_NODE_2_TARGET_ADDR}) *********************************************************\n\n"
gcloud compute ssh $SHARD_NODE_2_TARGET_ADDR --command "cd ./ain-blockchain; sudo yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_2_ZONE
gcloud compute ssh $SHARD_NODE_2_TARGET_ADDR --command "cd ./ain-blockchain; yarn install --ignore-engines" --project $PROJECT_ID --zone $NODE_2_ZONE
fi

# ssh into each instance, install packages and start up the server
printf "\n* >> Starting shard_$i tracker (${SHARD_TRACKER_TARGET_ADDR}) *********************************************************\n\n"
START_TRACKER_CMD="gcloud compute ssh $SHARD_TRACKER_TARGET_ADDR --command '$START_TRACKER_CMD_BASE $KEEP_CODE_OPTION' --project $PROJECT_ID --zone $TRACKER_ZONE"
START_TRACKER_CMD="gcloud compute ssh $SHARD_TRACKER_TARGET_ADDR --command '$START_TRACKER_CMD_BASE $GCP_USER $KEEP_CODE_OPTION' --project $PROJECT_ID --zone $TRACKER_ZONE"
printf "START_TRACKER_CMD=$START_TRACKER_CMD\n"
eval $START_TRACKER_CMD
printf "\n* >> Starting shard_$i node 0 (${SHARD_NODE_0_TARGET_ADDR}) *********************************************************\n\n"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_0_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $SEASON $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION' --project $PROJECT_ID --zone $NODE_0_ZONE"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_0_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $GCP_USER $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION $CHOWN_DATA_OPTION' --project $PROJECT_ID --zone $NODE_0_ZONE"
printf "START_NODE_CMD=$START_NODE_CMD\n"
eval $START_NODE_CMD
printf "\n* >> Starting shard_$i node 1 (${SHARD_NODE_1_TARGET_ADDR}) *********************************************************\n\n"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_1_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $SEASON $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION' --project $PROJECT_ID --zone $NODE_1_ZONE"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_1_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $GCP_USER $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION $CHOWN_DATA_OPTION' --project $PROJECT_ID --zone $NODE_1_ZONE"
printf "START_NODE_CMD=$START_NODE_CMD\n"
eval $START_NODE_CMD
printf "\n* >> Starting shard_$i node 2 (${SHARD_NODE_2_TARGET_ADDR}) *********************************************************\n\n"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_2_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $SEASON $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION' --project $PROJECT_ID --zone $NODE_2_ZONE"
START_NODE_CMD="gcloud compute ssh $SHARD_NODE_2_TARGET_ADDR --command '$START_NODE_CMD_BASE $SEASON $GCP_USER $i 0 $KEEP_CODE_OPTION $KEEP_DATA_OPTION $CHOWN_DATA_OPTION' --project $PROJECT_ID --zone $NODE_2_ZONE"
printf "START_NODE_CMD=$START_NODE_CMD\n"
eval $START_NODE_CMD
done
Expand Down
Loading

0 comments on commit ad9c720

Please sign in to comment.