Skip to content

Commit

Permalink
Merge pull request #402 from ainblockchain/release/0.7.3
Browse files Browse the repository at this point in the history
Release/0.7.3 to master branch
  • Loading branch information
minsulee2 authored May 21, 2021
2 parents e0e14aa + 2bdba4c commit 0449906
Show file tree
Hide file tree
Showing 53 changed files with 2,886 additions and 1,444 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/local/github-actions-for-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This setup is for local run.
name: AIN-blockchain CI/CD

on:
push:
branches:
- 'develop'
- 'release/*'
- 'master'
pull_request:
branches:
- 'develop'
- 'release/*'
- 'master'
jobs:
build_and_test:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
run: sudo npm install -g yarn
- name: install pip
run: |
sudo apt-get install software-properties-common
sudo apt-add-repository universe
sudo apt-get update
sudo apt-get -y install python-pip
pip install ast
- name: yarn install
run: yarn install
# - name: yarn unittest
# run: yarn run test_unit
- name: yarn integration test
run: yarn run test_integration
check_protocol_version:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: test
if: github.event_name == 'push'
run: echo ${{github.event_name}}
- name: get current version
run: echo "VERSION=$(cat package.json | jq -r '.version')" >> $GITHUB_ENV
- name: get min/max versions
run: |
echo "MIN_VERSION=$(cat client/protocol_versions.json | jq -r --arg var "$VERSION" '.[$var].min')" >> $GITHUB_ENV
echo "MAX_VERSION=$(cat client/protocol_versions.json | jq -r --arg var "$VERSION" '.[$var].max')" >> $GITHUB_ENV
- name: send results
env:
SLACK_WEBHOOK_TOKEN: ${{ secrets.SLACK_WEBHOOK_TOKEN }}
run: |
curl -X POST https://hooks.slack.com/services/$SLACK_WEBHOOK_TOKEN \
-H "Content-Type: application/json" \
-d '{"username": "ain-blockchain",
"channel": "blockchain-testnet-deploy",
"text": "New PR has just been merged(${{ github.ref }}, ${{ github.sha }}).\nCurrent version: '"$VERSION"', compatible with min('"$MIN_VERSION"'), max('"$MAX_VERSION"')",
"icon_emoji": ":gem:"}'
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Official Javascript implementation of AI Network Blockchain.

Tracker server is required by new peers who wish to join the AIN network. Each peer is sent the ipaddress of 2 other nodes in the network. These nodes then gossip information through the network of all transactions and blocks.

NOTE: Tracker Server must be started first before starting any blockchain node instances
NOTE: Tracker Server must be started first before starting any blockchain node instances.

### Running without Docker

Expand All @@ -33,7 +33,10 @@ You can override default port numbering system by setting `PORT` and `P2P_PORT`
Set <NUMBER_OF_SHARDS> to 0 if you only want to run a parent chain, or set it to the specific number of shard chains you want to run in addition to the parent chain.
```
gcloud init
sh deploy_blockchain_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS>
# For one-off deploy
sh deploy_blockchain_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS> [--setup]
# For incremental deploy
sh deploy_blockchain_incremental_gcp.sh {dev|staging|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS> [--setup]
```
- Set up Ubuntu machine (if it's on a new VM)
```
Expand Down Expand Up @@ -94,9 +97,9 @@ yarn install
```
- Run blockchain nodes
```
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=0 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=1 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=2 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=0 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_SET_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=1 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_SET_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
MIN_NUM_VALIDATORS=3 ACCOUNT_INDEX=2 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_SET_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
```
You can override default port numbering system by setting `PORT` and `P2P_PORT` environment variables.
Before starting node jobs, remove existing blockchain files and logs if necessary:
Expand All @@ -107,7 +110,7 @@ The default minimum size of the validator whitelist is 3. Change MIN_NUM_VALIDAT
the genesis-configs/base/genesis.json to change this value. You may also need to modify the GENESIS_WHITELIST and GENESIS_VALIDATORS accordingly.
The genesis configs directory used is `genesis-configs/base` by default and it can be altered using `GENESIS_CONFIGS_DIR` env variable. For example, afan shard cluster can use the following command line:
```
GENESIS_CONFIGS_DIR=genesis-configs/afan-shard MIN_NUM_VALIDATORS=1 ACCOUNT_INDEX=0 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
GENESIS_CONFIGS_DIR=genesis-configs/afan-shard MIN_NUM_VALIDATORS=1 ACCOUNT_INDEX=0 DEBUG=false STAKE=250 CONSOLE_LOG=true ENABLE_DEV_SET_CLIENT_API=true ENABLE_GAS_FEE_WORKAROUND=true node client/index.js
```

#### On Google Coud Platform (GCP)
Expand All @@ -116,7 +119,10 @@ GENESIS_CONFIGS_DIR=genesis-configs/afan-shard MIN_NUM_VALIDATORS=1 ACCOUNT_INDE
Set <NUMBER_OF_SHARDS> to 0 if you only want to run a parent chain, or set it to the specific number of shard chains you want to run in addition to the parent chain.
```
gcloud init
sh deploy_blockchain_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS>
# For one-off deploy
sh deploy_blockchain_gcp.sh {dev|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS> [--setup]
# For incremental deploy
sh deploy_blockchain_incremental_gcp.sh {dev|staging|spring|summer} <YOUR_GCP_USER_NAME> <NUMBER_OF_SHARDS> [--setup]
```
- Set up Ubuntu machine (if it's on a new VM)
```
Expand Down
7 changes: 0 additions & 7 deletions blockchain-database.code-workspace

This file was deleted.

6 changes: 3 additions & 3 deletions blockchain/block-file-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class BlockFileUtil {
return this.getBlockFilenameByNumber(block.number);
}

// TODO(csh): Don't use glob?
// TODO(cshcomcom): Don't use glob?
static getAllBlockPaths(chainPath) {
const allBlockFilesPattern = `${chainPath}/${CHAINS_N2B_DIR_NAME}/*.${FILE_NAME_SUFFIX}`;
return glob.sync(allBlockFilesPattern).sort(compare());
Expand Down Expand Up @@ -65,7 +65,7 @@ class BlockFileUtil {
return isBlockEmpty;
}

// TODO(csh): Change to asynchronous
// TODO(cshcomcom): Change to asynchronous.
static readBlock(blockPath) {
const zippedFs = fs.readFileSync(blockPath);
return JSON.parse(zlib.gunzipSync(zippedFs).toString());
Expand All @@ -76,7 +76,7 @@ class BlockFileUtil {
return this.readBlock(blockPath);
}

// TODO(csh): Change to asynchronous
// TODO(cshcomcom): Change to asynchronous.
static writeBlock(chainPath, block) {
const blockPath = this.getBlockPath(chainPath, block.number);
if (!fs.existsSync(blockPath)) {
Expand Down
4 changes: 2 additions & 2 deletions blockchain/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Block {
static buildAccountsSetupTx(timestamp, privateKey, ownerAddress) {
const transferOps = [];
const otherAccounts = GenesisAccounts[AccountProperties.OTHERS];
if (otherAccounts && Array.isArray(otherAccounts) && otherAccounts.length > 0 &&
if (otherAccounts && ChainUtil.isArray(otherAccounts) && otherAccounts.length > 0 &&
GenesisAccounts[AccountProperties.SHARES] > 0) {
for (let i = 0; i < otherAccounts.length; i++) {
const accountAddress = otherAccounts[i][AccountProperties.ADDRESS];
Expand Down Expand Up @@ -291,7 +291,7 @@ class Block {
const firstTx = this.buildDbSetupTx(genesisTime, ownerPrivateKey);
const secondTx = this.buildAccountsSetupTx(genesisTime, ownerPrivateKey, ownerAddress);
const thirdTx = this.buildConsensusAppTx(genesisTime, ownerPrivateKey, ownerAddress);
// TODO(lia): Change the logic to staking & signing by the current node
// TODO(liayoo): Change the logic to staking & signing by the current node.
const stakingTxs = this.buildGenesisStakingTxs(genesisTime);

return [firstTx, secondTx, thirdTx, ...stakingTxs];
Expand Down
6 changes: 3 additions & 3 deletions blockchain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Blockchain {
}
const newChain = this.loadChain();
if (newChain) {
// Note(minsu): Deal with the case the only genesis block was generated.
// NOTE(minsulee2): Deal with the case the only genesis block was generated.
if (newChain.length > 1) {
lastBlockWithoutProposal = newChain.pop();
const lastBlockPath = BlockFileUtil.getBlockPath(
Expand Down Expand Up @@ -163,7 +163,7 @@ class Blockchain {
logger.error(`Genesis block is corrupted`);
return false;
}
// TODO(lia): Check if the tx nonces are correct.
// TODO(liayoo): Check if the tx nonces are correct.
return Blockchain.isValidChainSegment(chain);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ class Blockchain {
if (!Number.isInteger(to) || to < 0) {
to = this.lastBlockNumber() + 1;
}
if (to - from > CHAIN_SEGMENT_LENGTH) { // Note: To prevent large query
if (to - from > CHAIN_SEGMENT_LENGTH) { // NOTE: To prevent large query.
to = from + CHAIN_SEGMENT_LENGTH;
}
const chain = [];
Expand Down
Loading

0 comments on commit 0449906

Please sign in to comment.