Nc 2026 network option (#645)

fixes NC-2026 adds a `--network` option instead of separated options

Networks are now defined using a `--network` option that takes the case insensitive
name of an enum values as input :   MAINNET, RINKEBY, ROPSTEN, GOERLI, DEV

These presets are a set of network-id, genesis file and boonodes list.

If the `--genesis-file` is provided with a valid JSON genesis file,
Pantheon uses it instead of the default network. An empty bootnodes list is then
the default value and network id is the chain id found in the genesis file.

`--network-id` and `--bootnodes` options can override these defaults.

You can of course also override the `--network-id` and `--bootnodes` for a
predefined known network (using `--network`).

User have no reason to set `--network` and `--genesis-file` options at the same
time that would lead to misunderstandings so we raise an error to prevent both
options to be defined at the same time on the command line.

Also fixes NC-2189 renaming --private-genesis-file to --genesis-file

Updates a lot of doc according to the options changes

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Nicolas MASSART 6 years ago committed by GitHub
parent 5f0434e9e5
commit 2ef0694c6f
  1. 7
      acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/ThreadPantheonNodeRunner.java
  2. 12
      docs/Configuring-Pantheon/Accounts-for-Testing.md
  3. 27
      docs/Configuring-Pantheon/Logging.md
  4. 18
      docs/Configuring-Pantheon/NetworkID-And-ChainID.md
  5. 4
      docs/Configuring-Pantheon/Networking.md
  6. 2
      docs/Configuring-Pantheon/Passing-JVM-Options.md
  7. 24
      docs/Configuring-Pantheon/Testing-Developing-Nodes.md
  8. 20
      docs/Configuring-Pantheon/Using-Configuration-File.md
  9. 33
      docs/Consensus-Protocols/Clique.md
  10. 6
      docs/Consensus-Protocols/IBFT.md
  11. 37
      docs/Getting-Started/Run-Docker-Image.md
  12. 49
      docs/Getting-Started/Starting-Pantheon.md
  13. 4
      docs/Reference/JSON-RPC-API-Methods.md
  14. 179
      docs/Reference/Pantheon-CLI-Syntax.md
  15. 4
      docs/Reference/Using-JSON-RPC-API.md
  16. 34
      docs/Tutorials/Create-Private-Network.md
  17. 4
      docs/Using-Pantheon/Debugging.md
  18. 2
      pantheon/src/main/java/tech/pegasys/pantheon/cli/DefaultCommandValues.java
  19. 29
      pantheon/src/main/java/tech/pegasys/pantheon/cli/EthNetworkConfig.java
  20. 4
      pantheon/src/main/java/tech/pegasys/pantheon/cli/NetworkName.java
  21. 160
      pantheon/src/main/java/tech/pegasys/pantheon/cli/PantheonCommand.java
  22. 9
      pantheon/src/main/java/tech/pegasys/pantheon/cli/StandaloneCommand.java
  23. 186
      pantheon/src/test/java/tech/pegasys/pantheon/cli/PantheonCommandTest.java
  24. 3
      pantheon/src/test/resources/complete_config.toml
  25. 9
      pantheon/src/test/resources/everything_config.toml

@ -12,7 +12,7 @@
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.node;
import static tech.pegasys.pantheon.cli.EthNetworkConfig.mainnet;
import static tech.pegasys.pantheon.cli.NetworkName.MAINNET;
import tech.pegasys.pantheon.Runner;
import tech.pegasys.pantheon.RunnerBuilder;
@ -55,7 +55,10 @@ public class ThreadPantheonNodeRunner implements PantheonNodeRunner {
final PantheonControllerBuilder builder = new PantheonControllerBuilder();
final EthNetworkConfig ethNetworkConfig =
node.ethNetworkConfig()
.orElse(new EthNetworkConfig.Builder(mainnet()).setNetworkId(NETWORK_ID).build());
.orElse(
new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(MAINNET))
.setNetworkId(NETWORK_ID)
.build());
final PantheonController<?> pantheonController;
try {
pantheonController =

@ -3,11 +3,13 @@ description: Ethereum accounts used for testing only on private network
# Accounts for Testing
You can use existing accounts for testing by including them in the genesis file for a private network. Alternatively, Pantheon provides predefined accounts in development mode.
You can use existing accounts for testing by including them in the genesis file for a private network.
Alternatively, Pantheon provides predefined accounts in development mode.
## Development Mode
When you start Pantheon with the [`--dev-mode`](/Reference/Pantheon-CLI-Syntax/#dev-mode) command line option, the `dev.json` genesis file is used by default.
When you start Pantheon with the [`--network=dev`](../Reference/Pantheon-CLI-Syntax.md#network)
command line option, the `dev.json` genesis file is used by default.
The `dev.json` genesis file defines the accounts below that can be used for testing.
@ -15,6 +17,8 @@ You can use existing accounts for testing by including them in the genesis file
## Genesis File
To use existing test accounts, specify the accounts and balances in a genesis file for your test network. For an example of defining accounts in the genesis file, refer to [`dev.json`](https://github.com/PegaSysEng/pantheon/blob/master/config/src/main/resources/dev.json).
To use existing test accounts, specify the accounts and balances in a genesis file for your test network.
For an example of defining accounts in the genesis file, refer to [`dev.json`](https://github.com/PegaSysEng/pantheon/blob/master/config/src/main/resources/dev.json).
Use the [`--genesis`](/Reference/Pantheon-CLI-Syntax/#genesis) command line option to start Pantheon with the genesis file defining the existing accounts.
Use the [`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file) command line option to
start Pantheon with the genesis file defining the existing accounts.

@ -15,11 +15,16 @@ Pantheon uses Log4J2 for logging. There are two methods to configure logging beh
## Basic Log Level Setting
Use the [`--logging`](../Reference/Pantheon-CLI-Syntax.md#logging) command line option to specify the logging verbosity. The [`--logging`](../Reference/Pantheon-CLI-Syntax.md#logging) option changes the volume of events displayed in the log.
Use the [`--logging`](../Reference/Pantheon-CLI-Syntax.md#logging) command line option to specify
the logging verbosity. The [`--logging`](../Reference/Pantheon-CLI-Syntax.md#logging) option changes
the volume of events displayed in the log.
## Advanced Custom Logging
You can provide your own logging configuration using the standard Log4J2 configuration mechanisms. For example, the following Log4J2 configuration is the same as the [default configuration](https://github.com/PegaSysEng/pantheon/blob/master/pantheon/src/main/resources/log4j2.xml) except logging of stack traces for exceptions is excluded.
You can provide your own logging configuration using the standard Log4J2 configuration mechanisms.
For example, the following Log4J2 configuration is the same as the
[default configuration](https://github.com/PegaSysEng/pantheon/blob/master/pantheon/src/main/resources/log4j2.xml)
except logging of stack traces for exceptions is excluded.
```xml tab="log4j2.xml"
<?xml version="1.0" encoding="UTF-8"?>
@ -41,12 +46,18 @@ You can provide your own logging configuration using the standard Log4J2 configu
</Configuration>
```
To use your custom configuration, set the environment variable `LOG4J_CONFIGURATION_FILE` to the location of your configuration file.
To use your custom configuration, set the environment variable `LOG4J_CONFIGURATION_FILE` to the
location of your configuration file.
If you have more specific requirements, you can create your own [log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
If you have more specific requirements, you can create your own
[log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
For Bash-based executions, you can set the variable for only the scope of the program execution by setting it before starting Pantheon. For example, to set the debug logging and start Pantheon connected to the Rinkeby testnet:
For Bash-based executions, you can set the variable for only the scope of the program execution by
setting it before starting Pantheon.
```bash
$ LOG4J_CONFIGURATION_FILE=./debug.xml bin/pantheon --rinkeby
```
!!!example
To set the debug logging and start Pantheon connected to the Rinkeby testnet:
```bash
$ LOG4J_CONFIGURATION_FILE=./debug.xml bin/pantheon --network=rinkeby
```

@ -3,11 +3,21 @@ description: Pantheon network ID and chain ID implementation
# Network ID and Chain ID
Ethereum networks have a **network ID** and a **chain ID**. The network ID is specified using the [`--network-id`](../Reference/Pantheon-CLI-Syntax.md#network-id) option and the chain ID is specified in the genesis file.
Ethereum networks have a **network ID** and a **chain ID**. The network ID can be specified using the
[`--network-id`](../Reference/Pantheon-CLI-Syntax.md#network-id) option and the chain ID is specified
in the genesis file.
For most networks including mainnet and the public testnets, the network ID and the chain ID are the same.
For most networks including MainNet and the public testnets, the network ID and the chain ID are the
same and Pantheon network id default values are defined according to the genesis chain id value.
The network ID is automatically set by Pantheon when connecting to the Ethereum mainnet ==1==, Rinkeby ==4==, and Ropsten ==3==.
The network ID is automatically set by Pantheon to the chain ID when connecting to the Ethereum networks:
When using the [`--dev-mode`](../Reference/Pantheon-CLI-Syntax.md#dev-mode) or [`--genesis`](../Reference/Pantheon-CLI-Syntax.md#genesis) options, specify the network ID using the [`--network-id`](../Reference/Pantheon-CLI-Syntax.md#network-id) 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==
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
network ID using the [`--network-id`](../Reference/Pantheon-CLI-Syntax.md#network-id) option.

@ -20,7 +20,9 @@ If connections are not getting through the firewalls, ensure the peer discovery
## Peer Discovery Port
The [`--p2p-listen`](../Reference/Pantheon-CLI-Syntax.md#p2p-listen) option specifies the host and port on which P2P peer discovery listens. The default is ==127.0.0.1:30303==.
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.
## Limiting Peers

@ -12,5 +12,5 @@ For Bash-based executions, you can set the variable for only the scope of the pr
!!! example
```bash
$ PANTHEON_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 \
$ bin/pantheon --rinkeby
$ bin/pantheon --network=rinkeby
```

@ -21,41 +21,45 @@ To start a bootnode for a private network:
!!! example
```bash
pantheon --genesis=privateNetworkGenesis.json --datadir=nodeDataDir export-pub-key bootnode
pantheon --genesis-file=privateNetworkGenesis.json --data-path=nodeDataPath export-pub-key bootnode
```
Where `privateNetworkGenesis.json` and `nodeDataDir` are changed to the relevant values for
Where `privateNetworkGenesis.json` and `nodeDataPath` are changed to the relevant values for
your private network.
The node public key is exported to the `bootnode` file.
2. Start the bootnode, specifying:
* No arguments for the [`--bootnodes` option](../Reference/Pantheon-CLI-Syntax.md#bootnodes) because this is the bootnode.
* Network ID for your private network.
* Genesis file and data directory as in the previous step.
!!! example
```
pantheon --bootnodes --genesis=privateNetworkGenesis.json --datadir=nodeDataDir --network-id 123
pantheon --genesis-file=privateNetworkGenesis.json --data-path=nodeDataPath
```
To specify this bootnode for another node, the enode URL for the `--bootnodes` option is `enode://<id>@<host:port>` where:
To specify this bootnode for another node, the enode URL for the [`--bootnodes`](../Reference/Pantheon-CLI-Syntax.md#bootnodes)
option is `enode://<id>@<host:port>` where:
* `<id>` is the node public key written to the specified file (`bootnode` in the above example) excluding the initial 0x.
* `<host:port>` is the host and port the bootnode is listening on for P2P peer discovery. Specified by the `--p2p-listen` option for the bootnode (default is `127.0.0.1:30303`).
* `<host:port>` is the host and port the bootnode is listening on for P2P peer discovery.
Specified by the [`--p2p-host` option](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and
[`--p2p-port` option](../Reference/Pantheon-CLI-Syntax.md#p2p-port) option for the bootnode
(default host is `127.0.0.1` and port is `30303`).
!!! example
If the `--p2p-listen` option is not specified and the node public key exported is `0xc35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f`
If the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) or [`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port) options are not specified and the node public key exported is `0xc35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f`
The enode URL is:
`enode://c35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f@127.0.0.1:30303`
!!! info
The default host and port for P2P peer discovery is `127.0.0.1:30303`. Use the `--p2p-listen` option to specify a host and port.
The default host and port for P2P peer discovery is `127.0.0.1:30303`.
Use the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and
[`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port) option to specify a host and port.
To start a node specifying the bootnode for P2P discovery:
!!! example
```bash
pantheon --genesis=privateNetworkGenesis.json --datadir=nodeDataDir --p2p-listen=127.0.0.1:30301 --network-id=123 --bootnodes=enode://c35c3ec90a8a51fd5703594c6303382f3ae6b2ecb99bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f@127.0.0.1:30303
pantheon --genesis-file=privateNetworkGenesis.json --data-path=nodeDataPath --p2p-host=127.0.0.1 --p2p-port=30301 --network-id=123 --bootnodes=enode://c35c3ec90a8a51fd5703594c6303382f3ae6b2ecb99bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f@127.0.0.1:30303
```

@ -3,7 +3,7 @@
To specify command line options in a file, use a TOML configuration file.
The configuration file can be saved and reused across node startups. To specify the configuration file,
use the [`--config` option](../Reference/Pantheon-CLI-Syntax.md#config).
use the [`--config-file` option](../Reference/Pantheon-CLI-Syntax.md#config).
To override an option specified in the configuration file, specify the same option on the command line.
When an option is specified in both places, Pantheon is started with the command line value.
@ -25,17 +25,23 @@ Specific differences between the command line and the TOML file format are:
!!!example "Example TOML configuration file"
```toml
# Valid TOML config file
datadir="~/pantheondata" # Path
data-path="~/pantheondata" # Path
# Network
bootnodes=["enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567"]
p2p-listen="1.2.3.4:1234" # IP:port
p2p-host="1.2.3.4"
p2p-port=1234
max-peers=42
rpc-listen="5.6.7.8:5678" # IP:port
ws-listen="9.10.11.12:9101" # IP:port
rpc-http-host="5.6.7.8"
rpc-http-port=5678
rpc-ws-host="9.10.11.12"
rpc-ws-port=9101
# Chain
genesis="~/genesis.json" # Path to the custom genesis file
genesis-file="~/genesis.json" # Path to the custom genesis file
# Mining
miner-enabled=true
@ -44,5 +50,5 @@ Specific differences between the command line and the TOML file format are:
!!!example "Starting Pantheon with a Configuration File"
```bash
pantheon --config=/home/me/me_node/config.toml
pantheon --config-file=/home/me/me_node/config.toml
```

@ -5,13 +5,17 @@ source: rinkeby.json
# Clique
Pantheon implements the Clique Proof-of-Authority (PoA) consensus protocol. Clique is used by the Rinkeby testnet and can be used for private networks.
Pantheon implements the Clique Proof-of-Authority (PoA) consensus protocol. Clique is used by the
Rinkeby testnet and can be used for private networks.
In Clique networks, transactions and blocks are validated by approved accounts, known as signers. Signers take turns to create the next block. Existing signers propose and vote to add or remove signers.
In Clique networks, transactions and blocks are validated by approved accounts, known as signers.
Signers take turns to create the next block. Existing signers propose and vote to add or remove signers.
## Genesis File
To use Clique in a private network, Pantheon requires a Clique genesis file. When connecting to Rinkeby, Pantheon uses the [`rinkeby.json`](https://github.com/PegaSysEng/pantheon/blob/master/config/src/main/resources/rinkeby.json) genesis file in the `/pantheon/config/src/main/resources` directory.
To use Clique in a private network, Pantheon requires a Clique genesis file. When connecting to Rinkeby,
Pantheon uses the [`rinkeby.json`](https://github.com/PegaSysEng/pantheon/blob/master/config/src/main/resources/rinkeby.json)
genesis file in the `/pantheon/config/src/main/resources` directory.
A PoA genesis file defines properties specific to Clique:
@ -37,14 +41,17 @@ The properties specific to Clique are:
* `epoch` - Number of blocks after which to reset all votes.
* `extraData` - Initial signers are specified after the 32 bytes reserved for vanity data.
To connect to the Rinkeby testnet, start Pantheon with the [`--rinkeby`](../Reference/Pantheon-CLI-Syntax.md#rinkeby) command line option. To start a node on a Clique private network, use the [`--genesis`](../Reference/Pantheon-CLI-Syntax.md#genesis`) option to specify the custom genesis file.
To connect to the Rinkeby testnet, start Pantheon with the [`--network=rinkeby`](../Reference/Pantheon-CLI-Syntax.md#network)
command line option. To start a node on a Clique private network, use the
[`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file) option to specify the custom genesis file.
## Adding and Removing Signers
To propose adding or removing signers using the JSON-RPC methods, enable the HTTP interface
using [`--rpc-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-enabled) or WebSockets interface using
[`--ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#ws-enabled). If also using the [`--rpc-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-api)
or [`--ws-api`](../Reference/Pantheon-CLI-Syntax.md#ws-api) options, include `CLIQUE`.
using [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled) or WebSockets interface using
[`--rpc-ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled). If also using the
[`--rpc-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-api)
or [`--ws-api`](../Reference/Pantheon-CLI-Syntax.md#ws-api) options, include `CLIQUE`.
The JSON-RPC methods to add or remove signers are:
@ -60,9 +67,11 @@ To propose adding a signer, call `clique_propose` specifying the address of the
When the next block is created by the signer, a vote is added to the block for the proposed signer.
When more than half of the existing signers propose adding the signer and their votes have been distributed in blocks, the signer is added and can begin signing blocks.
When more than half of the existing signers propose adding the signer and their votes have been
distributed in blocks, the signer is added and can begin signing blocks.
Use `clique_getSigners` to return a list of the signers and to confirm that your proposed signer has been added.
Use `clique_getSigners` to return a list of the signers and to confirm that your proposed signer has
been added.
!!! example "JSON-RPC clique_getSigners Request Example"
```bash
curl -X POST --data '{"jsonrpc":"2.0","method":"clique_getSigners","params":["latest"], "id":1}' <JSON-RPC-endpoint:port>
@ -74,11 +83,13 @@ To discard your proposal after confirming the signer was added, call `clique_dis
curl -X POST --data '{"jsonrpc":"2.0","method":"clique_discard","params":["0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73"], "id":1}' <JSON-RPC-endpoint:port>
```
The process for removing a signer is the same as adding a signer except you specify `false` as the second parameter of `clique_propose`.
The process for removing a signer is the same as adding a signer except you specify `false` as the
second parameter of `clique_propose`.
### Epoch Transition
At each epoch transition, all pending votes collected from received blocks are discarded. Existing proposals remain in effect and signers re-add their vote the next time they create a block.
At each epoch transition, all pending votes collected from received blocks are discarded.
Existing proposals remain in effect and signers re-add their vote the next time they create a block.
Define the number of blocks between epoch transitions in the genesis file.

@ -71,13 +71,13 @@ Properties that have specific values in IBFT 2.0 genesis files are:
* `difficulty` - `0x1`
* `mixHash` - `0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365` for Istanbul block identification.
To start a node on an IBFT 2.0 private network, use the [`--genesis`](../Reference/Pantheon-CLI-Syntax.md#genesis`) option to specify the custom genesis file.
To start a node on an IBFT 2.0 private network, use the [`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file`) option to specify the custom genesis file.
## Adding and Removing Validators
To propose adding or removing validators using the JSON-RPC methods, enable the HTTP interface
using [`--rpc-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-enabled) or WebSockets interface using
[`--ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#ws-enabled). If also using the [`--rpc-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-api)
using [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled) or WebSockets interface using
[`--rpc-ws-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-enabled). If also using the [`--rpc-api`](../Reference/Pantheon-CLI-Syntax.md#rpc-api)
or [`--ws-api`](../Reference/Pantheon-CLI-Syntax.md#ws-api) options, include `IBFT`.
The JSON-RPC methods to add or remove validators are:

@ -47,29 +47,32 @@ docker run pegasyseng/pantheon:latest
!!!attention
You cannot use the following Pantheon command line options when running Pantheon from the Docker image:
* [`--datadir`](../Reference/Pantheon-CLI-Syntax.md#datadir), see [Persisting Data](#persisting-data)
* [`--config`](../Reference/Pantheon-CLI-Syntax.md#config), see [Custom Configuration File](#custom-configuration-file)
* [`--genesis`](../Reference/Pantheon-CLI-Syntax.md#genesis), see [Custom Genesis File](#custom-genesis-file).
* [`--rpc-listen`](../Reference/Pantheon-CLI-Syntax.md#rpc-listen), [`--p2plisten`](../Reference/Pantheon-CLI-Syntax.md#p2plisten), [`--ws-listen`](../Reference/Pantheon-CLI-Syntax.md#ws-listen), see [Exposing Ports](#exposing-ports)
* [`--data-path`](../Reference/Pantheon-CLI-Syntax.md#data-path), see [Persisting Data](#persisting-data)
* [`--config-file`](../Reference/Pantheon-CLI-Syntax.md#config), see [Custom Configuration File](#custom-configuration-file)
* [`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file), see [Custom Genesis File](#custom-genesis-file).
* [`--rpc-http-host`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-host) and [`--rpc-http-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-port),
[`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and [`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port),
[`--rpc-ws-host`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-host) and [`--rpc-ws-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port),
see [Exposing Ports](#exposing-ports)
All other [Pantheon command line options](/Reference/Pantheon-CLI-Syntax) work in the same way as when Pantheon is installed locally.
### Data Directory
Specify a Docker volume for the data directory. This is the equivalent of specifying the [`--datadir`](../Reference/Pantheon-CLI-Syntax.md#datadir) option.
Specify a Docker volume for the data directory. This is the equivalent of specifying the [`--data-path`](../Reference/Pantheon-CLI-Syntax.md#data-path) option.
To run Pantheon specifying a volume for the data directory:
```bash
docker run --mount type=bind,source=/<pantheonDataDir>,target=/var/lib/pantheon pegasyseng/pantheon:latest
docker run --mount type=bind,source=/<pantheondata-path>,target=/var/lib/pantheon pegasyseng/pantheon:latest
```
Where `<pantheonDataDir>` is the volume to which the data is saved.
Where `<pantheondata-path>` is the volume to which the data is saved.
### Custom Configuration File
Specify a custom configuration file to provide a file containing key/value pairs for command line options. This is the equivalent of specifying the [`--config`](../Reference/Pantheon-CLI-Syntax.md#config) option.
Specify a custom configuration file to provide a file containing key/value pairs for command line options. This is the equivalent of specifying the [`--config-file`](../Reference/Pantheon-CLI-Syntax.md#config-file) option.
To run Pantheon specifying a custom configuration file:
```bash
@ -85,7 +88,7 @@ Where `myconf.toml` is your custom configuration file and `path` is the absolute
### Custom Genesis File
Specify a custom genesis file to configure the blockchain. This is equivalent to specifying the `--genesis` option.
Specify a custom genesis file to configure the blockchain. This is equivalent to specifying the `--genesis-file` option.
To run Pantheon specifying a custom genesis file:
```bash
@ -102,18 +105,18 @@ Where `mygenesis.json` is your custom configuration file and `path` is the absol
### Exposing Ports
Expose ports for P2P peer discovery, JSON-RPC service, and WebSockets. This is required to use the
defaults ports or specify different ports (the equivalent of specifying the [`--rpc-listen`](../Reference/Pantheon-CLI-Syntax.md#rpc-listen),
[`--p2p-listen`](../Reference/Pantheon-CLI-Syntax.md#p2p-listen), [`--ws-listen`](../Reference/Pantheon-CLI-Syntax.md#ws-listen) options).
defaults ports or specify different ports (the equivalent of specifying the [`--rpc-http-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-port),
[`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port), [`--rpc-ws-port`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-port) options).
To run Pantheon exposing local ports for access:
```bash
$ docker run -p <localportJSON-RPC>:8545 -p <localportWS>:8546 -p <localportP2P>:30303 pegasyseng/pantheon:latest --rpc-enabled --ws-enabled
$ docker run -p <localportJSON-RPC>:8545 -p <localportWS>:8546 -p <localportP2P>:30303 pegasyseng/pantheon:latest --rpc-http-enabled --rpc-ws-enabled
```
!!!example
To enable RPC calls to http://127.0.0.1:8545 and P2P discovery on http://127.0.0.1:13001:
```bash
docker run -p 8545:8545 -p 13001:30303 pegasyseng/pantheon:latest --rpc-enabled
docker run -p 8545:8545 -p 13001:30303 pegasyseng/pantheon:latest --rpc-http-enabled
```
## Starting Pantheon
@ -128,7 +131,7 @@ docker run -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon>,target=/
To run a node on mainnet with the HTTP JSON-RPC service enabled:
```bash
docker run -p 8545:8545 -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon>,target=/var/lib/pantheon pegasyseng/pantheon:latest --rpc-enabled
docker run -p 8545:8545 -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon>,target=/var/lib/pantheon pegasyseng/pantheon:latest --rpc-http-enabled
```
## Run a Node on Ropsten Testnet
@ -137,21 +140,21 @@ Save a local copy of the [Ropsten genesis file](https://github.com/PegaSysEng/pa
To run a node on Ropsten:
```bash
docker run -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon/ropsten>,target=/var/lib/pantheon --mount type=bind,source=/<path>/ropsten.json,target=/etc/pantheon/genesis.json pegasyseng/pantheon:latest --network-id=3 --bootnodes=enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303
docker run -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon/ropsten>,target=/var/lib/pantheon --network=ropsten
```
## Run a Node on Rinkeby Testnet
To run a node on Rinkeby:
```bash
docker run -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon/rinkeby>,target=/var/lib/pantheon pegasyseng/pantheon:latest --rinkeby
docker run -p 30303:30303 --mount type=bind,source=/<myvolume/pantheon/rinkeby>,target=/var/lib/pantheon pegasyseng/pantheon:latest --network=rinkeby
```
## Run a Node for Testing
To run a node that mines blocks at a rate suitable for testing purposes with WebSockets enabled:
```bash
docker run -p 8546:8546 --mount type=bind,source=/<myvolume/pantheon/testnode>,target=/var/lib/pantheon pegasyseng/pantheon:latest --dev-mode --bootnodes= --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-cors-origins "all" --ws-enabled
docker run -p 8546:8546 --mount type=bind,source=/<myvolume/pantheon/testnode>,target=/var/lib/pantheon pegasyseng/pantheon:latest --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-http-cors-origins "all" --rpc-ws-enabled --network=dev
```
## Stopping Pantheon and Cleaning up Resources

@ -13,7 +13,7 @@ Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or p
## Local Block Data
When connecting to a network other than the network previously connected to, you must either delete the local block data
or use the [`--datadir`](../Reference/Pantheon-CLI-Syntax.md#datadir) option to specify a different data directory.
or use the [`--data-path`](../Reference/Pantheon-CLI-Syntax.md#data-path) option to specify a different data directory.
To delete the local block data, delete the `database` directory in the `pantheon/build/distribution/pantheon-<version>` directory.
@ -22,16 +22,18 @@ To delete the local block data, delete the `database` directory in the `pantheon
Pantheon specifies the genesis configuration, and sets the network ID and bootnodes when connecting
to [Mainnet](#run-a-node-on-ethereum-mainnet), [Goerli](#run-a-node-on-goerli-testnet), [Rinkeby](#run-a-node-on-rinkeby-testnet), and [Ropsten](#run-a-node-on-ropsten-testnet).
When [`--dev-mode`](../Reference/Pantheon-CLI-Syntax.md#dev-mode) is specified, Pantheon uses the development mode genesis configuration.
When [`--network=dev`](../Reference/Pantheon-CLI-Syntax.md#network) is specified, Pantheon uses the
development mode genesis configuration associated to a low difficulty.
The default bootnodes setting for dev network is to have an empty bootnodes list.
The genesis files defining the genesis configurations are in the [Pantheon source files](https://github.com/PegaSysEng/pantheon/tree/master/config/src/main/resources).
To define a genesis configuration, create a genesis file (for example, `genesis.json`) and specify the file
using the [`--genesis`](../Reference/Pantheon-CLI-Syntax.md#genesis) option.
using the [`--genesis-file`](../Reference/Pantheon-CLI-Syntax.md#genesis-file) option.
## Confirm Node is Running
If you have started Pantheon with the [`--rpc-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-enabled) option, use [cURL](https://curl.haxx.se/) to
If you have started Pantheon with the [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled) option, use [cURL](https://curl.haxx.se/) to
call [JSON-RPC API methods](../Reference/JSON-RPC-API-Methods.md) to confirm the node is running.
!!!example
@ -67,63 +69,54 @@ call [JSON-RPC API methods](../Reference/JSON-RPC-API-Methods.md) to confirm the
To run a node that mines blocks at a rate suitable for testing purposes:
```bash
pantheon --dev-mode --network-id="2018" --bootnodes --miner-enabled --miner-coinbase=0xfe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-cors-origins="all" --host-whitelist="all" --ws-enabled --rpc-enabled --datadir=/tmp/tmpDatdir
pantheon --network=dev --miner-enabled --miner-coinbase=0xfe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-http-cors-origins="all" --host-whitelist="all" --rpc-rpc-ws-enabled --rpc-http-enabled --data-path=/tmp/tmpDatdir
```
Alternatively, use the following [configuration file](../Configuring-Pantheon/Using-Configuration-File.md) and `--bootnodes` on the command line to start a node with the same options as above:
Alternatively, use the following [configuration file](../Configuring-Pantheon/Using-Configuration-File.md)
on the command line to start a node with the same options as above:
```toml
dev-mode=true
network-id="2018"
network="dev"
miner-enabled=true
miner-coinbase="0xfe3b557e8fb62b89f4916b721be55ceb828dbd73"
rpc-cors-origins=["all"]
host-whitelist=["all"]
ws-enabled=true
rpc-enabled=true
datadir="/tmp/tmpDatadir"
rpc-ws-enabled=true
rpc-http-enabled=true
data-path="/tmp/tmpdata-path"
```
## Run a Node on Ropsten Testnet
!!!note
From v0.8.2, use the [`--ropsten` option](../Reference/Pantheon-CLI-Syntax.md#options)
instead of the following options. For v0.8.1, use the following options.
To run a node on Ropsten:
```bash
pantheon --network-id=3 --genesis=<path>/pantheon/ethereum/core/src/main/resources/ropsten.json --bootnodes=enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303
pantheon --network=ropsten
```
To run a node on Ropsten with the HTTP JSON-RPC service enabled and allow Remix to access the node:
```bash
pantheon --rpc-enabled --rpc-cors-origins "http://remix.ethereum.org" --network-id=3 --genesis=<path>/pantheon/ethereum/core/src/main/resources/ropsten.json --bootnodes=enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303
pantheon --network=ropsten --rpc-http-enabled --rpc-http-cors-origins "http://remix.ethereum.org"
```
Where `<path>` is the path to the `/pantheon` directory.
## Run a Node on Rinkeby Testnet
To run a node on Rinkeby specifying a data directory:
```bash
pantheon --rinkeby --datadir=<path>/rinkebyDataDir
pantheon --network=rinkeby --data-path=<path>/<rinkebydata-path>
```
Where `<path>` and `<rinkebyDataDir>` are the path and directory where the Rinkeby chain data is to be saved.
Where `<path>` and `<rinkebydata-path>` are the path and directory where the Rinkeby chain data is to be saved.
## Run a Node on Goerli Testnet
To run a node on [Goerli](https://github.com/goerli/testnet) specifying a data directory:
```bash
pantheon --goerli --datadir=<path>/<goerliDataDir>
pantheon --network=goerli --data-path=<path>/<goerlidata-path>
```
Where `<path>` and `<goerliDataDir>` are the path and directory where the Goerli chain data is to be saved.
!!!note
This option is only available from v0.8.3.
Where `<path>` and `<goerlidata-path>` are the path and directory where the Goerli chain data is to be saved.
## Run a Node on Ethereum Mainnet
@ -133,8 +126,8 @@ To run a node on the Ethereum mainnet:
pantheon
```
To run a node on mainnet with the HTTP JSON-RPC service enabled:
To run a node on mainnet with the HTTP JSON-RPC service enabled and available for localhost only:
```bash
pantheon --rpc-enabled
pantheon --rpc-http-enabled
```

@ -320,7 +320,7 @@ You can get the Ethereum account address from a client such as MetaMask or Ether
!!!example
```bash
$ bin/pantheon --miner-coinbase="0xfe3b557e8fb62b89f4916b721be55ceb828dbd73" --rpc-enabled
$ bin/pantheon --miner-coinbase="0xfe3b557e8fb62b89f4916b721be55ceb828dbd73" --rpc-http-enabled
```
**Parameters**
@ -2062,7 +2062,7 @@ Lists the validators defined in the specified block.
### ibft_proposeValidatorVote
Proposes [adding or removing a validator]((../Consensus-Protocols/IBFT.md#adding-and-removing-validators)) with the specified address.
Proposes [adding or removing a validator](../Consensus-Protocols/IBFT.md#adding-and-removing-validators)) with the specified address.
**Parameters**

@ -4,9 +4,10 @@ description: Pantheon commande line interface reference
# Pantheon Command Line
!!! important "Breaking Changes in v0.9"
In v0.9, changes will be made to the command line options to improve usability. These will be breaking changes; that is,
in many cases the v0.8 command line options will no longer work. This reference and the rest of the documentation will be
updated to reflect these changes. Any further information required about the changes will be included in the v0.9 release notes.
In v0.9 the command line changed to improve usability. These are breaking changes; that is,
in many cases the v0.8 command line options will no longer work. This reference and the rest of
the documentation will be updated to reflect these changes. Any further information required
about the changes are included in the v0.9 release notes.
This reference describes the syntax of the Pantheon Command Line Interface (CLI) options and subcommands.
@ -79,12 +80,16 @@ bootnodes=["enode://c35c3...d615f@1.2.3.4:30303","enode://f42c13...fc456@1.2.3.5
List of comma-separated enode URLs for P2P discovery bootstrap.
When connecting to mainnet or public testnets, the default is a predefined list of enode URLs.
Specify bootnodes when connecting to a [private network](../Configuring-Pantheon/Testing-Developing-Nodes.md#bootnodes).
When connecting to MainNet or public testnets, the default is a predefined list of enode URLs.
On custom networks defined by [`--genesis-file`](#genesis-file) option,
an empty list of bootnodes is defined by default unless you define custom bootnodes as described in
[private network documentation](../Configuring-Pantheon/Testing-Developing-Nodes.md#bootnodes).
!!! note
Specifying a node is a [bootnode](../Configuring-Pantheon/Testing-Developing-Nodes.md#bootnodes)
must be done on the command line not in a [configuration file](../Configuring-Pantheon/Using-Configuration-File.md).
Specifying that a node is a [bootnode](../Configuring-Pantheon/Testing-Developing-Nodes.md#bootnodes)
must be done on the command line using [`--bootnodes`](#bootnodes) option without value,
not in a [configuration file](../Configuring-Pantheon/Using-Configuration-File.md).
### config-file
@ -93,7 +98,7 @@ Specify bootnodes when connecting to a [private network](../Configuring-Pantheon
```
```bash tab="Example Command Line"
--config=/home/me/me_node/config.toml
--config-file=/home/me/me_node/config.toml
```
The path to the [TOML configuration file](../Configuring-Pantheon/Using-Configuration-File.md).
@ -121,33 +126,13 @@ The path to the Pantheon data directory. The default is the `/build/distribution
!!!note
This option is not used when running Pantheon from the [Docker image](../Getting-Started/Run-Docker-Image.md#persisting-data).
### genesis-file
### dev-mode
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
```bash tab="Syntax"
--dev-mode
```
```bash tab="Example Configuration File"
dev-mode=true
```
Set this option to `true` to run in development mode.
For example, specify this option to perform CPU mining more easily in a private test network.
In development mode, a custom genesis configuration specifies the chain ID.
When using this option, also set the [`--network-id`](#network-id) option to the network you use for development.
Default is `false`.
!!!note
The [`--dev-mode`](#dev-mode) option overrides the [`--genesis`](#genesis) option. If both are specified, the development mode configuration is used.
Genesis file is used to create a custom network.
### genesis-file
!!!tip
To use a public Ethereum network such as Rinkeby, use the [`--network`](#network) option.
The network option defines the genesis file for public networks.
```bash tab="Syntax"
--genesis-file=<FILE>
@ -161,36 +146,13 @@ Default is `false`.
genesis-file="/home/me/me_node/customGenesisFile.json"
```
The path to the genesis file. The default is the embedded genesis file for the Ethereum mainnet.
When using this option, it is recommended to also set the [`--network-id`](#network-id) option.
!!!note
This option is not used when running Pantheon from the [Docker image](../Getting-Started/Run-Docker-Image.md#custom-genesis-file).
!!!note
The [`--genesis`](#genesis) option is overridden by the [`--dev-mode`](#dev-mode) option.
If both are specified, the specified genesis file is ignored and the development mode configuration used.
### goerli
The path to the genesis file.
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
```bash tab="Syntax"
--goerli
```
```bash tab="Example Configuration File"
goerli=true
```
Uses the Goerli test network. Default is false.
The [`--genesis-file`](#genesis-file) and [`--network`](#network) option can't be used at the same time.
!!!note
This option is only available from v0.8.3.
This option is not used when running Pantheon from the [Docker image](../Getting-Started/Run-Docker-Image.md#custom-genesis-file).
### host-whitelist
@ -367,11 +329,47 @@ min-gas-price="1337"
The minimum price that a transaction offers for it to be included in a mined block.
The default is 1000.
### network-id
### network
```bash tab="Syntax"
--network=<NETWORK>
```
```bash tab="Example Command Line"
--network=rinkeby
```
```bash tab="Example Configuration File"
network="rinkeby"
```
Predefined network configuration.
The default is `mainnet`.
Possible values are :
`mainnet`
: Main Ethereum network
`ropsten`
: PoW test network similar to current main Ethereum network.
`rinkeby`
: PoA test network using Clique.
`goerli`
: PoA test network using Clique.
`dev`
: PoW development network with a very low difficulty to enable local CPU mining.
!!!note
Values are case insensitive, so either `mainnet` or `MAINNET` works.
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
The [`--network`](#network) and [`--genesis-file`](#genesis-file) option can't be used at the same time.
### network-id
```bash tab="Syntax"
--network-id=<INTEGER>
@ -386,7 +384,9 @@ network-id="8675309"
```
P2P network identifier.
The default is set to mainnet with value `1`.
This option can be used to override your current network ID.
The default value is the current network chain ID which is defined in the genesis file.
### no-discovery
@ -451,21 +451,6 @@ Not intended for use with mainnet or public testnets.
!!!note
Permissioning is under development and will be available in v1.0.
### ottoman
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
```bash tab="Syntax"
--ottoman
```
Enables accepting of blocks in an IBFT 1.0 network. The default is `false`.
!!!note
A Pantheon node cannot be a validator in an IBFT 1.0 network. Pantheon implements [IBFT 2.0](../Consensus-Protocols/IBFT.md).
### p2p-host
```bash tab="Syntax"
@ -508,44 +493,6 @@ The default is 30303.
!!!note
This option is not used when running Pantheon from the [Docker image](../Getting-Started/Run-Docker-Image.md#exposing-ports).
### rinkeby
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
```bash tab="Syntax"
--rinkeby
```
```bash tab="Example Configuration File"
rinkeby=true
```
Uses the Rinkeby test network.
Default is `false`.
### ropsten
!!!important
This option is deprecated in favor of the new `--network` option.
It will be completely removed in the 0.9 release.
```bash tab="Syntax"
--ropsten
```
```bash tab="Example Configuration File"
ropsten=true
```
Uses the Ropsten test network.
Default is `false`.
!!!note
This option is only available only from v0.8.2. For v0.8.1, refer to [Starting Pantheon](../Getting-Started/Starting-Pantheon.md#run-a-node-on-ropsten-testnet).
### rpc-http-enabled
```bash tab="Syntax"

@ -33,8 +33,8 @@ In this reference, the placeholder
`<JSON-RPC-http-endpoint:port>` and `<JSON-RPC-ws-endpoint:port>` means an endpoint (IP address and port)
of the JSON-RPC service of a Pantheon node respectively for http endpoint and for WebSocket endpoint.
To activate JSON-RPC using http or WebSocket, see [`--rpc-listen`](../Reference/Pantheon-CLI-Syntax.md#rpc-listen)
and [`--ws-listen`](../Reference/Pantheon-CLI-Syntax.md#ws-listen) options in the CLI documentation.
To activate JSON-RPC using http or WebSocket, see [`--rpc-http-enabled`](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled)
and [`--rpc-ws-listen`](../Reference/Pantheon-CLI-Syntax.md#rpc-ws-listen) options in the CLI documentation.
The transport attributes are:

@ -35,11 +35,11 @@ Create directories for your private network, each of the three nodes, and a data
```bash
Private-Network/
├── Node-1
   ├── Node-1-Datadir
   ├── Node-1-data-path
├── Node-2
   ├── Node-2-Datadir
   ├── Node-2-data-path
└── Node-3
├── Node-3-Datadir
├── Node-3-data-path
```
### 2. Create Genesis File
@ -89,17 +89,17 @@ In the `Node-1` directory, use the [`export-pub-key` subcommand](../Reference/Pa
the [node public key](../Configuring-Pantheon/Node-Keys.md) to the specified file (`publicKeyNode1` in this example):
```bash tab="MacOS"
pantheon --datadir=Node-1-Datadir --genesis=../privateNetworkGenesis.json export-pub-key Node-1-Datadir/publicKeyNode1
pantheon --data-path=Node-1-data-path --genesis-file=../privateNetworkGenesis.json export-pub-key Node-1-data-path/publicKeyNode1
```
```bash tab="Windows"
pantheon --datadir=Node-1-Datadir --genesis=..\privateNetworkGenesis.json export-pub-key Node-1-Datadir\publicKeyNode1
pantheon --data-path=Node-1-data-path --genesis-file=..\privateNetworkGenesis.json export-pub-key Node-1-data-path\publicKeyNode1
```
Your node 1 directory now contains:
```bash
├── Node-1
   ├── Node-1-Datadir
   ├── Node-1-data-path
├── database
      ├── key
      ├── publicKeyNode1
@ -114,14 +114,14 @@ Start Node-1 specifying:
* No arguments for the [`--bootnodes` option](../Reference/Pantheon-CLI-Syntax.md#bootnodes) because this is your bootnode.
* Mining is enabled and the account to which mining rewards are paid using the [`--miner-enabled`](../Reference/Pantheon-CLI-Syntax.md#miner-enabled)
and [`--miner-coinbase` options](../Reference/Pantheon-CLI-Syntax.md#miner-coinbase).
* JSON-RPC API is enabled using the [`--rpc-enabled` option](../Reference/Pantheon-CLI-Syntax.md#rpc-enabled).
* JSON-RPC API is enabled using the [`--rpc-http-enabled` option](../Reference/Pantheon-CLI-Syntax.md#rpc-http-enabled).
```bash tab="MacOS"
pantheon --datadir=Node-1-Datadir --genesis=../privateNetworkGenesis.json --bootnodes --network-id 123 --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-enabled
pantheon --data-path=Node-1-data-path --genesis-file=../privateNetworkGenesis.json --bootnodes --network-id 123 --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-http-enabled
```
```bash tab="Windows"
pantheon --datadir=Node-1-Datadir --genesis=..\privateNetworkGenesis.json --bootnodes --network-id 123 --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-enabled
pantheon --data-path=Node-1-data-path --genesis-file=..\privateNetworkGenesis.json --bootnodes --network-id 123 --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-http-enabled
```
!!! info
@ -144,31 +144,31 @@ The enode URL is `enode://<id>@<host:port>` where:
Start another terminal, change to the `Node-2` directory and start Node-2 specifying:
* Different port to Node-1 for P2P peer discovery using the [`--p2p-listen` option](../Reference/Pantheon-CLI-Syntax.md#p2p-listen).
* Different port to Node-1 for P2P peer discovery using the [`--p2p-port` option](../Reference/Pantheon-CLI-Syntax.md#p2p-port).
* Enode URL for Node-1 using the [`--bootnodes` option](../Reference/Pantheon-CLI-Syntax.md#bootnodes).
* Data directory for Node-2 using the [`--datadir` option](../Reference/Pantheon-CLI-Syntax.md#datadir).
* Data directory for Node-2 using the [`--data-path` option](../Reference/Pantheon-CLI-Syntax.md#data-path).
* Genesis file and network ID as for Node-1.
```bash tab="MacOS"
pantheon --datadir=Node-2-Datadir --genesis=../privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-listen=127.0.0.1:30304
pantheon --data-path=Node-2-data-path --genesis-file=../privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-port=30304
```
```bash tab="Windows"
pantheon --datadir=Node-2-Datadir --genesis=..\privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-listen=127.0.0.1:30304
pantheon --data-path=Node-2-data-path --genesis-file=..\privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-port=30304
```
Start another terminal, change to the `Node-3` directory and start Node-3 specifying:
* Different port to Node-1 and Node-2 for P2P peer discovery.
* Data directory for Node-3 using the [`--datadir` option](../Reference/Pantheon-CLI-Syntax.md#datadir).
* Data directory for Node-3 using the [`--data-path` option](../Reference/Pantheon-CLI-Syntax.md#data-path).
* Bootnode, genesis file, and network ID as for Node-2.
```bash tab="MacOS"
pantheon --datadir=Node-3-Datadir --genesis=../privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-listen=127.0.0.1:30305
pantheon --data-path=Node-3-data-path --genesis-file=../privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-port30305
```
```bash tab="Windows"
pantheon --datadir=Node-3-Datadir --genesis=..\privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-listen=127.0.0.1:30305
pantheon --data-path=Node-3-data-path --genesis-file=..\privateNetworkGenesis.json --bootnodes="enode://<node public key ex 0x>@127.0.0.1:30303" --network-id 123 --p2p-port=30305
```
### 6. Confirm Private Network is Working
@ -199,7 +199,7 @@ Send transactions using `eth_sendRawTransaction` to [send ether or, deploy or in
Use the [JSON-RPC API](../Reference/Using-JSON-RPC-API.md).
Start a node with the `--ws-enabled` option and use the [RPC Pub/Sub API](../Using-Pantheon/RPC-PubSub.md).
Start a node with the `--rpc-ws-enabled` option and use the [RPC Pub/Sub API](../Using-Pantheon/RPC-PubSub.md).
## Stop Nodes

@ -56,8 +56,8 @@ block of the `prometheus.yml` file:
a single node for testing with metrics enabled:
```bash tab="Example"
pantheon --dev-mode --network-id="2018" --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73
--rpc-cors-origins="all" --rpc-enabled --metrics-enabled
pantheon --network=dev --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73
--rpc-http-cors-origins="all" --rpc-http-enabled --metrics-enabled
```
4. In another terminal, run Prometheus specifying the `prometheus.yml` file:

@ -35,7 +35,7 @@ interface DefaultCommandValues {
String DEFAULT_DATA_DIR_PATH = "./build/data";
String MANDATORY_INTEGER_FORMAT_HELP = "<INTEGER>";
String MANDATORY_MODE_FORMAT_HELP = "<MODE>";
String MANDATORY_NETWORK_FORMAT_HELP = "<CHAIN>";
String MANDATORY_NETWORK_FORMAT_HELP = "<NETWORK>";
String MANDATORY_NODE_ID_FORMAT_HELP = "<NODEID>";
Wei DEFAULT_MIN_TRANSACTION_GAS_PRICE = Wei.of(1000);
BytesValue DEFAULT_EXTRA_DATA = BytesValue.EMPTY;

@ -21,6 +21,7 @@ import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.R
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
@ -33,10 +34,12 @@ public class EthNetworkConfig {
private static final int RINKEBY_NETWORK_ID = 4;
private static final int ROPSTEN_NETWORK_ID = 3;
private static final int GOERLI_NETWORK_ID = 6284;
private static final int DEV_NETWORK_ID = 2018;
private static final String MAINNET_GENESIS = "mainnet.json";
private static final String RINKEBY_GENESIS = "rinkeby.json";
private static final String ROPSTEN_GENESIS = "ropsten.json";
private static final String GOERLI_GENESIS = "goerli.json";
private static final String DEV_GENESIS = "dev.json";
private final String genesisConfig;
private final int networkId;
private final Collection<?> bootNodes;
@ -93,24 +96,24 @@ public class EthNetworkConfig {
+ '}';
}
public static EthNetworkConfig mainnet() {
public static EthNetworkConfig getNetworkConfig(final NetworkName networkName) {
switch (networkName) {
case ROPSTEN:
return new EthNetworkConfig(
jsonConfig(MAINNET_GENESIS), MAINNET_NETWORK_ID, MAINNET_BOOTSTRAP_NODES);
}
public static EthNetworkConfig rinkeby() {
jsonConfig(ROPSTEN_GENESIS), ROPSTEN_NETWORK_ID, ROPSTEN_BOOTSTRAP_NODES);
case RINKEBY:
return new EthNetworkConfig(
jsonConfig(RINKEBY_GENESIS), RINKEBY_NETWORK_ID, RINKEBY_BOOTSTRAP_NODES);
}
public static EthNetworkConfig ropsten() {
return new EthNetworkConfig(
jsonConfig(ROPSTEN_GENESIS), ROPSTEN_NETWORK_ID, ROPSTEN_BOOTSTRAP_NODES);
}
public static EthNetworkConfig goerli() {
case GOERLI:
return new EthNetworkConfig(
jsonConfig(GOERLI_GENESIS), GOERLI_NETWORK_ID, GOERLI_BOOTSTRAP_NODES);
case DEV:
return new EthNetworkConfig(jsonConfig(DEV_GENESIS), DEV_NETWORK_ID, new ArrayList<>());
case MAINNET:
default:
return new EthNetworkConfig(
jsonConfig(MAINNET_GENESIS), MAINNET_NETWORK_ID, MAINNET_BOOTSTRAP_NODES);
}
}
private static String jsonConfig(final String resourceName) {

@ -14,8 +14,8 @@ package tech.pegasys.pantheon.cli;
public enum NetworkName {
MAINNET,
OTTOMAN,
RINKEBY,
ROPSTEN,
GOERLI
GOERLI,
DEV
}

@ -29,6 +29,7 @@ import tech.pegasys.pantheon.RunnerBuilder;
import tech.pegasys.pantheon.cli.custom.CorsAllowedOriginsProperty;
import tech.pegasys.pantheon.cli.custom.EnodeToURIPropertyConverter;
import tech.pegasys.pantheon.cli.custom.JsonRPCWhitelistHostsProperty;
import tech.pegasys.pantheon.config.GenesisConfigFile;
import tech.pegasys.pantheon.consensus.clique.jsonrpc.CliqueRpcApis;
import tech.pegasys.pantheon.consensus.ibft.jsonrpc.IbftRpcApis;
import tech.pegasys.pantheon.controller.KeyPairUtil;
@ -61,7 +62,6 @@ import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@ -73,6 +73,7 @@ import com.google.common.io.Resources;
import com.google.common.net.HostAndPort;
import com.google.common.net.HostSpecifier;
import io.vertx.core.Vertx;
import io.vertx.core.json.DecodeException;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import picocli.CommandLine;
@ -185,7 +186,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
arity = "0..*",
converter = EnodeToURIPropertyConverter.class
)
private final Collection<URI> bootstrapNodes = null;
private final Collection<URI> bootNodes = null;
@Option(
names = {"--max-peers"},
@ -231,47 +232,9 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
paramLabel = MANDATORY_NETWORK_FORMAT_HELP,
description =
"Synchronize against the indicated network, possible values are ${COMPLETION-CANDIDATES}."
+ " (default: ${DEFAULT-VALUE})"
+ " (default: MAINNET)"
)
private final NetworkName network = MAINNET;
/** @deprecated Deprecated in favour of --network option */
@Deprecated
// Boolean option to indicate if the client have to sync against the ottoman test network
// (see https://github.com/ethereum/EIPs/issues/650).
@Option(
names = {"--ottoman"},
description =
"Synchronize against the Ottoman test network, only useful if using an iBFT genesis file"
+ " - see https://github.com/ethereum/EIPs/issues/650 (default: ${DEFAULT-VALUE})"
)
private final Boolean syncWithOttoman = false;
/** @deprecated Deprecated in favour of --network option */
@Deprecated
@Option(
names = {"--rinkeby"},
description =
"Use the Rinkeby test network"
+ " - see https://github.com/ethereum/EIPs/issues/225 (default: ${DEFAULT-VALUE})"
)
private final Boolean rinkeby = false;
/** @deprecated Deprecated in favour of --network option */
@Deprecated
@Option(
names = {"--ropsten"},
description = "Use the Ropsten test network (default: ${DEFAULT-VALUE})"
)
private final Boolean ropsten = false;
/** @deprecated Deprecated in favour of --network option */
@Deprecated
@Option(
names = {"--goerli"},
description = "Use the Goerli test network (default: ${DEFAULT-VALUE})"
)
private final Boolean goerli = false;
private final NetworkName network = null;
@Option(
names = {"--p2p-host"},
@ -290,12 +253,11 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
)
private final Integer p2pPort = DEFAULT_PORT;
/** @deprecated Deprecated in favour of --network option */
@Deprecated
@Option(
names = {"--network-id"},
paramLabel = MANDATORY_INTEGER_FORMAT_HELP,
description = "P2P network identifier (default: ${DEFAULT-VALUE})",
description =
"P2P network identifier. (default: the selected network chain ID or custom genesis chain ID)",
arity = "1"
)
private final Integer networkId = null;
@ -454,16 +416,6 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
)
private final JsonRPCWhitelistHostsProperty hostsWhitelist = new JsonRPCWhitelistHostsProperty();
/** @deprecated Deprecated in favour of --network option */
@Deprecated
@Option(
names = {"--dev-mode"},
description =
"set during development to have a custom genesis with specific chain id "
+ "and reduced difficulty to enable CPU mining (default: ${DEFAULT-VALUE})."
)
private final Boolean isDevMode = false;
@Option(
names = {"--logging", "-l"},
paramLabel = "<LOG VERBOSITY LEVEL>",
@ -566,6 +518,8 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
final CommandLine commandLine = new CommandLine(this);
commandLine.setCaseInsensitiveEnumValuesAllowed(true);
standaloneCommands = new StandaloneCommand();
if (isFullInstantiation()) {
@ -601,7 +555,7 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
Configurator.setAllLevels("", logLevel);
}
if (!p2pEnabled && (bootstrapNodes != null && !bootstrapNodes.isEmpty())) {
if (!p2pEnabled && (bootNodes != null && !bootNodes.isEmpty())) {
throw new ParameterException(
new CommandLine(this), "Unable to specify bootnodes if p2p is disabled.");
}
@ -613,13 +567,8 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
"Unable to mine without a valid coinbase. Either disable mining (remove --miner-enabled)"
+ "or specify the beneficiary of mining (via --miner-coinbase <Address>)");
}
if (trueCount(ropsten, rinkeby, goerli) > 1) {
throw new ParameterException(
new CommandLine(this),
"Unable to connect to multiple networks simultaneously. Specify one of --ropsten, --rinkeby or --goerli");
}
final EthNetworkConfig ethNetworkConfig = ethNetworkConfig();
final EthNetworkConfig ethNetworkConfig = updateNetworkConfig(getNetwork());
final PermissioningConfiguration permissioningConfiguration = permissioningConfiguration();
ensureAllBootnodesAreInWhitelist(ethNetworkConfig, permissioningConfiguration);
@ -636,6 +585,11 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
permissioningConfiguration);
}
private NetworkName getNetwork() {
//noinspection ConstantConditions network is not always null but injected by PicoCLI if used
return network == null ? MAINNET : network;
}
private void ensureAllBootnodesAreInWhitelist(
final EthNetworkConfig ethNetworkConfig,
final PermissioningConfiguration permissioningConfiguration) {
@ -659,20 +613,16 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
}
}
private static int trueCount(final Boolean... b) {
return (int) Arrays.stream(b).filter(bool -> bool).count();
}
PantheonController<?> buildController() {
try {
return controllerBuilder
.synchronizerConfiguration(buildSyncConfig())
.homePath(dataDir())
.ethNetworkConfig(ethNetworkConfig())
.syncWithOttoman(syncWithOttoman)
.ethNetworkConfig(updateNetworkConfig(getNetwork()))
.syncWithOttoman(false) // ottoman feature is still there but it's now removed from CLI
.miningParameters(
new MiningParameters(coinbase, minTransactionGasPrice, extraData, isMiningEnabled))
.devMode(isDevMode)
.devMode(NetworkName.DEV.equals(getNetwork()))
.nodePrivateKeyFile(getNodePrivateKeyFile())
.metricsSystem(metricsSystem)
.privacyParameters(orionConfiguration())
@ -811,31 +761,69 @@ public class PantheonCommand implements DefaultCommandValues, Runnable {
return autoDiscoveredDefaultIP;
}
private EthNetworkConfig ethNetworkConfig() {
final EthNetworkConfig predefinedNetworkConfig;
if (rinkeby) {
predefinedNetworkConfig = EthNetworkConfig.rinkeby();
} else if (ropsten) {
predefinedNetworkConfig = EthNetworkConfig.ropsten();
} else if (goerli) {
predefinedNetworkConfig = EthNetworkConfig.goerli();
} else {
predefinedNetworkConfig = EthNetworkConfig.mainnet();
}
return updateNetworkConfig(predefinedNetworkConfig);
private EthNetworkConfig updateNetworkConfig(final NetworkName network) {
final EthNetworkConfig.Builder builder =
new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(network));
// custom genesis file use comes with specific default values for the genesis file itself
// but also for the network id and the bootnodes list.
File genesisFile = genesisFile();
if (genesisFile != null) {
//noinspection ConstantConditions network is not always null but injected by PicoCLI if used
if (this.network != null) {
// We check if network option was really provided by user and not only looking at the
// default value.
// if user provided it and provided the genesis file option at the same time, it raises a
// conflict error
throw new ParameterException(
new CommandLine(this),
"--network option and --genesis-file option can't be used at the same time."
+ "Please refer to CLI reference for more details about this constraint.");
}
private EthNetworkConfig updateNetworkConfig(final EthNetworkConfig ethNetworkConfig) {
final EthNetworkConfig.Builder builder = new EthNetworkConfig.Builder(ethNetworkConfig);
if (genesisFile() != null) {
builder.setGenesisConfig(genesisConfig());
if (networkId == null) {
// if no network id option is defined on the CLI we have to set a default value from the
// genesis file.
// We do the genesis parsing only in this case as we already have network id constants
// for known networks to speed up the process.
// Also we have to parse the genesis as we don't already have a parsed version at this
// stage.
// If no chain id is found in the genesis as it's an optional, we use mainnet network id.
try {
GenesisConfigFile genesisConfigFile = GenesisConfigFile.fromConfig(genesisConfig());
builder.setNetworkId(
genesisConfigFile
.getConfigOptions()
.getChainId()
.orElse(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId()));
} catch (DecodeException e) {
throw new ParameterException(
new CommandLine(this),
String.format("Unable to parse genesis file %s.", genesisFile),
e);
}
}
if (bootNodes == null) {
// We default to an empty bootnodes list if the option is not provided on CLI because
// mainnet bootnodes won't work as the default value for a custom genesis,
// so it's better to have an empty list as default value that forces to create a custom one
// than a useless one that may make user think that it can work when it can't.
builder.setBootNodes(new ArrayList<>());
}
}
if (networkId != null) {
builder.setNetworkId(networkId);
}
if (bootstrapNodes != null) {
builder.setBootNodes(bootstrapNodes);
if (bootNodes != null) {
builder.setBootNodes(bootNodes);
}
return builder.build();
}

@ -37,13 +37,14 @@ class StandaloneCommand implements DefaultCommandValues {
// Genesis file path with null default option if the option
// is not defined on command line as this default is handled by Runner
// to use mainnet json file from resources
// NOTE: we have no control over default value here.
// to use mainnet json file from resources as indicated in the
// default network option
// Then we have no control over genesis default value here.
@CommandLine.Option(
names = {"--private-genesis-file"},
names = {"--genesis-file"},
paramLabel = MANDATORY_FILE_FORMAT_HELP,
description =
"The path to genesis file. Setting this will also override --chain option to be CUSTOM"
"The path to genesis file. Setting this option makes --network option ignored and requires --network-id to be set."
)
final File genesisFile = null;
}

@ -21,9 +21,15 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNotNull;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static tech.pegasys.pantheon.cli.NetworkName.DEV;
import static tech.pegasys.pantheon.cli.NetworkName.GOERLI;
import static tech.pegasys.pantheon.cli.NetworkName.MAINNET;
import static tech.pegasys.pantheon.cli.NetworkName.RINKEBY;
import static tech.pegasys.pantheon.cli.NetworkName.ROPSTEN;
import static tech.pegasys.pantheon.ethereum.p2p.config.DiscoveryConfiguration.MAINNET_BOOTSTRAP_NODES;
import tech.pegasys.pantheon.PantheonInfo;
import tech.pegasys.pantheon.config.GenesisConfigFile;
import tech.pegasys.pantheon.ethereum.core.Address;
import tech.pegasys.pantheon.ethereum.core.MiningParameters;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
@ -52,6 +58,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.common.io.Resources;
import io.vertx.core.json.JsonObject;
import net.consensys.cava.toml.Toml;
import net.consensys.cava.toml.TomlParseResult;
import org.apache.commons.text.StringEscapeUtils;
@ -62,6 +69,7 @@ import org.mockito.ArgumentMatchers;
import picocli.CommandLine;
public class PantheonCommandTest extends CommandTestAbstract {
private final String ORION_URI = "http://1.2.3.4:5555";
private final String VALID_NODE_ID =
"6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0";
@ -69,7 +77,12 @@ public class PantheonCommandTest extends CommandTestAbstract {
private static final JsonRpcConfiguration defaultJsonRpcConfiguration;
private static final WebSocketConfiguration defaultWebSocketConfiguration;
private static final MetricsConfiguration defaultMetricsConfiguration;
private static final String GENESIS_CONFIG_TESTDATA = "genesis_config";
private static final int GENESIS_CONFIG_TEST_CHAINID = 3141592;
private static final JsonObject GENESIS_VALID_JSON =
(new JsonObject())
.put("config", (new JsonObject()).put("chainId", GENESIS_CONFIG_TEST_CHAINID));
private static final JsonObject GENESIS_INVALID_DATA =
(new JsonObject()).put("config", new JsonObject());
private final String[] validENodeStrings = {
"enode://" + VALID_NODE_ID + "@192.168.0.1:4567",
@ -237,7 +250,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
assumeTrue(isFullInstantiation());
final URL configFile = Resources.getResource("complete_config.toml");
final Path genesisFile = createFakeGenesisFile();
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
final String updatedConfig =
Resources.toString(configFile, UTF_8)
.replace("~/genesis.json", escapeTomlString(genesisFile.toString()));
@ -282,8 +295,9 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(uriListArgumentCaptor.getValue()).isEqualTo(nodes);
final EthNetworkConfig networkConfig =
new EthNetworkConfig.Builder(EthNetworkConfig.mainnet())
.setGenesisConfig(GENESIS_CONFIG_TESTDATA)
new EthNetworkConfig.Builder(EthNetworkConfig.getNetworkConfig(MAINNET))
.setNetworkId(42)
.setGenesisConfig(encodeJsonGenesis(GENESIS_VALID_JSON))
.setBootNodes(nodes)
.build();
verify(mockControllerBuilder).homePath(eq(Paths.get("~/pantheondata")));
@ -293,8 +307,6 @@ public class PantheonCommandTest extends CommandTestAbstract {
// TODO: Re-enable as per NC-1057/NC-1681
// verify(mockSyncConfBuilder).syncMode(ArgumentMatchers.eq(SyncMode.FAST));
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@ -453,21 +465,100 @@ public class PantheonCommandTest extends CommandTestAbstract {
public void genesisPathOptionMustBeUsed() throws Exception {
assumeTrue(isFullInstantiation());
final Path genesisFile = createFakeGenesisFile();
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
parseCommand("--genesis-file", genesisFile.toString());
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue().getGenesisConfig())
.isEqualTo(encodeJsonGenesis(GENESIS_VALID_JSON));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void genesisAndNetworkMustNotBeUsedTogether() throws Exception {
assumeTrue(isFullInstantiation());
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
parseCommand("--genesis-file", genesisFile.toString(), "--network", "rinkeby");
verifyZeroInteractions(mockRunnerBuilder);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString())
.startsWith("--network option and --genesis-file option can't be used at the same time.");
}
@Test
public void defaultNetworkIdAndBootnodesForCustomNetworkOptions() throws Exception {
assumeTrue(isFullInstantiation());
final Path genesisFile = createFakeGenesisFile(GENESIS_VALID_JSON);
parseCommand("--genesis-file", genesisFile.toString());
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
parseCommand("--private-genesis-file", genesisFile.toString());
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue().getGenesisConfig())
.isEqualTo(encodeJsonGenesis(GENESIS_VALID_JSON));
assertThat(networkArg.getValue().getBootNodes()).isEmpty();
assertThat(networkArg.getValue().getNetworkId()).isEqualTo(GENESIS_CONFIG_TEST_CHAINID);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void defaultNetworkIdForInvalidGenesisMustBeMainnetNetworkId() throws Exception {
assumeTrue(isFullInstantiation());
final Path genesisFile = createFakeGenesisFile(GENESIS_INVALID_DATA);
parseCommand("--genesis-file", genesisFile.toString());
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config");
assertThat(networkArg.getValue().getGenesisConfig())
.isEqualTo(encodeJsonGenesis(GENESIS_INVALID_DATA));
// assertThat(networkArg.getValue().getNetworkId())
// .isEqualTo(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId());
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void predefinedNetworkIdsMustBeEqualToChainIds() {
// check the network id against the one in mainnet genesis config
// it implies that EthNetworkConfig.mainnet().getNetworkId() returns a value equals to the chain
// id
// in this network genesis file.
GenesisConfigFile genesisConfigFile =
GenesisConfigFile.fromConfig(EthNetworkConfig.getNetworkConfig(MAINNET).getGenesisConfig());
assertThat(genesisConfigFile.getConfigOptions().getChainId().isPresent()).isTrue();
assertThat(genesisConfigFile.getConfigOptions().getChainId().getAsInt())
.isEqualTo(EthNetworkConfig.getNetworkConfig(MAINNET).getNetworkId());
}
@Test
public void genesisPathDisabledUnderDocker() {
System.setProperty("pantheon.docker", "true");
@ -736,7 +827,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
@Test
public void ropstenWithNodesWhitelistOptionWhichDoesIncludeRopstenBootnodesMustNotDisplayError() {
parseCommand("--ropsten", "--nodes-whitelist", String.join(",", ropstenBootnodes));
parseCommand("--network", "ropsten", "--nodes-whitelist", String.join(",", ropstenBootnodes));
verify(mockRunnerBuilder)
.permissioningConfiguration(permissioningConfigurationArgumentCaptor.capture());
@ -759,7 +850,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
@Test
public void ropstenWithNodesWhitelistOptionWhichDoesNotIncludeRopstenBootnodesMustDisplayError() {
parseCommand("--ropsten", "--nodes-whitelist", String.join(",", validENodeStrings));
parseCommand("--network", "ropsten", "--nodes-whitelist", String.join(",", validENodeStrings));
verifyZeroInteractions(mockRunnerBuilder);
@ -1419,18 +1510,24 @@ public class PantheonCommandTest extends CommandTestAbstract {
@Test
public void devModeOptionMustBeUsed() throws Exception {
parseCommand("--dev-mode");
parseCommand("--network", "dev");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
verify(mockControllerBuilder).devMode(eq(true));
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(DEV));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
public void rinkebyValuesAreUsed() throws Exception {
parseCommand("--rinkeby");
parseCommand("--network", "rinkeby");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
@ -1438,14 +1535,15 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(RINKEBY));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.rinkeby());
}
@Test
public void ropstenValuesAreUsed() throws Exception {
parseCommand("--ropsten");
parseCommand("--network", "ropsten");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
@ -1453,14 +1551,15 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(ROPSTEN));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.ropsten());
}
@Test
public void goerliValuesAreUsed() throws Exception {
parseCommand("--goerli");
parseCommand("--network", "goerli");
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
@ -1468,19 +1567,10 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.goerli());
}
@Test
public void noSeveralNetworkOptions() {
parseCommand("--goerli", "--rinkeby");
verifyZeroInteractions(mockRunnerBuilder);
assertThat(networkArg.getValue()).isEqualTo(EthNetworkConfig.getNetworkConfig(GOERLI));
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).contains("Unable to connect to multiple networks");
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
@ -1493,16 +1583,24 @@ public class PantheonCommandTest extends CommandTestAbstract {
networkValuesCanBeOverridden("goerli");
}
@Test
public void ropstenValuesCanBeOverridden() throws Exception {
networkValuesCanBeOverridden("ropsten");
}
@Test
public void devValuesCanBeOverridden() throws Exception {
networkValuesCanBeOverridden("dev");
}
private void networkValuesCanBeOverridden(final String network) throws Exception {
final Path genesisFile = createFakeGenesisFile();
parseCommand(
"--" + network,
"--network",
network,
"--network-id",
"1",
"1234567",
"--bootnodes",
String.join(",", validENodeStrings),
"--private-genesis-file",
genesisFile.toString());
String.join(",", validENodeStrings));
final ArgumentCaptor<EthNetworkConfig> networkArg =
ArgumentCaptor.forClass(EthNetworkConfig.class);
@ -1510,12 +1608,12 @@ public class PantheonCommandTest extends CommandTestAbstract {
verify(mockControllerBuilder).ethNetworkConfig(networkArg.capture());
verify(mockControllerBuilder).build();
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
assertThat(networkArg.getValue().getGenesisConfig()).isEqualTo("genesis_config");
assertThat(networkArg.getValue().getBootNodes())
.isEqualTo(Stream.of(validENodeStrings).map(URI::create).collect(Collectors.toList()));
assertThat(networkArg.getValue().getNetworkId()).isEqualTo(1);
assertThat(networkArg.getValue().getNetworkId()).isEqualTo(1234567);
assertThat(commandOutput.toString()).isEmpty();
assertThat(commandErrorOutput.toString()).isEmpty();
}
@Test
@ -1528,7 +1626,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString()).doesNotContain("--config-file");
assertThat(commandOutput.toString()).doesNotContain("--data-path");
assertThat(commandOutput.toString()).doesNotContain("--private-genesis-file");
assertThat(commandOutput.toString()).doesNotContain("--genesis-file");
assertThat(commandErrorOutput.toString()).isEmpty();
}
@ -1540,7 +1638,7 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(commandOutput.toString()).contains("--config-file");
assertThat(commandOutput.toString()).contains("--data-path");
assertThat(commandOutput.toString()).contains("--private-genesis-file");
assertThat(commandOutput.toString()).contains("--genesis-file");
assertThat(commandErrorOutput.toString()).isEmpty();
}
@ -1583,12 +1681,16 @@ public class PantheonCommandTest extends CommandTestAbstract {
assertThat(orionArg.getValue().isEnabled()).isEqualTo(false);
}
private Path createFakeGenesisFile() throws IOException {
private Path createFakeGenesisFile(final JsonObject jsonGenesis) throws IOException {
final Path genesisFile = Files.createTempFile("genesisFile", "");
Files.write(genesisFile, "genesis_config".getBytes(UTF_8));
Files.write(genesisFile, encodeJsonGenesis(jsonGenesis).getBytes(UTF_8));
return genesisFile;
}
private String encodeJsonGenesis(final JsonObject jsonGenesis) {
return jsonGenesis.encodePrettily();
}
private boolean isFullInstantiation() {
return !Boolean.getBoolean("pantheon.docker");
}

@ -22,7 +22,8 @@ metrics-host="8.6.7.5"
metrics-port=309
# chain
private-genesis-file="~/genesis.json" # Path
genesis-file="~/genesis.json" # Path
network-id=42
sync-mode="fast"# should be FAST or FULL (or fast or full)
ottoman=false # true means using ottoman testnet if genesys file uses iBFT

@ -31,14 +31,9 @@ host-whitelist=["all"]
# chain
network="MAINNET"
private-genesis-file="~/genesis.json"
genesis-file="~/genesis.json"
sync-mode="fast"
ottoman=false
ropsten=false
goerli=false
network-id=303
rinkeby=false
dev-mode=false
# JSON-RPC
rpc-http-enabled=false
@ -66,7 +61,7 @@ metrics-prometheus-job="pantheon-everything"
# Mining
miner-enabled=false
miner-coinbase="0x0000000000000000000000000000000000000002"
miner-extra-data="Protocol Engineering Group And SYStems"
miner-extra-data="0x444F4E27542050414E4943202120484F444C2C20484F444C2C20484F444C2021"
min-gas-price="1"
# Permissioning

Loading…
Cancel
Save