Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
Prev Previous commit
Next Next commit
More formatting changes and minor language tweaks
  • Loading branch information
halfalicious committed Apr 5, 2019
commit 119b71902bd06b55a8f98ceeb883bfde52a96c9e
68 changes: 59 additions & 9 deletions doc/private_net_sync.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,78 @@
Creating a private network with 2 syncing nodes
===============================================
These instructions cover creating an Ethereum private network consisting of 2 nodes - 1 node will mine blocks and the other node will connect to the first node and sync the mined blocks to its own block database. Both nodes will use (the same) private chain configuration.
These instructions cover creating an Ethereum private network consisting of two nodes - one node will mine blocks and the other node will connect to the first node and sync the mined blocks to its own block database. Both nodes will use (the same) private chain configuration.


What is a private network?
--------------------------
For the purposes of this documentation, a "private network" can be thought of as a network of Ethereum nodes only accessible on your physical machine.
For the purposes of this documentation, a **private network** can be thought of as a network of Ethereum nodes only accessible on your physical machine.

What is a private chain?
-------------------------
An Ethereum chain is some state (e.g. accounts and balances and/or contract code) and a set of rules a set of rules for interacting with that state. For the purposes of this documentation, a private chain is an Ethereum chain is one whose configuration is only available on your physical machine.
An Ethereum chain is some state (e.g. accounts and balances and/or contract code) and a set of rules for interacting with that state. For the purposes of this documentation, a **private chain** is an Ethereum chain whose configuration is only available on your physical machine.

Mining
------
- Mining will be done using the Aleth CPU miner (Aleth doesn't include a GPU miner because of the high support costs).
- Only 1 node will be mining to keep your machine responsive (since both nodes are running on the same physical system, having both mine will slow your system down significantly).
- If you find your system being sluggish or if you'd like to have both nodes mine, you can tune the number of mining threads via the ``-t <thread count>`` flag
- Mining will be done using the Aleth CPU miner (Aleth doesn't include a GPU miner because of the high maintenance and support costs. Please see `EthMiner <https://github.com/ethereum-mining/ethminer>`_) for GPU mining support.
- Only one node will be mining to keep your machine responsive (since both nodes are running on the same physical system, having both mine will slow your system down significantly).
- If you find your system being sluggish or if you'd like both nodes to mine, you can tune the number of mining threads via the ``-t <thread count>`` flag

Chain configuration
-------------------
- You typically run a private chain using a chain configuration json file - this isn't strictly required, but it makes testing a lot easier since you can do things like lower the difficulty rate and pre-fund addresses with Ether.
- You typically run a private chain using a chain configuration json file (this isn't strictly required, but it makes testing a lot easier since you can do things like lower the difficulty rate and pre-fund addresses with Ether).
- The chain configuration json file format is defined here: https://github.com/ethereum/wiki/wiki/Ethereum-Chain-Spec-Format
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really follow that spec? It might be outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I assumed we did, Ill investigate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, the spec is either deprecated or we don't fully implement the spec (for example it lists a "nodes" key which we don't support). I'll remove the link.

- Here's an example file: TODO
- Since the configuration file is used to create the chain's genesis state, both nodes must use the same configuration file otherwise they will have different genesis states and consequently won't be able to peer with each other. An example of this is shown in the "Common Problems" section (TODO)
- Here's an example file:

::

{
"sealEngine": "Ethash",
"params": {
"accountStartNonce": "0x00",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent params contents

"maximumExtraDataSize": "0x20",
"homesteadForkBlock": "0x00",
"EIP150ForkBlock": "0x00",
"EIP158ForkBlock": "0x00",
"byzantiumForkBlock": "0x00",
"constantinopleForkBlock": "0x00",
"constantinopleFixForkBlock": "0x00",
"minGasLimit": "0x5208",
"maxGasLimit": "0x7fffffffffffffff",
"tieBreakingGas": false,
"gasLimitBoundDivisor": "0x0400",
"minimumDifficulty": "0x100000",
"difficultyBoundDivisor": "0x0800",
"durationLimit": "0x0d",
"blockReward": "0x4563918244F40000",
"networkID" : "0x42",
"chainID": "0x42",
"allowFutureBlocks" : false
},
"genesis": {
"nonce": "0x0000000000000042",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent genesis contents.

"difficulty": "0x100000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"author": "0x0000000000000000000000000000000000000000",
"timestamp": "0x5A5B92D7",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x655741534d2074657374206e6574776f726b2030",
"gasLimit": "0x989680"
},
"accounts": {
"0000000000000000000000000000000000000001": { "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } }, "balance": "0x01" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent accounts contents.

"0000000000000000000000000000000000000002": { "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } }, "balance": "0x01" },
"0000000000000000000000000000000000000003": { "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } }, "balance": "0x01" },
"0000000000000000000000000000000000000004": { "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } }, "balance": "0x01" },
"0000000000000000000000000000000000000005": { "precompiled": { "name": "modexp" }, "balance": "0x01" },
"0000000000000000000000000000000000000006": { "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } }, "balance": "0x01" },
"0000000000000000000000000000000000000007": { "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } }, "balance": "0x01" },
"0000000000000000000000000000000000000008": { "precompiled": { "name": "alt_bn128_pairing_product" }, "balance": "0x01" },
"00fd4aaf9713f5bb664c20a462acc4ebc363d1a6": { "balance" : "0x200000000000000000000000000000000000000000000000000000000000000" },
"004d5baf9ab6a9c29c73725ec35023e330af2bc8": { "balance" : "0x200000000000000000000000000000000000000000000000000000000000000" }
}
}

- **Both nodes must use the same configuration file!** The configuration file is used to create the chain's genesis state, so using a different configuration file with each node means that each node will be running on a different chain. The nodes will therefore not be able to peer with each other - an example of this is shown in the `Common Problems`_ section.

Instructions
============
Expand Down