|
|
@ -103,6 +103,7 @@ import tech.pegasys.pantheon.services.PantheonEventsImpl; |
|
|
|
import tech.pegasys.pantheon.services.PantheonPluginContextImpl; |
|
|
|
import tech.pegasys.pantheon.services.PantheonPluginContextImpl; |
|
|
|
import tech.pegasys.pantheon.services.PicoCLIOptionsImpl; |
|
|
|
import tech.pegasys.pantheon.services.PicoCLIOptionsImpl; |
|
|
|
import tech.pegasys.pantheon.services.StorageServiceImpl; |
|
|
|
import tech.pegasys.pantheon.services.StorageServiceImpl; |
|
|
|
|
|
|
|
import tech.pegasys.pantheon.util.NetworkUtility; |
|
|
|
import tech.pegasys.pantheon.util.PermissioningConfigurationValidator; |
|
|
|
import tech.pegasys.pantheon.util.PermissioningConfigurationValidator; |
|
|
|
import tech.pegasys.pantheon.util.bytes.BytesValue; |
|
|
|
import tech.pegasys.pantheon.util.bytes.BytesValue; |
|
|
|
import tech.pegasys.pantheon.util.number.Fraction; |
|
|
|
import tech.pegasys.pantheon.util.number.Fraction; |
|
|
@ -114,7 +115,9 @@ import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.net.InetAddress; |
|
|
|
import java.net.InetAddress; |
|
|
|
|
|
|
|
import java.net.SocketException; |
|
|
|
import java.net.URI; |
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.net.UnknownHostException; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.time.Clock; |
|
|
|
import java.time.Clock; |
|
|
@ -322,6 +325,14 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
arity = "1") |
|
|
|
arity = "1") |
|
|
|
private String p2pHost = autoDiscoverDefaultIP().getHostAddress(); |
|
|
|
private String p2pHost = autoDiscoverDefaultIP().getHostAddress(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Option( |
|
|
|
|
|
|
|
names = {"--p2p-interface"}, |
|
|
|
|
|
|
|
paramLabel = MANDATORY_HOST_FORMAT_HELP, |
|
|
|
|
|
|
|
description = |
|
|
|
|
|
|
|
"The network interface address on which this node listens for p2p communication (default: ${DEFAULT-VALUE})", |
|
|
|
|
|
|
|
arity = "1") |
|
|
|
|
|
|
|
private String p2pInterface = NetworkUtility.INADDR_ANY; |
|
|
|
|
|
|
|
|
|
|
|
@Option( |
|
|
|
@Option( |
|
|
|
names = {"--p2p-port"}, |
|
|
|
names = {"--p2p-port"}, |
|
|
|
paramLabel = MANDATORY_PORT_FORMAT_HELP, |
|
|
|
paramLabel = MANDATORY_PORT_FORMAT_HELP, |
|
|
@ -750,7 +761,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
try { |
|
|
|
try { |
|
|
|
prepareLogging(); |
|
|
|
prepareLogging(); |
|
|
|
logger.info("Starting Pantheon version: {}", PantheonInfo.version()); |
|
|
|
logger.info("Starting Pantheon version: {}", PantheonInfo.version()); |
|
|
|
checkOptions().configure().controller().startPlugins().startSynchronization(); |
|
|
|
validateOptions().configure().controller().startPlugins().startSynchronization(); |
|
|
|
} catch (final Exception e) { |
|
|
|
} catch (final Exception e) { |
|
|
|
throw new ParameterException(this.commandLine, e.getMessage(), e); |
|
|
|
throw new ParameterException(this.commandLine, e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
@ -862,6 +873,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
ethNetworkConfig, |
|
|
|
ethNetworkConfig, |
|
|
|
maxPeers, |
|
|
|
maxPeers, |
|
|
|
p2pHost, |
|
|
|
p2pHost, |
|
|
|
|
|
|
|
p2pInterface, |
|
|
|
p2pPort, |
|
|
|
p2pPort, |
|
|
|
graphQLConfiguration, |
|
|
|
graphQLConfiguration, |
|
|
|
jsonRpcConfiguration, |
|
|
|
jsonRpcConfiguration, |
|
|
@ -891,8 +903,38 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private PantheonCommand checkOptions() { |
|
|
|
private PantheonCommand validateOptions() { |
|
|
|
// Check that P2P options are able to work or send an error
|
|
|
|
issueOptionWarnings(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
validateP2PInterface(p2pInterface); |
|
|
|
|
|
|
|
validateMiningParams(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validateMiningParams() { |
|
|
|
|
|
|
|
// noinspection ConstantConditions
|
|
|
|
|
|
|
|
if (isMiningEnabled && coinbase == null) { |
|
|
|
|
|
|
|
throw new ParameterException( |
|
|
|
|
|
|
|
this.commandLine, |
|
|
|
|
|
|
|
"Unable to mine without a valid coinbase. Either disable mining (remove --miner-enabled)" |
|
|
|
|
|
|
|
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void validateP2PInterface(final String p2pInterface) { |
|
|
|
|
|
|
|
final String failMessage = "The provided --p2p-interface is not available: " + p2pInterface; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
if (!NetworkUtility.isNetworkInterfaceAvailable(p2pInterface)) { |
|
|
|
|
|
|
|
throw new ParameterException(commandLine, failMessage); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (UnknownHostException | SocketException e) { |
|
|
|
|
|
|
|
throw new ParameterException(commandLine, failMessage, e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void issueOptionWarnings() { |
|
|
|
|
|
|
|
// Check that P2P options are able to work
|
|
|
|
checkOptionDependencies( |
|
|
|
checkOptionDependencies( |
|
|
|
logger, |
|
|
|
logger, |
|
|
|
commandLine, |
|
|
|
commandLine, |
|
|
@ -904,8 +946,11 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
"--max-peers", |
|
|
|
"--max-peers", |
|
|
|
"--banned-node-id", |
|
|
|
"--banned-node-id", |
|
|
|
"--banned-node-ids", |
|
|
|
"--banned-node-ids", |
|
|
|
|
|
|
|
"--p2p-host", |
|
|
|
|
|
|
|
"--p2p-interface", |
|
|
|
|
|
|
|
"--p2p-port", |
|
|
|
"--remote-connections-max-percentage")); |
|
|
|
"--remote-connections-max-percentage")); |
|
|
|
// Check that mining options are able to work or send an error
|
|
|
|
// Check that mining options are able to work
|
|
|
|
checkOptionDependencies( |
|
|
|
checkOptionDependencies( |
|
|
|
logger, |
|
|
|
logger, |
|
|
|
commandLine, |
|
|
|
commandLine, |
|
|
@ -926,15 +971,6 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
"--pruning-enabled", |
|
|
|
"--pruning-enabled", |
|
|
|
!isPruningEnabled, |
|
|
|
!isPruningEnabled, |
|
|
|
asList("--pruning-block-confirmations", "--pruning-blocks-retained")); |
|
|
|
asList("--pruning-block-confirmations", "--pruning-blocks-retained")); |
|
|
|
|
|
|
|
|
|
|
|
// noinspection ConstantConditions
|
|
|
|
|
|
|
|
if (isMiningEnabled && coinbase == null) { |
|
|
|
|
|
|
|
throw new ParameterException( |
|
|
|
|
|
|
|
this.commandLine, |
|
|
|
|
|
|
|
"Unable to mine without a valid coinbase. Either disable mining (remove --miner-enabled)" |
|
|
|
|
|
|
|
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private PantheonCommand configure() throws Exception { |
|
|
|
private PantheonCommand configure() throws Exception { |
|
|
@ -1302,6 +1338,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
final EthNetworkConfig ethNetworkConfig, |
|
|
|
final EthNetworkConfig ethNetworkConfig, |
|
|
|
final int maxPeers, |
|
|
|
final int maxPeers, |
|
|
|
final String p2pAdvertisedHost, |
|
|
|
final String p2pAdvertisedHost, |
|
|
|
|
|
|
|
final String p2pListenInterface, |
|
|
|
final int p2pListenPort, |
|
|
|
final int p2pListenPort, |
|
|
|
final GraphQLConfiguration graphQLConfiguration, |
|
|
|
final GraphQLConfiguration graphQLConfiguration, |
|
|
|
final JsonRpcConfiguration jsonRpcConfiguration, |
|
|
|
final JsonRpcConfiguration jsonRpcConfiguration, |
|
|
@ -1324,6 +1361,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable { |
|
|
|
.discovery(peerDiscoveryEnabled) |
|
|
|
.discovery(peerDiscoveryEnabled) |
|
|
|
.ethNetworkConfig(ethNetworkConfig) |
|
|
|
.ethNetworkConfig(ethNetworkConfig) |
|
|
|
.p2pAdvertisedHost(p2pAdvertisedHost) |
|
|
|
.p2pAdvertisedHost(p2pAdvertisedHost) |
|
|
|
|
|
|
|
.p2pListenInterface(p2pListenInterface) |
|
|
|
.p2pListenPort(p2pListenPort) |
|
|
|
.p2pListenPort(p2pListenPort) |
|
|
|
.maxPeers(maxPeers) |
|
|
|
.maxPeers(maxPeers) |
|
|
|
.limitRemoteWireConnectionsEnabled(isLimitRemoteWireConnectionsEnabled) |
|
|
|
.limitRemoteWireConnectionsEnabled(isLimitRemoteWireConnectionsEnabled) |
|
|
|