From 2ff91d887d7dde99fc141413a5811f751c6774d6 Mon Sep 17 00:00:00 2001 From: Chris Ward Date: Fri, 20 Sep 2019 17:05:58 +0200 Subject: [PATCH] Move files, first dev mode draft --- docs/_getting-started/dev-mode.md | 48 ++++++++++++ .../private-network.md | 0 docs/getting-started/dev-mode.md | 74 ------------------- 3 files changed, 48 insertions(+), 74 deletions(-) create mode 100644 docs/_getting-started/dev-mode.md rename docs/{getting-started => _getting-started}/private-network.md (100%) delete mode 100644 docs/getting-started/dev-mode.md diff --git a/docs/_getting-started/dev-mode.md b/docs/_getting-started/dev-mode.md new file mode 100644 index 0000000000..6f3c1b35a7 --- /dev/null +++ b/docs/_getting-started/dev-mode.md @@ -0,0 +1,48 @@ +--- +title: Dev mode +--- + +Geth has a development mode which sets up a single node Ethereum test network with a number of options optimized for developing on local machines. You enable it with the `--dev` argument. + +Starting geth in dev mode does the following: + +- Initializes the data directory with a testing genesis block +- Sets max peers to 0 +- Turns off discovery by other nodes +- Sets the gas price to 0 +- Uses the ethash consensus engine with clique headers to allows blocks to be mined as fast as your CPU and memory can handle +- Prevents the consensus (proof of work) difficulty from ever increasing +- Permits 0 block times in the clique consensus engine and forbid empty blocks for 0 periods + +You can specify a data directory to maintain state between runs using the `--datadir` option, otherwise databases are ephemeral and in-memory: + +```shell +$ mkdir test-chain-dir +$ geth --dev --datadir test-chain-dir console +``` + +Once geth is running in dev mode, you can interact with it in the same way as when geth is running in other ways. + +For example, create a test account: + +```shell +> personal.newAccount() +``` + +Then transfer ether from the coinbase to the new account: + +```shell +> eth.sendTransaction({from:eth.coinbase, to:eth.accounts[1], value: web3.toWei(0.05, "ether")}) +``` + +And check the balance of the account: + +```shell +> eth.getBalance(eth.accounts[1]) +``` + +If you want to test your dapps with a realistic block time use the `--dev.period` option when you start dev mode: + +```shell +geth --dev --dev.period 100 console +``` diff --git a/docs/getting-started/private-network.md b/docs/_getting-started/private-network.md similarity index 100% rename from docs/getting-started/private-network.md rename to docs/_getting-started/private-network.md diff --git a/docs/getting-started/dev-mode.md b/docs/getting-started/dev-mode.md deleted file mode 100644 index 9b23af8e5c..0000000000 --- a/docs/getting-started/dev-mode.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: Dev mode ---- - -Geth has a development mode which sets up a single node Ethereum test network with a number of options optimized for developing on local machines. You enable it with the `--dev` argument. - -Dev mode does the following: - -- Initializes the data directory with a testing genesis block -- Sets max peers to 0 -- Turns off discovery by other nodes -- Sets the gas price to 0 -- Uses a testing consensus algorithm (proof of work) which generates blocks quickly -- Prevents the consensus (proof of work) difficulty from ever increasing - -We recommend you create and specify a data directory when using dev mode. - -```shell -$ mkdir test-chain-dir -$ geth --dev --datadir test-chain-dir console -``` - - - -Once geth is running, create a test account. - - - - - -```shell -> personal.newAccount() -Passphrase: -Repeat passphrase: -INFO [06-25|00:51:55] New wallet appeared url=keystore:///tmp… status=Locked -"0x42a3f741fa25e52c618854e7a002ff7c7985b044" -> -``` - -Then start the miner to mine some blocks. The coinbase will have automatically been set to the test account so the mined Ether will be deposited there. You can verify this by running `eth.coinbase`. - -```sh -> miner.start() -INFO [06-25|00:52:45] Updated mining threads threads=0 -INFO [06-25|00:52:45] Transaction pool price threshold updated price=0 -INFO [06-25|00:52:45] Starting mining operation -null -> INFO [06-25|00:52:45] Commit new mining work number=1 txs=0 uncles=0 elapsed=103.893µs -INFO [06-25|00:52:45] Generating DAG in progress epoch=0 percentage=0 elapsed=68.374µs -INFO [06-25|00:52:45] Generating DAG in progress epoch=0 percentage=3 elapsed=137.968µs -... -INFO [06-25|00:52:51] 🔗 block reached canonical chain number=3 hash=7049f9…22f775 -INFO [06-25|00:52:51] 🔨 mined potential block number=8 hash=c84185…4b5994 -INFO [06-25|00:52:51] Mining too far in the future wait=2s -``` - -And after a few seconds, stop the miner. - -```sh -> miner.stop() -INFO [06-25|00:52:53] Commit new mining work number=9 txs=0 uncles=0 elapsed=2.002s -true -> -``` - -Now check the balance in your test account. - -```sh -> web3.fromWei(eth.getBalance(personal.listAccounts[0]), "ether") -40 -> -``` - -Our test account has 40 Ether in it, which at 5 Ether per block means it mined 8 blocks in 8 seconds on a contemporary iMac, including generating the [DAG](https://ethereum.stackexchange.com/questions/1993/what-actually-is-a-dag).