Skip to content

Commit

Permalink
Merge branch 'master' into ibft_vtc
Browse files Browse the repository at this point in the history
  • Loading branch information
rain-on authored Feb 20, 2019
2 parents fbc87ba + 9584291 commit eb10f9a
Show file tree
Hide file tree
Showing 66 changed files with 1,265 additions and 557 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ public interface NodeConfiguration {
Optional<EthNetworkConfig> ethNetworkConfig();

void ethNetworkConfig(Optional<EthNetworkConfig> ethNetworkConfig);

boolean isBootnode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public class PantheonNode implements Node, NodeConfiguration, RunnableNode, Auto
private final GenesisConfigProvider genesisConfigProvider;
private final boolean devMode;
private final boolean discoveryEnabled;
private final boolean isBootnode;

private List<String> bootnodes = new ArrayList<>();
private JsonRequestFactories jsonRequestFactories;
Expand All @@ -105,7 +106,8 @@ public PantheonNode(
final GenesisConfigProvider genesisConfigProvider,
final int p2pPort,
final Boolean p2pEnabled,
final boolean discoveryEnabled)
final boolean discoveryEnabled,
final boolean isBootnode)
throws IOException {
this.homeDirectory = Files.createTempDirectory("acctest");
this.keyPair = KeyPairUtil.loadKeyPair(homeDirectory);
Expand All @@ -120,6 +122,7 @@ public PantheonNode(
this.devMode = devMode;
this.p2pEnabled = p2pEnabled;
this.discoveryEnabled = discoveryEnabled;
this.isBootnode = isBootnode;
LOG.info("Created PantheonNode {}", this.toString());
}

Expand Down Expand Up @@ -429,6 +432,11 @@ public boolean isDiscoveryEnabled() {
return discoveryEnabled;
}

@Override
public boolean isBootnode() {
return isBootnode;
}

Optional<PermissioningConfiguration> getPermissioningConfiguration() {
return permissioningConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ public void start(final List<? extends RunnableNode> nodes) {

for (final RunnableNode node : nodes) {
this.nodes.put(node.getName(), node);
bootNodes.add(node.getConfiguration().enodeUrl());
if (node.getConfiguration().isBootnode()) {
bootNodes.add(node.getConfiguration().enodeUrl());
}
}

for (final RunnableNode node : nodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PantheonFactoryConfiguration {
private final GenesisConfigProvider genesisConfigProvider;
private final Boolean p2pEnabled;
private final boolean discoveryEnabled;
private final boolean isBootnode;

PantheonFactoryConfiguration(
final String name,
Expand All @@ -44,7 +45,8 @@ class PantheonFactoryConfiguration {
final boolean devMode,
final GenesisConfigProvider genesisConfigProvider,
final Boolean p2pEnabled,
final boolean discoveryEnabled) {
final boolean discoveryEnabled,
final boolean isBootnode) {
this.name = name;
this.miningParameters = miningParameters;
this.jsonRpcConfiguration = jsonRpcConfiguration;
Expand All @@ -55,6 +57,7 @@ class PantheonFactoryConfiguration {
this.genesisConfigProvider = genesisConfigProvider;
this.p2pEnabled = p2pEnabled;
this.discoveryEnabled = discoveryEnabled;
this.isBootnode = isBootnode;
}

public String getName() {
Expand Down Expand Up @@ -96,4 +99,8 @@ public GenesisConfigProvider getGenesisConfigProvider() {
public Boolean getP2pEnabled() {
return p2pEnabled;
}

public boolean isBootnode() {
return isBootnode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.Optional;

public class PantheonFactoryConfigurationBuilder {
Expand All @@ -39,6 +40,7 @@ public class PantheonFactoryConfigurationBuilder {
private GenesisConfigProvider genesisConfigProvider = ignore -> Optional.empty();
private Boolean p2pEnabled = true;
private boolean discoveryEnabled = true;
private boolean isBootnode = true;

public PantheonFactoryConfigurationBuilder setName(final String name) {
this.name = name;
Expand Down Expand Up @@ -99,6 +101,7 @@ public PantheonFactoryConfigurationBuilder webSocketEnabled() {
final WebSocketConfiguration config = WebSocketConfiguration.createDefault();
config.setEnabled(true);
config.setPort(0);
config.setHostsWhitelist(Collections.singleton("*"));

this.webSocketConfiguration = config;
return this;
Expand Down Expand Up @@ -144,6 +147,11 @@ public PantheonFactoryConfigurationBuilder setDiscoveryEnabled(final boolean dis
return this;
}

public PantheonFactoryConfigurationBuilder setIsBootnode(final boolean isBootnode) {
this.isBootnode = isBootnode;
return this;
}

public PantheonFactoryConfiguration build() {
return new PantheonFactoryConfiguration(
name,
Expand All @@ -155,6 +163,7 @@ public PantheonFactoryConfiguration build() {
devMode,
genesisConfigProvider,
p2pEnabled,
discoveryEnabled);
discoveryEnabled,
isBootnode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ private PantheonNode create(final PantheonFactoryConfiguration config) throws IO
config.getGenesisConfigProvider(),
serverSocket.getLocalPort(),
config.getP2pEnabled(),
config.isDiscoveryEnabled());
config.isDiscoveryEnabled(),
config.isBootnode());
serverSocket.close();

return node;
Expand Down Expand Up @@ -104,6 +105,16 @@ public PantheonNode createArchiveNode(final String name) throws IOException {
.build());
}

public PantheonNode createNonBootnodeArchiveNode(final String name) throws IOException {
return create(
new PantheonFactoryConfigurationBuilder()
.setName(name)
.jsonRpcEnabled()
.webSocketEnabled()
.setIsBootnode(false)
.build());
}

public PantheonNode createArchiveNodeWithDiscoveryDisabledAndAdmin(final String name)
throws IOException {
return create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void setUp() throws Exception {

permissionedCluster = new Cluster(clusterConfiguration, net);
forbiddenNode = pantheon.createArchiveNode("forbidden-node");
allowedNode = pantheon.createArchiveNode("allowed-node");
allowedNode = pantheon.createNonBootnodeArchiveNode("allowed-node");
permissionedNode =
pantheon.createNodeWithNodesWhitelist(
"permissioned-node", Collections.singletonList(getEnodeURI(allowedNode)));
Expand Down
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,21 @@ run {
}

startScripts {

def shortenWindowsClasspath = { line ->
line = line.replaceAll(/^set CLASSPATH=.*$/, "set CLASSPATH=%APP_HOME%/lib/*")
}

doLast {
unixScript.text = unixScript.text.replace('PANTHEON_HOME', '\$APP_HOME')
windowsScript.text = windowsScript.text.replace('PANTHEON_HOME', '%~dp0..')

// Prevent the error originating from the 8191 chars limit on Windows
windowsScript.text =
windowsScript
.readLines()
.collect(shortenWindowsClasspath)
.join('\r\n')
}
}

Expand Down
8 changes: 4 additions & 4 deletions docs/Configuring-Pantheon/NetworkID-And-ChainID.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ same and are specified in the genesis file.
The network ID and chain ID are automatically defined by Pantheon when connecting to networks specified
using the [`--network`](../Reference/Pantheon-CLI-Syntax.md#network) option:

- **MainNet:** chain-id ==1==, network-id ==1==
- **Rinkeby:** chain-id ==4==, network-id ==4==
- **Ropsten:** chain-id ==3==, network-id ==3==
- **Dev:** chain-id ==2018==, network-id ==2018==
- **MainNet:** chain-id 1, network-id 1
- **Rinkeby:** chain-id 4, network-id 4
- **Ropsten:** chain-id 3, network-id 3
- **Dev:** chain-id 2018, network-id 2018

When using the [`--network=dev`](../Reference/Pantheon-CLI-Syntax.md#network) or
[`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file) options, you can override the
Expand Down
4 changes: 2 additions & 2 deletions docs/Configuring-Pantheon/Networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ If connections are not getting through the firewalls, ensure the peer discovery
## Peer Discovery Port

The [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and [`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port)
options specifies the host and port on which P2P peer discovery listens. The default is ==127.0.0.1==
for host and ==30303== for port.
options specifies the host and port on which P2P peer discovery listens. The default is `127.0.0.1`
for host and `30303` for port.

## Limiting Peers

Expand Down
3 changes: 0 additions & 3 deletions docs/Consensus-Protocols/Comparing-PoA.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Pantheon implements the Clique and IBFT 2.0 Proof of Authority consensus protoco
consensus protocols are used when participants are known to each other and there is a level of trust between them.
For example, in a permissioned consortium network.

!!! note
IBFT 2.0 is under development and will be available in v1.0.

Proof of Authority consensus protocols allow faster block times and have a much greater throughput of transactions
than the Ethash Proof of Work consensus protocol used on the Ethereum MainNet.

Expand Down
3 changes: 0 additions & 3 deletions docs/Consensus-Protocols/IBFT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ description: Pantheon IBFT 2.0 Proof-of-Authority (PoA) consensus protocol imple

# IBFT 2.0

!!! note
IBFT 2.0 is under development and will be available in v1.0.

Pantheon implements the IBFT 2.0 Proof-of-Authority (PoA) consensus protocol. IBFT 2.0 can be used for private networks.

In IBFT 2.0 networks, transactions and blocks are validated by approved accounts, known as validators.
Expand Down
5 changes: 1 addition & 4 deletions docs/Consensus-Protocols/Overview-Consensus.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ Pantheon implements a number of consensus protocols:

* [Clique](Clique.md) (Proof of Authority)

* [IBFT 2.0](IBFT.md) (Proof of Authority)

!!! note
IBFT 2.0 is under development and will be available in v1.0.
* [IBFT 2.0](IBFT.md) (Proof of Authority)

The genesis file specifies the consensus protocol for a chain `config`:

Expand Down
Loading

0 comments on commit eb10f9a

Please sign in to comment.