Skip to content

Commit 6e291e3

Browse files
authored
Merge pull request #461 from ainblockchain/release/v0.8.0
Merge Release/v0.8.0 into master
2 parents 32127d6 + f85a16e commit 6e291e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1444
-1077
lines changed

.github/workflows/github-actions.yml

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,29 @@ on:
1111
- 'develop'
1212
- 'release/*'
1313
- 'master'
14+
types: [opened, synchronize, reopened, closed]
1415
jobs:
1516
build_and_test:
1617
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
17-
runs-on: ubuntu-latest
18+
runs-on: macos-latest
1819
steps:
1920
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2021
- uses: actions/checkout@v2
2122
# Setup node environment for testing
22-
- uses: actions/setup-node@v1
23+
- uses: actions/setup-node@v2
2324
with:
24-
node-version: '12.16'
25+
node-version: '12.x'
2526
registry-url: 'https://registry.npmjs.org'
26-
- name: test
27-
run: echo ${{github.event_name}}
28-
- name: npm install
29-
run: npm install
27+
- name: yarn install
28+
run: yarn install
3029
- name: run unittest
31-
run: npm run test_unit
30+
run: yarn run test_unit
3231
- name: run integration test
3332
if: github.event.pull_request.base.ref == 'master' # integration test only run when master merging
34-
run: npm run test_integration
33+
run: yarn run test_integration
3534
check_protocol_version:
3635
if: ${{ github.event_name == 'push' }}
37-
runs-on: ubuntu-latest
36+
runs-on: macos-latest
3837
steps:
3938
- uses: actions/checkout@v2
4039
- name: test
@@ -52,7 +51,59 @@ jobs:
5251
run: |
5352
curl -X POST https://hooks.slack.com/services/$SLACK_WEBHOOK_TOKEN \
5453
-H "Content-Type: application/json" \
55-
-d '{"username": "ain-blockchain",
54+
-d '{"username": "AIN-BLOCKCHAIN",
5655
"channel": "blockchain-testnet-deploy",
5756
"text": "New PR has just been merged(${{ github.ref }}, ${{ github.sha }}).\nCurrent version: '"$VERSION"', compatible with min('"$MIN_VERSION"'), max('"$MAX_VERSION"')",
5857
"icon_emoji": ":gem:"}'
58+
performance_test:
59+
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'develop'
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: google-github-actions/setup-gcloud@master
63+
with:
64+
service_account_key: ${{ secrets.PERF_TEST_PIPELINE_GCP_SA_KEY }}
65+
project_id: ${{ secrets.PERF_TEST_PIPELINE_GCP_PROJECT_ID }}
66+
- name: send test start message to gcp
67+
run: |-
68+
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 &" &
69+
sleep 60
70+
check_deployment:
71+
if: github.event.pull_request.base.ref == 'master'
72+
runs-on: macos-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- uses: actions/setup-node@v2
76+
with:
77+
node-version: '12.x'
78+
registry-url: 'https://registry.npmjs.org'
79+
- name: setup key
80+
env:
81+
PRIV_KEY_FOR_DOWNLOAD: ${{ secrets.DEPLOYMENT_PRIV_KEY_FOR_DOWNLOAD }}
82+
KNOWN_HOSTS: ${{ secrets.DEPLOYMENT_KNOWN_HOSTS }}
83+
run: |
84+
echo "$PRIV_KEY_FOR_DOWNLOAD" > ./tools/cicd/id_rsa
85+
chmod 600 ./tools/cicd/id_rsa
86+
echo $KNOWN_HOSTS >> ~/.ssh/known_hosts
87+
- name: check apps
88+
env:
89+
ENV_ID: ${{ secrets.DEPLOYMENT_ENV_ID }}
90+
CLIENT_EMAIL: ${{ secrets.DEPLOYMENT_CLIENT_EMAIL }}
91+
PRIVATE_KEY: ${{ secrets.DEPLOYMENT_PRIVATE_KEY}}
92+
GPT2: ${{ secrets.DEPLOYMENT_GPT2 }}
93+
INSIGHT: ${{ secrets.DEPLOYMENT_INSIGHT }}
94+
FAUCET: ${{ secrets.DEPLOYMENT_FAUCET }}
95+
PIPELINE: ${{ secrets.DEPLOYMENT_PIPELINE }}
96+
DATA: ${{ secrets.DEPLOYMENT_DATA }}
97+
run: |
98+
yarn add dotenv google-spreadsheet semver
99+
node tools/cicd/deployment.js
100+
- name: send slack message
101+
env:
102+
SLACK_WEBHOOK_TOKEN: ${{ secrets.SLACK_WEBHOOK_TOKEN }}
103+
run: |
104+
curl -X POST https://hooks.slack.com/services/$SLACK_WEBHOOK_TOKEN \
105+
-H "Content-Type: application/json" \
106+
-d '{"username": "APP_VERSION_CHECK",
107+
"channel": "blockchain-testnet-deploy",
108+
"text": "New blockchain version has just been released. Please check compatibility of app versions below:\n ${{ secrets.DEPLOYMENT_SHEET_URL }}",
109+
"icon_emoji": ":bomb:"}'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The genesis configs directory used is `genesis-configs/base` by default and it c
115115
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
116116
```
117117

118-
#### On Google Coud Platform (GCP)
118+
#### On Google Cloud Platform (GCP)
119119

120120
- Deploy code (in common with Tracker server)
121121
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.

bitbucket-pipelines.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

blockchain/block.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const sizeof = require('object-sizeof');
33
const moment = require('moment');
44
const _ = require('lodash');
55
const logger = require('../logger')('BLOCK');
6-
const ChainUtil = require('../common/chain-util');
6+
const CommonUtil = require('../common/common-util');
77
const Transaction = require('../tx-pool/transaction');
88
const StateNode = require('../db/state-node');
99
const DB = require('../db');
@@ -28,8 +28,8 @@ class Block {
2828
this.transactions = Block.sanitizeTransactions(transactions);
2929
// Block's header
3030
this.last_hash = lastHash;
31-
this.last_votes_hash = ChainUtil.hashString(stringify(lastVotes));
32-
this.transactions_hash = ChainUtil.hashString(stringify(this.transactions));
31+
this.last_votes_hash = CommonUtil.hashString(stringify(lastVotes));
32+
this.transactions_hash = CommonUtil.hashString(stringify(this.transactions));
3333
this.number = number;
3434
this.epoch = epoch;
3535
this.timestamp = timestamp;
@@ -80,7 +80,7 @@ class Block {
8080

8181
static hash(block) {
8282
if (!(block instanceof Block)) block = Block.parse(block);
83-
return ChainUtil.hashString(stringify(block.header));
83+
return CommonUtil.hashString(stringify(block.header));
8484
}
8585

8686
static getSize(block) {
@@ -119,12 +119,12 @@ class Block {
119119
logger.error(`[${LOG_HEADER}] Block hash is incorrect for block ${block.hash}`);
120120
return false;
121121
}
122-
if (block.transactions_hash !== ChainUtil.hashString(stringify(block.transactions))) {
122+
if (block.transactions_hash !== CommonUtil.hashString(stringify(block.transactions))) {
123123
logger.error(
124124
`[${LOG_HEADER}] Transactions or transactions_hash is incorrect for block ${block.hash}`);
125125
return false;
126126
}
127-
if (block.last_votes_hash !== ChainUtil.hashString(stringify(block.last_votes))) {
127+
if (block.last_votes_hash !== CommonUtil.hashString(stringify(block.last_votes))) {
128128
logger.error(
129129
`[${LOG_HEADER}] Last votes or last_votes_hash is incorrect for block ${block.hash}`);
130130
return false;
@@ -209,7 +209,7 @@ class Block {
209209
static buildAccountsSetupTx(timestamp, privateKey, ownerAddress) {
210210
const transferOps = [];
211211
const otherAccounts = GenesisAccounts[AccountProperties.OTHERS];
212-
if (otherAccounts && ChainUtil.isArray(otherAccounts) && otherAccounts.length > 0 &&
212+
if (otherAccounts && CommonUtil.isArray(otherAccounts) && otherAccounts.length > 0 &&
213213
GenesisAccounts[AccountProperties.SHARES] > 0) {
214214
for (let i = 0; i < otherAccounts.length; i++) {
215215
const accountAddress = otherAccounts[i][AccountProperties.ADDRESS];
@@ -283,9 +283,9 @@ class Block {
283283
}
284284

285285
static getGenesisBlockTxs(genesisTime) {
286-
const ownerAddress = ChainUtil.getJsObject(
286+
const ownerAddress = CommonUtil.getJsObject(
287287
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.ADDRESS]);
288-
const ownerPrivateKey = ChainUtil.getJsObject(
288+
const ownerPrivateKey = CommonUtil.getJsObject(
289289
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.PRIVATE_KEY]);
290290

291291
const firstTx = this.buildDbSetupTx(genesisTime, ownerPrivateKey);
@@ -304,14 +304,14 @@ class Block {
304304
const resList = [];
305305
for (const tx of genesisTxs) {
306306
const res = tempGenesisDb.executeTransaction(Transaction.toExecutable(tx));
307-
if (ChainUtil.isFailedTx(res)) {
307+
if (CommonUtil.isFailedTx(res)) {
308308
logger.error(`Genesis transaction failed:\n${JSON.stringify(tx, null, 2)}` +
309309
`\nRESULT: ${JSON.stringify(res)}`)
310310
return null;
311311
}
312312
resList.push(res);
313313
}
314-
const { gasAmountTotal, gasCostTotal } = ChainUtil.getServiceGasCostTotalFromTxList(genesisTxs, resList);
314+
const { gasAmountTotal, gasCostTotal } = CommonUtil.getServiceGasCostTotalFromTxList(genesisTxs, resList);
315315
return {
316316
stateProofHash: tempGenesisDb.getStateProof('/')[ProofProperties.PROOF_HASH],
317317
gasAmountTotal,
@@ -322,7 +322,7 @@ class Block {
322322
static genesis() {
323323
// This is a temporary fix for the genesis block. Code should be modified after
324324
// genesis block broadcasting feature is implemented.
325-
const ownerAddress = ChainUtil.getJsObject(
325+
const ownerAddress = CommonUtil.getJsObject(
326326
GenesisAccounts, [AccountProperties.OWNER, AccountProperties.ADDRESS]);
327327
const genesisTime = GenesisAccounts[AccountProperties.TIMESTAMP];
328328
const lastHash = '';

0 commit comments

Comments
 (0)