Skip to content

Commit

Permalink
Merge pull request #1118 from OriginTrail/prerelease/mainnet
Browse files Browse the repository at this point in the history
4.0.1 release
  • Loading branch information
djordjekovac authored Jan 6, 2020
2 parents 1495a29 + 11195e9 commit dc8bc00
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __OriginTrail is an ecosystem dedicated to making global supply chains work toge

This repository contains a work-in-progress code for a network node.

__OriginTrail Decentralized Network (ODN)__ is currently running in the __OriginTrail Vostok Mainnet__ stage. For further information about the roadmap please see our [website](https://tech.origintrail.io/roadmap).
__OriginTrail Decentralized Network (ODN)__ is currently running in the __Freedom-Gemini__ stage. For further information about the roadmap please see our [website](https://tech.origintrail.io/roadmap).

[Please see our main documentation page for more information](http://docs.origintrail.io)

Expand Down
3 changes: 3 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ssl_certificate_path": "kademlia.crt",
"identity_filepath": "identity.json",
"erc725_identity_filepath": "erc725_identity.json",
"houston_password_file_name": "houston.txt",
"cpus": 0,
"embedded_peercache_path": "peercache",
"onion_virtual_port": "4043",
Expand Down Expand Up @@ -121,6 +122,7 @@
"ssl_certificate_path": "kademlia.crt",
"identity_filepath": "identity.json",
"erc725_identity_filepath": "erc725_identity.json",
"houston_password_file_name": "houston.txt",
"cpus": 0,
"embedded_peercache_path": "peercache",
"onion_virtual_port": "4043",
Expand Down Expand Up @@ -229,6 +231,7 @@
"ssl_certificate_path": "kademlia.crt",
"identity_filepath": "identity.json",
"erc725_identity_filepath": "erc725_identity.json",
"houston_password_file_name": "houston.txt",
"cpus": 0,
"embedded_peercache_path": "peercache",
"onion_virtual_port": "4043",
Expand Down
9 changes: 3 additions & 6 deletions modules/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ class Logger {
* @return {*}
*/
static transformLog(level, msg) {
if (process.env.LOGS_LEVEL_DEBUG) {
return {
level,
msg,
};
}
if (msg.startsWith('connection timed out')) {
return null;
}
Expand All @@ -213,6 +207,9 @@ class Logger {
if (msg.startsWith('updating peer profile')) {
return null;
}
if (msg.startsWith('updating cached peer profile')) {
return null;
}
if (msg.includes('client cannot service request at this time')) {
return null;
}
Expand Down
12 changes: 6 additions & 6 deletions modules/network/kademlia/kademlia.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ class Kademlia {
next();
});

this.node.blacklist = this.node.plugin(kadence.churnfilter({
cooldownBaseTimeout: this.config.network.churnPlugin.cooldownBaseTimeout,
cooldownMultiplier:
parseInt(this.config.network.churnPlugin.cooldownMultiplier, 10),
cooldownResetTime: this.config.network.churnPlugin.cooldownResetTime,
}));
// this.node.blacklist = this.node.plugin(kadence.churnfilter({
// cooldownBaseTimeout: this.config.network.churnPlugin.cooldownBaseTimeout,
// cooldownMultiplier:
// parseInt(this.config.network.churnPlugin.cooldownMultiplier, 10),
// cooldownResetTime: this.config.network.churnPlugin.cooldownResetTime,
// }));
if (this.config.traverse_nat_enabled) {
this.enableNatTraversal();
}
Expand Down
8 changes: 7 additions & 1 deletion modules/service/pricing-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ class PricingService {

async getGasPrice() {
if (process.env.NODE_ENV === 'development') {
this.logger.trace(`Using default gas price from configuration: ${this.config.blockchain.gas_price}`);
return this.config.blockchain.gas_price;
}

const now = new Date().getTime();
if (this.config.blockchain.gas_price_last_update_timestamp
+ constants.GAS_PRICE_VALIDITY_TIME_IN_MILLS > now) {
this.logger.trace(`Using gas price from configuration: ${this.config.blockchain.gas_price}`);
return this.config.blockchain.gas_price;
}
let gasStationGasPrice = await this.gasStationService.getGasPrice()
Expand All @@ -59,19 +61,23 @@ class PricingService {
let web3GasPrice = await this.web3.eth.getGasPrice()
.catch((err) => { this.logger.warn(err); }) * constants.AVERAGE_GAS_PRICE_MULTIPLIER;
web3GasPrice = Math.round(web3GasPrice);

if (gasStationGasPrice && web3GasPrice) {
const gasPrice = (
gasStationGasPrice > web3GasPrice ? gasStationGasPrice : web3GasPrice);
this.saveNewGasPriceAndTime(gasPrice);
const service = gasStationGasPrice > web3GasPrice ? 'gas station' : 'web3';
this.logger.trace(`Using gas price from ${service} service: ${gasStationGasPrice}`);
return gasPrice;
} else if (gasStationGasPrice) {
this.saveNewGasPriceAndTime(gasStationGasPrice);
this.logger.trace(`Using gas price from gas station service: ${gasStationGasPrice}`);
return gasStationGasPrice;
} else if (web3GasPrice) {
this.saveNewGasPriceAndTime(web3GasPrice);
this.logger.trace(`Using gas price from web3 service: ${web3GasPrice}`);
return web3GasPrice;
}
this.logger.trace(`Using gas price from configuration: ${this.config.blockchain.gas_price}`);
return this.config.blockchain.gas_price;
}

Expand Down
11 changes: 8 additions & 3 deletions modules/service/trac-price-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ class TracPriceService {

async getTracPriceInEth() {
if (process.env.NODE_ENV === 'development') {
this.logger.trace(`Using default trac price in eth from configuration: ${this.config.blockchain.trac_price_in_eth}`);
return this.config.blockchain.trac_price_in_eth;
}

const now = new Date().getTime();
if (this.config.blockchain.trac_price_in_eth_last_update_timestamp
+ constants.TRAC_PRICE_IN_ETH_VALIDITY_TIME_IN_MILLS > now) {
this.logger.trace(`Using trac price in eth from configuration: ${this.config.blockchain.trac_price_in_eth}`);
return this.config.blockchain.trac_price_in_eth;
}
let tracPriceInEth;
let tracPriceInEth = this.config.blockchain.trac_price_in_eth;
const response = await axios.get(coinGeckoLink)
.catch((err) => {
this.logger.warn(err);
Expand All @@ -29,9 +31,12 @@ class TracPriceService {
}
if (tracPriceInEth) {
this._saveNewTracPriceInEth(tracPriceInEth);
return tracPriceInEth;
this.logger.trace(`Using trac price in eth from coingecko service: ${tracPriceInEth}`);
} else {
tracPriceInEth = this.config.blockchain.trac_price_in_eth;
this.logger.trace(`Using trac price in eth from configuration: ${tracPriceInEth}`);
}
return this.config.blockchain.trac_price_in_eth;
return tracPriceInEth;
}

_saveNewTracPriceInEth(tracePrice) {
Expand Down
17 changes: 10 additions & 7 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,19 @@ class OTNode {
process.exit(1);
}

// Fetch Houston access password
if (!config.houston_password) {
const houstonPasswordFilePath = path
.join(config.appDataPath, config.houston_password_file_name);
if (fs.existsSync(houstonPasswordFilePath)) {
log.info('Using existing houston password.');
config.houston_password = fs.readFileSync(houstonPasswordFilePath).toString();
} else {
config.houston_password = uuidv4();
fs.writeFileSync(houstonPasswordFilePath, config.houston_password);
log.notify('================================================================');
log.notify(' Houston password generated and stored in file ');
log.notify('================================================================');
}

fs.writeFileSync(path.join(config.appDataPath, 'houston.txt'), config.houston_password);
log.notify('================================================================');
log.notify('Houston password stored in file ');
log.notify('================================================================');

// Starting the kademlia
const transport = container.resolve('transport');
await transport.init(container.cradle);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "4.0.0",
"version": "4.0.1",
"description": "OriginTrail node",
"main": ".eslintrc.js",
"config": {
Expand Down
2 changes: 1 addition & 1 deletion test/modules/utilities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Utilities module', () => {
'ssl_authority_paths', 'node_rpc_port',
'remote_control_enabled', 'dc_challenge_retry_delay_in_millis', 'dh_challenge_retry_delay_in_millis',
'read_stake_factor', 'send_logs_to_origintrail',
'dh_min_reputation', 'dh_min_stake_amount',
'dh_min_reputation', 'dh_min_stake_amount', 'houston_password_file_name',
'is_bootstrap_node', 'houston_password', 'reverse_tunnel_address', 'reverse_tunnel_port',
'autoUpdater', 'bugSnag', 'network', 'dataSetStorage', 'dc_holding_time_in_minutes', 'dc_choose_time', 'dc_litigation_interval_in_minutes',
'dh_max_holding_time_in_minutes', 'dh_min_litigation_interval_in_minutes',
Expand Down

0 comments on commit dc8bc00

Please sign in to comment.