Skip to content

Commit

Permalink
Merge branch 'v6/develop' of https://github.com/OriginTrail/ot-node i…
Browse files Browse the repository at this point in the history
…nto v6/develop
  • Loading branch information
djordjekovac committed Apr 1, 2022
2 parents bb351b2 + 35b6d46 commit baef689
Show file tree
Hide file tree
Showing 33 changed files with 2,926 additions and 11,736 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @branarakic @djordjekovac @kotlarmilos @NZT48
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report_v6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report for v6 ot-node
about: Create an issue report
title: ''
labels: ''
assignees: ''

---

## Issue description

## Expected behavior

## Actual behavior

## Steps to reproduce the problem

1.
2.
3.

## Specifications

- Node version:
- Platform:
- Node wallet:
- Node libp2p identity:

## Contact details
- Email:

## Error logs


## Disclaimer

Please be aware that the issue reported on a public repository allows everyone to see your node logs, node details, and contact details. If you have any sensitive information, feel free to share it by sending an email to [[email protected]]([email protected]).
21 changes: 21 additions & 0 deletions .github/release-drafter-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name-template: 'OriginTrail Release $NEXT_PATCH_VERSION'
tag-template: "$NEXT_PATCH_VERSION"
version-template: "v$MAJOR.$MINOR.$PATCH"
categories:
- title: '🚀 Features'
labels:
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'internal process'
- title: '⚠️ Breaking changes'
labels:
- 'breaking change'
change-template: '- $TITLE (#$NUMBER)'
template: |
# Changes
$CHANGES
49 changes: 49 additions & 0 deletions .github/workflows/TEST-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: TEST-release

#todo this test should be execute when opening PR to prerelease/release branches
on: [pull_request]
env:
NODE_ENV: test
ARTIFACTS_DIR: artifacts
CUCUMBER_ARTIFACTS_DIR: artifacts/cucumber
jobs:

test:
#todo think about locking the version - version should be the same as the one in official documentation
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: operationaldb
MYSQL_USER: node
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
graphdb:
image: khaller/graphdb-free:latest
ports:
- 7200:7200
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: mkdir -p $ARTIFACTS_DIR
- run: cp .origintrail_noderc.tests .origintrail_noderc
- run: sudo chmod -R 777 $ARTIFACTS_DIR
- run: mkdir -p $CUCUMBER_ARTIFACTS_DIR
- run: sudo chmod -R 777 $CUCUMBER_ARTIFACTS_DIR
- run: npm run test:bdd:release;
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: my-artifact
path: /home/runner/work/ot-node/ot-node/artifacts
49 changes: 49 additions & 0 deletions .github/workflows/TEST-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: TEST-unit

#todo this test should be execute when opening PR to prerelease/release branches
on: [pull_request]
env:
NODE_ENV: test
ARTIFACTS_DIR: artifacts
CUCUMBER_ARTIFACTS_DIR: artifacts/cucumber
jobs:

test:
#todo think about locking the version - version should be the same as the one in official documentation
runs-on: ubuntu-latest
# services:
# mysql:
# image: mysql:5.7
# env:
# MYSQL_DATABASE: operationaldb
# MYSQL_USER: node
# MYSQL_PASSWORD: password
# MYSQL_ROOT_PASSWORD: password
# ports:
# - 3306:3306
# options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
# graphdb:
# image: khaller/graphdb-free:latest
# ports:
# - 7200:7200
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: mkdir -p $ARTIFACTS_DIR
- run: cp .origintrail_noderc.tests .origintrail_noderc
- run: sudo chmod -R 777 $ARTIFACTS_DIR
- run: mkdir -p $CUCUMBER_ARTIFACTS_DIR
- run: sudo chmod -R 777 $CUCUMBER_ARTIFACTS_DIR
- run: npm run test:unit;
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: my-artifact
path: /home/runner/work/ot-node/ot-node/artifacts
19 changes: 19 additions & 0 deletions .github/workflows/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- develop

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
with:
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
config-name: release-drafter-template.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 changes: 67 additions & 6 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 5,
"replicationFactor": 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -36,8 +36,59 @@
],
"telemetryHub": {
"enabled": false,
"packages": ["ot-telemetry-collector"],
"packages": [
"ot-telemetry-collector"
],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"test": {
"appDataPath": "data",
"autoUpdate": {
"enabled": false,
"branch": "v6/develop",
"backupDirectory": "../backup"
},
"blockchain": [
{
"blockchainTitle": "ganache",
"networkId": "ganache::testnet",
"hubContractAddress": "",
"rpcEndpoints": [
"http://localhost:7545"
]
}
],
"graphDatabase": {
"implementation": "GraphDB",
"url": "http://localhost:7200",
"name": "node0",
"username": "admin",
"password": ""
},
"logLevel": "trace",
"replicationFactor": 5,
"rpcPort": 8900,
"network": {
"port": 9000,
"bootstrap": []
},
"ipWhitelist": [
"::1",
"127.0.0.1"
],
"telemetryHub": {
"enabled": false,
"packages": [
"ot-telemetry-collector"
],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"testnet": {
Expand Down Expand Up @@ -65,7 +116,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 5,
"replicationFactor": 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -81,8 +132,13 @@
],
"telemetryHub": {
"enabled": true,
"packages": ["ot-telemetry-collector"],
"packages": [
"ot-telemetry-collector"
],
"url": "https://polaris.delta.origin-trail.network/metrics/"
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
},
"mainnet": {
Expand All @@ -101,7 +157,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 5,
"replicationFactor": 5,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand All @@ -113,8 +169,13 @@
],
"telemetryHub": {
"enabled": false,
"packages": ["ot-telemetry-collector"],
"packages": [
"ot-telemetry-collector"
],
"url": ""
},
"operationalDatabase": {
"databaseName": "operationaldb"
}
}
}
1 change: 0 additions & 1 deletion config/sequelizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require('dotenv').config();
module.exports = {
username: 'root',
password: '',
database: 'operationaldb',
dialect: 'mysql',
host: 'localhost',
port: 3306,
Expand Down
33 changes: 18 additions & 15 deletions external/libp2p-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ class Libp2pService {
listen: [`/ip4/0.0.0.0/tcp/${this.config.port}`] // for production
// announce: ['/dns4/auto-relay.libp2p.io/tcp/443/wss/p2p/QmWDn2LY8nannvSWJzruUYoLZ4vV83vfCBwd8DipvdgQc3']
};

let id;
let privKey;
if (!this.config.peerId) {
const configFile = JSON.parse(fs.readFileSync(this.config.configFilename));
if (!configFile.network.privateKey) {
const id = await PeerId.create({bits: 1024, keyType: 'RSA'})
configFile.network.privateKey = id.toJSON().privKey;
if(process.env.NODE_ENV !== 'development') {
fs.writeFileSync(this.config.configFilename, JSON.stringify(configFile, null, 2));
}
if (!this.config.privateKey) {
id = await PeerId.create({bits: 1024, keyType: 'RSA'})
privKey = id.toJSON().privKey;
} else {
privKey = this.config.privateKey;
id = await PeerId.createFromPrivKey(this.config.privateKey);
}
this.config.privateKey = configFile.network.privateKey;
this.config.peerId = await PeerId.createFromPrivKey(this.config.privateKey);
this.config.privateKey = privKey;
this.config.peerId = id;
}

initializationObject.peerId = this.config.peerId;
Expand All @@ -83,7 +83,10 @@ class Libp2pService {
const peerId = this.node.peerId._idB58String;
this.config.id = peerId;
this.logger.info(`Network ID is ${peerId}, connection port is ${port}`);
resolve(result);
resolve({
peerId: id,
privateKey: privKey,
});
})
.catch((err) => {
reject(err);
Expand Down Expand Up @@ -288,7 +291,7 @@ class Libp2pService {
constants.NETWORK_API_BLACK_LIST_TIME_WINDOW_MINUTES -
(Date.now() - this.blackList[remotePeerId]) / (1000 * 60)
);

if(remainingMinutes > 0) {
this.logger.info(`Blocking request from ${remotePeerId}. Node is blacklisted for ${remainingMinutes} minutes.`);

Expand All @@ -297,7 +300,7 @@ class Libp2pService {
delete this.blackList[remotePeerId]
}
}

if(await this.rateLimiter.spamDetection.limit(remotePeerId)) {
this.blackList[remotePeerId] = Date.now();
this.logger.info(
Expand All @@ -309,8 +312,8 @@ class Libp2pService {
this.logger.info(`Blocking request from ${remotePeerId}. Max number of requests exceeded.`);

return true;
}
}

return false;
}

Expand Down
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ config = rc(pjson.name, defaultConfig);

(async () => {
try {
const node = new OTNode();
let userConfig = null;
if (process.env.NODE_ENV === 'development' && process.argv.length === 3) {
const configurationFilename = process.argv[2];
userConfig = JSON.parse(fs.readFileSync(process.argv[2]));
userConfig.configFilename = configurationFilename;
}
const node = new OTNode(userConfig);
await node.start();
} catch (e) {
console.error(`Error occurred while starting new version, error message: ${e}. ${e.stack}`);
Expand Down
Loading

0 comments on commit baef689

Please sign in to comment.