mirror of https://github.com/embarklabs/embark.git
Merge pull request #1002 from embark-framework/feat/warn-old-blockchain-client
Warn re: unsupported blockchain client
This commit is contained in:
commit
e10792436e
|
@ -305,6 +305,13 @@ Blockchain.prototype.isClientInstalled = function (callback) {
|
||||||
if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) {
|
if (err || !stdout || stderr.indexOf("not found") >= 0 || stdout.indexOf("not found") >= 0) {
|
||||||
return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath());
|
return callback(__('Ethereum client bin not found:') + ' ' + this.client.getBinaryPath());
|
||||||
}
|
}
|
||||||
|
const parsedVersion = this.client.parseVersion(stdout);
|
||||||
|
const supported = this.client.isSupportedVersion(parsedVersion);
|
||||||
|
if (supported === undefined) {
|
||||||
|
this.logger.error((__('WARNING! Ethereum client version could not be determined or compared with version range') + ' ' + this.client.versSupported + __(', for best results please use a supported version')).yellow);
|
||||||
|
} else if (!supported) {
|
||||||
|
this.logger.error((__('WARNING! Ethereum client version unsupported, for best results please use a version in range') + ' ' + this.client.versSupported).yellow);
|
||||||
|
}
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -461,6 +468,7 @@ var BlockchainClient = function(userConfig, clientName, env, onReadyCallback, on
|
||||||
userConfig.env = env;
|
userConfig.env = env;
|
||||||
userConfig.onReadyCallback = onReadyCallback;
|
userConfig.onReadyCallback = onReadyCallback;
|
||||||
userConfig.onExitCallback = onExitCallback;
|
userConfig.onExitCallback = onExitCallback;
|
||||||
|
userConfig.logger = logger;
|
||||||
return new Blockchain(userConfig, clientClass);
|
return new Blockchain(userConfig, clientClass);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ class BlockchainProcess extends ProcessWrapper {
|
||||||
this.client,
|
this.client,
|
||||||
this.env,
|
this.env,
|
||||||
this.blockchainReady.bind(this),
|
this.blockchainReady.bind(this),
|
||||||
this.blockchainExit.bind(this)
|
this.blockchainExit.bind(this),
|
||||||
|
console
|
||||||
);
|
);
|
||||||
|
|
||||||
this.blockchain.run();
|
this.blockchain.run();
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const GethMiner = require('./miner');
|
const GethMiner = require('./miner');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const semver = require('semver');
|
||||||
|
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
"BIN": "geth",
|
"BIN": "geth",
|
||||||
|
"VERSIONS_SUPPORTED": ">=1.8.14",
|
||||||
"NETWORK_TYPE": "custom",
|
"NETWORK_TYPE": "custom",
|
||||||
"NETWORK_ID": 1337,
|
"NETWORK_ID": 1337,
|
||||||
"RPC_API": ['eth', 'web3', 'net', 'debug', 'personal'],
|
"RPC_API": ['eth', 'web3', 'net', 'debug', 'personal'],
|
||||||
|
@ -26,6 +28,7 @@ class GethClient {
|
||||||
this.name = "geth";
|
this.name = "geth";
|
||||||
this.prettyName = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
this.prettyName = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||||
this.bin = this.config.ethereumClientBin || DEFAULTS.BIN;
|
this.bin = this.config.ethereumClientBin || DEFAULTS.BIN;
|
||||||
|
this.versSupported = DEFAULTS.VERSIONS_SUPPORTED;
|
||||||
this.httpReady = false;
|
this.httpReady = false;
|
||||||
this.wsReady = !this.config.wsRPC;
|
this.wsReady = !this.config.wsRPC;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +95,30 @@ class GethClient {
|
||||||
return this.bin + " version";
|
return this.bin + " version";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseVersion(rawVersionOutput) {
|
||||||
|
let parsed;
|
||||||
|
const match = rawVersionOutput.match(/Version: (.*)/);
|
||||||
|
if (match) {
|
||||||
|
parsed = match[1].trim();
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSupportedVersion(parsedVersion) {
|
||||||
|
let test;
|
||||||
|
try {
|
||||||
|
let v = semver(parsedVersion);
|
||||||
|
v = `${v.major}.${v.minor}.${v.patch}`;
|
||||||
|
test = semver.Range(this.versSupported).test(semver(v));
|
||||||
|
if (typeof test !== 'boolean') {
|
||||||
|
test = undefined;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// eslint-disable-next-line no-unsafe-finally
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
determineNetworkType(config) {
|
determineNetworkType(config) {
|
||||||
let cmd;
|
let cmd;
|
||||||
if (config.networkType === 'testnet') {
|
if (config.networkType === 'testnet') {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const fs = require('../../core/fs.js');
|
const fs = require('../../core/fs.js');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const semver = require('semver');
|
||||||
|
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
"BIN": "parity",
|
"BIN": "parity",
|
||||||
|
"VERSIONS_SUPPORTED": ">=2.0.0",
|
||||||
"NETWORK_TYPE": "dev",
|
"NETWORK_TYPE": "dev",
|
||||||
"NETWORK_ID": 17,
|
"NETWORK_ID": 17,
|
||||||
"RPC_API": ["web3", "eth", "pubsub", "net", "parity", "private", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub"],
|
"RPC_API": ["web3", "eth", "pubsub", "net", "parity", "private", "parity_pubsub", "traces", "rpc", "shh", "shh_pubsub"],
|
||||||
|
@ -33,6 +35,7 @@ class ParityClient {
|
||||||
this.name = "parity";
|
this.name = "parity";
|
||||||
this.prettyName = "Parity-Ethereum (https://github.com/paritytech/parity-ethereum)";
|
this.prettyName = "Parity-Ethereum (https://github.com/paritytech/parity-ethereum)";
|
||||||
this.bin = this.config.ethereumClientBin || DEFAULTS.BIN;
|
this.bin = this.config.ethereumClientBin || DEFAULTS.BIN;
|
||||||
|
this.versSupported = DEFAULTS.VERSIONS_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
isReady(data) {
|
isReady(data) {
|
||||||
|
@ -113,6 +116,30 @@ class ParityClient {
|
||||||
return this.bin + " --version";
|
return this.bin + " --version";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseVersion(rawVersionOutput) {
|
||||||
|
let parsed;
|
||||||
|
const match = rawVersionOutput.match(/version Parity-Ethereum\/(.*?)\//);
|
||||||
|
if (match) {
|
||||||
|
parsed = match[1].trim();
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSupportedVersion(parsedVersion) {
|
||||||
|
let test;
|
||||||
|
try {
|
||||||
|
let v = semver(parsedVersion);
|
||||||
|
v = `${v.major}.${v.minor}.${v.patch}`;
|
||||||
|
test = semver.Range(this.versSupported).test(semver(v));
|
||||||
|
if (typeof test !== 'boolean') {
|
||||||
|
test = undefined;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// eslint-disable-next-line no-unsafe-finally
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
determineNetworkType(config) {
|
determineNetworkType(config) {
|
||||||
if (this.isDev) {
|
if (this.isDev) {
|
||||||
return "--chain=dev";
|
return "--chain=dev";
|
||||||
|
|
Loading…
Reference in New Issue