Skip to content

Commit

Permalink
Merge pull request #461 from ainblockchain/release/v0.8.0
Browse files Browse the repository at this point in the history
Merge Release/v0.8.0 into master
  • Loading branch information
minsulee2 authored Jun 30, 2021
2 parents 32127d6 + f85a16e commit 6e291e3
Show file tree
Hide file tree
Showing 46 changed files with 1,444 additions and 1,077 deletions.
73 changes: 62 additions & 11 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,29 @@ on:
- 'develop'
- 'release/*'
- 'master'
types: [opened, synchronize, reopened, closed]
jobs:
build_and_test:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Setup node environment for testing
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: '12.16'
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: test
run: echo ${{github.event_name}}
- name: npm install
run: npm install
- name: yarn install
run: yarn install
- name: run unittest
run: npm run test_unit
run: yarn run test_unit
- name: run integration test
if: github.event.pull_request.base.ref == 'master' # integration test only run when master merging
run: npm run test_integration
run: yarn run test_integration
check_protocol_version:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: test
Expand All @@ -52,7 +51,59 @@ jobs:
run: |
curl -X POST https://hooks.slack.com/services/$SLACK_WEBHOOK_TOKEN \
-H "Content-Type: application/json" \
-d '{"username": "ain-blockchain",
-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:"}'
performance_test:
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'develop'
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.PERF_TEST_PIPELINE_GCP_SA_KEY }}
project_id: ${{ secrets.PERF_TEST_PIPELINE_GCP_PROJECT_ID }}
- name: send test start message to gcp
run: |-
gcloud compute ssh "${{ secrets.PERF_TEST_PIPELINE_GCE_INSTANCE }}" --zone "${{ secrets.PERF_TEST_PIPELINE_GCE_INSTANCE_ZONE }}" -- "cd ~/../workspace/testnet-performance-test-pipeline && nohup node start_performance_test.js ${{ github.event.pull_request.head.ref }} >> test_log.txt 2>&1 &" &
sleep 60
check_deployment:
if: github.event.pull_request.base.ref == 'master'
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: setup key
env:
PRIV_KEY_FOR_DOWNLOAD: ${{ secrets.DEPLOYMENT_PRIV_KEY_FOR_DOWNLOAD }}
KNOWN_HOSTS: ${{ secrets.DEPLOYMENT_KNOWN_HOSTS }}
run: |
echo "$PRIV_KEY_FOR_DOWNLOAD" > ./tools/cicd/id_rsa
chmod 600 ./tools/cicd/id_rsa
echo $KNOWN_HOSTS >> ~/.ssh/known_hosts
- name: check apps
env:
ENV_ID: ${{ secrets.DEPLOYMENT_ENV_ID }}
CLIENT_EMAIL: ${{ secrets.DEPLOYMENT_CLIENT_EMAIL }}
PRIVATE_KEY: ${{ secrets.DEPLOYMENT_PRIVATE_KEY}}
GPT2: ${{ secrets.DEPLOYMENT_GPT2 }}
INSIGHT: ${{ secrets.DEPLOYMENT_INSIGHT }}
FAUCET: ${{ secrets.DEPLOYMENT_FAUCET }}
PIPELINE: ${{ secrets.DEPLOYMENT_PIPELINE }}
DATA: ${{ secrets.DEPLOYMENT_DATA }}
run: |
yarn add dotenv google-spreadsheet semver
node tools/cicd/deployment.js
- name: send slack message
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": "APP_VERSION_CHECK",
"channel": "blockchain-testnet-deploy",
"text": "New blockchain version has just been released. Please check compatibility of app versions below:\n ${{ secrets.DEPLOYMENT_SHEET_URL }}",
"icon_emoji": ":bomb:"}'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ The genesis configs directory used is `genesis-configs/base` by default and it c
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)
#### On Google Cloud Platform (GCP)

- Deploy code (in common with Tracker server)
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.
Expand Down
16 changes: 0 additions & 16 deletions bitbucket-pipelines.yml

This file was deleted.

24 changes: 12 additions & 12 deletions blockchain/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const sizeof = require('object-sizeof');
const moment = require('moment');
const _ = require('lodash');
const logger = require('../logger')('BLOCK');
const ChainUtil = require('../common/chain-util');
const CommonUtil = require('../common/common-util');
const Transaction = require('../tx-pool/transaction');
const StateNode = require('../db/state-node');
const DB = require('../db');
Expand All @@ -28,8 +28,8 @@ class Block {
this.transactions = Block.sanitizeTransactions(transactions);
// Block's header
this.last_hash = lastHash;
this.last_votes_hash = ChainUtil.hashString(stringify(lastVotes));
this.transactions_hash = ChainUtil.hashString(stringify(this.transactions));
this.last_votes_hash = CommonUtil.hashString(stringify(lastVotes));
this.transactions_hash = CommonUtil.hashString(stringify(this.transactions));
this.number = number;
this.epoch = epoch;
this.timestamp = timestamp;
Expand Down Expand Up @@ -80,7 +80,7 @@ class Block {

static hash(block) {
if (!(block instanceof Block)) block = Block.parse(block);
return ChainUtil.hashString(stringify(block.header));
return CommonUtil.hashString(stringify(block.header));
}

static getSize(block) {
Expand Down Expand Up @@ -119,12 +119,12 @@ class Block {
logger.error(`[${LOG_HEADER}] Block hash is incorrect for block ${block.hash}`);
return false;
}
if (block.transactions_hash !== ChainUtil.hashString(stringify(block.transactions))) {
if (block.transactions_hash !== CommonUtil.hashString(stringify(block.transactions))) {
logger.error(
`[${LOG_HEADER}] Transactions or transactions_hash is incorrect for block ${block.hash}`);
return false;
}
if (block.last_votes_hash !== ChainUtil.hashString(stringify(block.last_votes))) {
if (block.last_votes_hash !== CommonUtil.hashString(stringify(block.last_votes))) {
logger.error(
`[${LOG_HEADER}] Last votes or last_votes_hash is incorrect for block ${block.hash}`);
return false;
Expand Down Expand Up @@ -209,7 +209,7 @@ class Block {
static buildAccountsSetupTx(timestamp, privateKey, ownerAddress) {
const transferOps = [];
const otherAccounts = GenesisAccounts[AccountProperties.OTHERS];
if (otherAccounts && ChainUtil.isArray(otherAccounts) && otherAccounts.length > 0 &&
if (otherAccounts && CommonUtil.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 @@ -283,9 +283,9 @@ class Block {
}

static getGenesisBlockTxs(genesisTime) {
const ownerAddress = ChainUtil.getJsObject(
const ownerAddress = CommonUtil.getJsObject(
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.ADDRESS]);
const ownerPrivateKey = ChainUtil.getJsObject(
const ownerPrivateKey = CommonUtil.getJsObject(
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.PRIVATE_KEY]);

const firstTx = this.buildDbSetupTx(genesisTime, ownerPrivateKey);
Expand All @@ -304,14 +304,14 @@ class Block {
const resList = [];
for (const tx of genesisTxs) {
const res = tempGenesisDb.executeTransaction(Transaction.toExecutable(tx));
if (ChainUtil.isFailedTx(res)) {
if (CommonUtil.isFailedTx(res)) {
logger.error(`Genesis transaction failed:\n${JSON.stringify(tx, null, 2)}` +
`\nRESULT: ${JSON.stringify(res)}`)
return null;
}
resList.push(res);
}
const { gasAmountTotal, gasCostTotal } = ChainUtil.getServiceGasCostTotalFromTxList(genesisTxs, resList);
const { gasAmountTotal, gasCostTotal } = CommonUtil.getServiceGasCostTotalFromTxList(genesisTxs, resList);
return {
stateProofHash: tempGenesisDb.getStateProof('/')[ProofProperties.PROOF_HASH],
gasAmountTotal,
Expand All @@ -322,7 +322,7 @@ class Block {
static genesis() {
// This is a temporary fix for the genesis block. Code should be modified after
// genesis block broadcasting feature is implemented.
const ownerAddress = ChainUtil.getJsObject(
const ownerAddress = CommonUtil.getJsObject(
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.ADDRESS]);
const genesisTime = GenesisAccounts[AccountProperties.TIMESTAMP];
const lastHash = '';
Expand Down
Loading

0 comments on commit 6e291e3

Please sign in to comment.