Skip to content

Commit

Permalink
Merge pull request #1257 from ainblockchain/release/v1.1.4
Browse files Browse the repository at this point in the history
Release/v1.1.4
  • Loading branch information
platfowner committed Mar 20, 2024
2 parents c6d3ab6 + 8028d6d commit 3b0ba96
Show file tree
Hide file tree
Showing 20 changed files with 3,560 additions and 142 deletions.
3,378 changes: 3,378 additions & 0 deletions JSON_RPC_API.md

Large diffs are not rendered by default.

102 changes: 61 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
### [AI Network](https://ainetwork.ai) | [Whitepaper](https://c9ede755-23ca-410d-8a9d-e5b895cd95bb.filesusr.com/ugd/4f6eb2_482a2386addb4c3283ee6e26f8ad42e6.pdf) | [Documentation](https://docs.ainetwork.ai/)
Official Javascript implementation of AI Network Blockchain.

## JSON-RPC API

For accessing AIN Blockchain nodes, see [JSON_RPC_API.md](./JSON_RPC_API.md).

## Install Environment (Last update at 6th of Dec 2021)
### OS

- macOS 10.15 (macos-latest)
- Ubuntu 20.04 (ubuntu-latest)
- macOS 13.5 (macos-latest)
- Ubuntu 22.04 (ubuntu-latest)

### Node version
### NodeJs version

- v16.x
- v14.x
- v18.x

## Tracker

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.
Tracker server is required by new peers who wish to join the AIN network. Each peer is sent the ip address 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.

### Running without Docker
### Running Tracker without Docker

#### Local

Expand All @@ -44,26 +47,22 @@ You can override default port numbering system by setting `PORT` and `P2P_PORT`
```
gcloud init
# For genesis deploy
bash deploy_blockchain_genesis_gcp.sh {dev|staging|spring|summer} <# of Shards> [--setup]
bash deploy_blockchain_genesis_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <# of Shards> <Parent Node Index Begin> <Parent Node Index End> [--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]
# For incremental deploy
bash deploy_blockchain_incremental_gcp.sh {dev|staging|spring|summer} <# of Shards> <Begin Parent Node Index> <End Parent Node Index> [--setup]
bash deploy_blockchain_incremental_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <# of Shards> <Parent Node Index Begin> <Parent Node Index End> [--setup] [--keystore|--mnemonic|--private-key] [--keep-code|--no-keep-code] [--keep-data|--no-keep-data] [--full-sync|--fast-sync] [--chown-data|--no-chown-data]
```
- Set up Ubuntu machine (if it's on a new VM)
```
bash setup_blockchain_ubuntu.sh
```
- Copy files to a sharable folder & install yarn packages
```
source setup_tracker_gcp.sh
```
- Start tracker server job
```
cd ain-blockchain/
bash start_tracker_genesis_gcp.sh
bash start_tracker_genesis_gcp.sh <GCP Username> [--keep-code|--no-keep-code]
```

<!--
### Running with Docker
### Running Tracker with Docker
- Build Docker image
```
Expand All @@ -80,21 +79,21 @@ docker run --network="host" -d ainblockchain/tracker-server:latest
```
-->

### Client API for development and debugging
### Tracker Client API for development and testing purposes

#### Tracker health check
#### Tracker protocol version check & health check

GET http://<ip_address>:5000/
GET http://<ip_address>:8080/

#### Node status check
#### Network status check

GET http://<ip_address>:5000/peer_nodes
GET http://<ip_address>:8080/network_status

## Node
## Blockchain Node

Operates a single peer node instance of the AIN blockchain. A single blockchain node instance processes incoming transaction requests and maintains a local copy of the entire blockchain. The blockchain node first queries the tracker-server for ip addresses of other peers, and then syncs its local blockchain to the network consensus blockchain. If a node is included in the whitelist and has staked appropriate amount of AIN, it will then take part in the consensus protocol.

### Running without Docker
### Running Blockchain Node without Docker

#### Local

Expand Down Expand Up @@ -131,24 +130,20 @@ BLOCKCHAIN_CONFIGS_DIR=blockchain-configs/afan-shard MIN_NUM_VALIDATORS=1 DEBUG=
```
gcloud init
# For genesis deploy
bash deploy_blockchain_genesis_gcp.sh {dev|staging|spring|summer} <# of Shards> [--setup]
bash deploy_blockchain_genesis_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <# of Shards> <Parent Node Index Begin> <Parent Node Index End> [--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]
# For incremental deploy
bash deploy_blockchain_incremental_gcp.sh {dev|staging|spring|summer} <# of Shards> <Begin Parent Node Index> <End Parent Node Index> [--setup]
bash deploy_blockchain_incremental_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <# of Shards> <Parent Node Index Begin> <Parent Node Index End> [--setup] [--keystore|--mnemonic|--private-key] [--keep-code|--no-keep-code] [--keep-data|--no-keep-data] [--full-sync|--fast-sync] [--chown-data|--no-chown-data]
```
- Set up Ubuntu machine (if it's on a new VM)
```
bash setup_blockchain_ubuntu.sh
```
- Copy files to a sharable folder & install yarn packages
```
source setup_node_gcp.sh
```
- Start Node server job (set shard index to 0 if you're running a root chain node)
```
bash start_node_genesis_gcp.sh {dev|spring|summer} <SHARD_INDEX> <SERVER_INDEX>
bash start_node_genesis_gcp.sh [dev|staging|sandbox|exp|spring|summer|mainnet] <GCP Username> <Shard Index> <Node Index> [--keystore|--mnemonic|--private-key] [--keep-code|--no-keep-code] [--keep-data|--no-keep-data] [--full-sync|--fast-sync] [--chown-data|--no-chown-data] [--json-rpc] [--update-front-db] [--rest-func] [--event-handler]
```

### Running with Docker
### Running Blockchain Node with Docker

- Pull Docker image from [Docker Hub](https://hub.docker.com/repository/docker/ainblockchain/ain-blockchain)
```
Expand Down Expand Up @@ -207,7 +202,7 @@ cat logger/logs/8080/<log_file>
```
-->

### How to run tests
### Testing How-Tos

How to run unit test and integration test all around.
```
Expand All @@ -217,27 +212,52 @@ yarn run test_integration

Some individual tests already definded in the package.json.
```
yarn run test_chain_util
yarn run test_state_util
yarn run test_block_pool
yarn run test_db
yarn run test_node
yarn run test_blockchain
yarn run test_dapp
yarn run test_sharding
yarn run test_unit_block_pool
yarn run test_unit_blockchain
yarn run test_unit_common_util
yarn run test_unit_consensus
yarn run test_unit_db
yarn run test_unit_event_handler
yarn run test_unit_functions
yarn run test_unit_object_util
yarn run test_unit_p2p
yarn run test_unit_p2p_util
yarn run test_unit_radix_node
yarn run test_unit_radix_tree
yarn run test_unit_rule_util
yarn run test_unit_state_manager
yarn run test_unit_state_node
yarn run test_unit_state_util
yarn run test_unit_traffic_db
yarn run test_unit_traffic_sm
yarn run test_unit_tx
yarn run test_unit_tx_pool
yarn run test_integration_dapp
yarn run test_integration_blockchain
yarn run test_integration_consensus
yarn run test_integration_event_handler
yarn run test_integration_function
yarn run test_integration_node
yarn run test_integration_he_protocol
yarn run test_integration_he_sharding
yarn run test_integration_sharding
```

The load test is also supported.
```
yarn run loadtest
```

### Client API for development and debugging
### Blockchain Node Client API for development and testing purposes

#### Node health check
#### Node protocol version check

GET http://<ip_address>:8080/

#### Node health check

GET http://<ip_address>:8080/health_check

#### Fetch latest blocks in the blockchain (up to 20 blocks)

GET http://<ip_address>:8080/blocks
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/afan-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "local",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/base/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "local",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/he-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "local",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/mainnet-prod/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/sim-shard/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "local",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/testnet-dev/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/testnet-exp/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/testnet-prod/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/testnet-sandbox/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
2 changes: 1 addition & 1 deletion blockchain-configs/testnet-staging/node_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"FREE_TX_POOL_SIZE_LIMIT_RATIO_PER_ACCOUNT": 0.1,
"GET_OP_LIST_SIZE_LIMIT": 50,
"GET_RESP_BYTES_LIMIT": 20000000,
"GET_RESP_MAX_SIBLINGS": 5000,
"GET_RESP_MAX_SIBLINGS": 20000,
"HOSTING_ENV": "gcp",
"LIGHTWEIGHT": false,
"MAX_BLOCKCHAIN_API_RATE_LIMIT": 20,
Expand Down
3 changes: 3 additions & 0 deletions client/protocol_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,8 @@
},
"1.1.3": {
"min": "1.0.0"
},
"1.1.4": {
"min": "1.0.0"
}
}
15 changes: 0 additions & 15 deletions json_rpc/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,5 @@ module.exports = function getAccountApis(node) {
trafficStatsManager.addEvent(TrafficEventTypes.JSON_RPC_GET, latency);
done(null, JsonRpcUtil.addProtocolVersion({ result }));
},

[JSON_RPC_METHODS.AIN_GET_VALIDATOR_INFO]: function(args, done) {
const beginTime = Date.now();
const addr = args.address;
const isWhitelisted = node.db.getValue(PathUtil.getConsensusProposerWhitelistAddrPath(addr)) || false;
const stake = node.db.getValue(PathUtil.getServiceAccountBalancePath(addr)) || 0;
const latency = Date.now() - beginTime;
trafficStatsManager.addEvent(TrafficEventTypes.JSON_RPC_GET, latency);
done(null, JsonRpcUtil.addProtocolVersion({
result: {
isWhitelisted,
stake,
}
}));
},
};
};
Loading

0 comments on commit 3b0ba96

Please sign in to comment.