Skip to content

Commit

Permalink
Testnet Release 3.0.7 (#930)
Browse files Browse the repository at this point in the history
- Prevent remote control to crash finalize command.
- Use latest Kadence from v5 branch which includes fix for the Hashcash.
- Use Churn plugin to filter invalid connections.
  • Loading branch information
kipliklotrika authored May 8, 2019
1 parent d8c0570 commit 48c532c
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 124 deletions.
37 changes: 31 additions & 6 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@
"bootstraps": ["https://developbs.origintrial.me:5278/#05edf19bd36906240503e2e2e2f18d13f8211d2f"],
"remoteWhitelist": ["54.93.223.161", "127.0.0.1"],
"solutionDifficulty": 8,
"identityDifficulty": 8
"identityDifficulty": 8,
"churnPlugin": {
"cooldownBaseTimeout": "5m",
"cooldownMultiplier": 2,
"cooldownResetTime": "60m"
}
},
"bugSnag": {
"releaseStage": "development"
Expand Down Expand Up @@ -156,7 +161,7 @@
"network_id": "rinkeby",
"gas_limit": "2000000",
"gas_price": "20000000000",
"hub_contract_address": "0x16d553B9765b6Aa9fE7C45Dfa1a1839fD88DD7bc",
"hub_contract_address": "0xA272797Bfc59946388D89CdB6821dEeC927E0E36",
"plugins": [
{
"enabled": false,
Expand All @@ -178,7 +183,12 @@
"bootstraps": ["https://stagingbs.origintrial.me:5278/#1754b56ce26212eab45bc523c36e1d4bf57ea30e"],
"remoteWhitelist": ["54.93.223.161", "127.0.0.1"],
"solutionDifficulty": 14,
"identityDifficulty": 12
"identityDifficulty": 12,
"churnPlugin": {
"cooldownBaseTimeout": "5m",
"cooldownMultiplier": 2,
"cooldownResetTime": "60m"
}
},
"bugSnag": {
"releaseStage": "staging"
Expand Down Expand Up @@ -279,7 +289,12 @@
"bootstraps": ["https://82.196.10.12:5278/#e2f7ab11d0dd34595dfb2e71b4937ec8d790df84"],
"remoteWhitelist": ["54.93.223.161", "127.0.0.1"],
"solutionDifficulty": 14,
"identityDifficulty": 12
"identityDifficulty": 12,
"churnPlugin": {
"cooldownBaseTimeout": "5m",
"cooldownMultiplier": 2,
"cooldownResetTime": "60m"
}
},
"bugSnag": {
"releaseStage": "stable"
Expand Down Expand Up @@ -383,7 +398,12 @@
],
"remoteWhitelist": ["127.0.0.1", "localhost"],
"solutionDifficulty": 14,
"identityDifficulty": 12
"identityDifficulty": 12,
"churnPlugin": {
"cooldownBaseTimeout": "5m",
"cooldownMultiplier": 2,
"cooldownResetTime": "60m"
}
},
"bugSnag": {
"releaseStage": "testnet"
Expand Down Expand Up @@ -487,7 +507,12 @@
],
"remoteWhitelist": ["127.0.0.1"],
"solutionDifficulty": 14,
"identityDifficulty": 12
"identityDifficulty": 12,
"churnPlugin": {
"cooldownBaseTimeout": "5m",
"cooldownMultiplier": 2,
"cooldownResetTime": "60m"
}
},
"bugSnag": {
"releaseStage": "mariner"
Expand Down
11 changes: 3 additions & 8 deletions modules/Blockchain/Ethereum/migrations/2_total_migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ module.exports = async (deployer, network, accounts) => {
console.log(`\t Holding contract address: \t\t${holding.address}`);
break;
case 'rinkeby':
await deployer.deploy(Hub, { gas: 6000000, from: accounts[0] })
await deployer.deploy(Hub)
.then((result) => {
hub = result;
});
Expand All @@ -281,21 +281,18 @@ module.exports = async (deployer, network, accounts) => {
profileStorage = await deployer.deploy(
ProfileStorage,
hub.address,
{ gas: 6000000, from: accounts[0] },
);
await hub.setContractAddress('ProfileStorage', profileStorage.address);

holdingStorage = await deployer.deploy(
HoldingStorage,
hub.address,
{ gas: 6000000, from: accounts[0] },
);
await hub.setContractAddress('HoldingStorage', holdingStorage.address);

litigationStorage = await deployer.deploy(
LitigationStorage,
hub.address,
{ gas: 6000000, from: accounts[0] },
);
await hub.setContractAddress('LitigationStorage', litigationStorage.address);

Expand All @@ -304,23 +301,21 @@ module.exports = async (deployer, network, accounts) => {

await hub.setContractAddress('Token', '0x98d9a611ad1b5761bdc1daac42c48e4d54cf5882');

profile = await deployer.deploy(Profile, hub.address, { gas: 7000000, from: accounts[0] });
profile = await deployer.deploy(Profile, hub.address);
await hub.setContractAddress('Profile', profile.address);

holding = await deployer.deploy(Holding, hub.address, { gas: 7000000, from: accounts[0] });
holding = await deployer.deploy(Holding, hub.address);
await hub.setContractAddress('Holding', holding.address);

litigation = await deployer.deploy(
Litigation,
hub.address,
{ gas: 7000000, from: accounts[0] },
);
await hub.setContractAddress('Litigation', litigation.address);

replacement = await deployer.deploy(
Replacement,
hub.address,
{ gas: 7000000, from: accounts[0] },
);
await hub.setContractAddress('Replacement', replacement.address);

Expand Down
8 changes: 4 additions & 4 deletions modules/Blockchain/Ethereum/truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
update: {
host: 'localhost', // Connect to geth on the specified
port: 8545,
provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/${process.env.RINKEBY_ACCESS_KEY}`),
provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/v3/${process.env.RINKEBY_ACCESS_KEY}`),
network_id: 4,
gas: 6000000, // Gas limit used for deploys
websockets: true,
Expand All @@ -71,17 +71,17 @@ module.exports = {
rinkeby: {
host: 'localhost', // Connect to geth on the specified
port: 8545,
provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/${process.env.RINKEBY_ACCESS_KEY}`),
provider: () => new HDWalletProvider(mnemonic, `https://rinkeby.infura.io/v3/${process.env.RINKEBY_ACCESS_KEY}`),
network_id: 4,
gas: 6000000, // Gas limit used for deploys
gas: 6500000, // Gas limit used for deploys
websockets: true,
skipDryRun: true,
},

live: {
host: 'localhost',
port: 8545,
provider: () => new HDWalletProvider(mnemonic, `https://mainnet.infura.io/${process.env.MAINNET_ACCESS_KEY}`),
provider: () => new HDWalletProvider(mnemonic, `https://mainnet.infura.io/v3/${process.env.MAINNET_ACCESS_KEY}`),
network_id: 1,
gas: 6000000, // Gas limit used for deploys
websockets: true,
Expand Down
5 changes: 5 additions & 0 deletions modules/RemoteControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ class RemoteControl {
async (bid) => {
const holding = await this._findHoldingByBid(bid);

if (holding == null || holding.data_set_id == null) {
this.log.debug('Failed to get holding data for for bid %s.', bid);
return;
}

const dataInfo = await Models.data_info.findOne({
where: {
data_set_id: holding.data_set_id,
Expand Down
33 changes: 19 additions & 14 deletions modules/command/dh/dh-offer-finalized-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ class DhOfferFinalizedCommand extends Command {
this.logger.important(`I've been chosen for offer ${offerId}.`);

await this.remoteControl.onCompletedBids();
const scheduledTime = (bid.holding_time_in_minutes * 60 * 1000) + (60 * 1000);
return {
commands: [
{
name: 'dhPayOutCommand',
delay: scheduledTime,
retries: 3,
transactional: false,
data: {
offerId,
viaAPI: false,

if (this.config.disableAutoPayouts !== true) {
const scheduledTime =
(bid.holding_time_in_minutes * 60 * 1000) + (60 * 1000);
return {
commands: [
{
name: 'dhPayOutCommand',
delay: scheduledTime,
retries: 3,
transactional: false,
data: {
offerId,
viaAPI: false,
},
},
},
],
};
],
};
}
return Command.empty();
}

bid.status = 'NOT_CHOSEN';
Expand Down
13 changes: 7 additions & 6 deletions modules/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ require('winston-daily-rotate-file');
// eslint-disable-next-line
require('winston-papertrail').Papertrail;
require('winston-loggly-bulk');
const util = require('util');

const runtimeConfigJson = require('../config/config.json')[process.env.NODE_ENV];

const colors = require('colors/safe');
Expand Down Expand Up @@ -121,13 +123,12 @@ class Logger {

// Extend logger object to properly log 'Error' types
const origLog = logger.log;
logger.log = (level, msg) => {
if (msg instanceof Error) {
// eslint-disable-next-line prefer-rest-params
const args = Array.prototype.slice.call(arguments);
args[1] = msg.stack;
origLog.apply(logger, args);
logger.log = (level, ...rest) => {
if (rest[0] instanceof Error) {
rest[1] = rest[0].stack;
origLog.apply(logger, rest);
} else {
const msg = util.format(...rest);
const transformed = Logger.transformLog(level, msg);
if (!transformed) {
return;
Expand Down
27 changes: 25 additions & 2 deletions modules/network/kademlia/kademlia.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,29 @@ class Kademlia {
}));
this.log.info('Hashcash initialised');

this.node.blacklist = this.node.plugin(kadence.churnfilter({
cooldownBaseTimeout: this.config.network.churnPlugin.cooldownBaseTimeout,
cooldownMultiplier: this.config.network.churnPlugin.cooldownMultiplier,
cooldownResetTime: this.config.network.churnPlugin.cooldownResetTime,
}));
this.log.info('Churn filter initialised');

// Patch Churn to ignore all outgoing requests towards blacklisted contacts.
const send = this.node.send.bind(this.node);
this.node.send = function (method, params, target, handler) {
try {
const contactId = target[0].toString('hex');
if (this.node.blacklist.hasBlock(contactId)) {
this.log.debug('Trying to send to blacklisted contact: %s.', contactId);
return handler(Error('Contact blacklisted.'));
}
send(method, params, target, handler);
} catch (e) {
this.log.error('Failed to check for blacklist');
handler(Error('Failed to check for blacklist.'));
}
}.bind(this);

if (this.config.onion_enabled) {
this.enableOnion();
}
Expand All @@ -254,8 +277,8 @@ class Kademlia {

// Use verbose logging if enabled
if (process.env.LOGS_LEVEL_DEBUG) {
this.node.rpc.deserializer.append(new IncomingMessage(this.log));
this.node.rpc.serializer.prepend(new OutgoingMessage(this.log));
this.node.rpc.deserializer.append(() => new IncomingMessage(this.log));
this.node.rpc.serializer.prepend(() => new OutgoingMessage(this.log));
}
// Cast network nodes to an array
if (typeof this.config.network.bootstraps === 'string') {
Expand Down
Loading

0 comments on commit 48c532c

Please sign in to comment.