Skip to content

Commit 699dddf

Browse files
committed
Initial commit
0 parents  commit 699dddf

7 files changed

+155
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.blockchain/
2+
*.log

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Ethereum dev network
2+
3+
This repo contains scripts for bootstrapping and running local one-node Ethereum network for development use.
4+
5+
The bootstrapped network with these parameters is already included:
6+
7+
```
8+
Network id: 12342
9+
Difficulty: 1
10+
Gas limit: 4712389
11+
Engine: ethash
12+
```
13+
14+
Ten accounts are already created and pre-allocated with Ξ999 each. These accounts are generated using mnemonic `candy maple cake sugar pudding cream honey rich smooth crumble sweet treat`, which you can use when developing with MetaMask. Also, they match ones generated by `truffle develop`.
15+
16+
```
17+
0x627306090abab3a6e1400e9345bc60c78a8bef57 (private key c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3, password 0)
18+
0xf17f52151ebef6c7334fad080c5704d77216b732 (private key ae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f, password 1)
19+
0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef (private key 0dbbe8e4ae425a6d2687f1a7e3ba17bc98c673636790f1b8ad91193c05875ef1, password 2)
20+
0x821aea9a577a9b44299b9c15c88cf3087f3b5544 (private key c88b703fb08cbea894b6aeff5a544fb92e78a18e19814cd85da83b71f772aa6c, password 3)
21+
0x0d1d4e623d10f9fba5db95830f7d3839406c6af2 (private key 388c684f0ba1ef5017716adb5d21a053ea8e90277d0868337519f97bede61418, password 4)
22+
0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e (private key 659cbb0e2411a44db63778987b1e22153c086a95eb6b18bdf89de078917abc63, password 5)
23+
0x2191ef87e392377ec08e7c08eb105ef5448eced5 (private key 82d052c865f5763aad42add438569276c00d3d88a2d062d36b2bae914d58b8c8, password 6)
24+
0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5 (private key aa3680d5d48a8283413f7a108367c7299ca73f553735860a87b08f39395618b7, password 7)
25+
0x6330a553fc93768f612722bb8c2ec78ac90b3bbc (private key 0f62d96d6675f32685bbdb8ac13cda7c23436f63efbb9d07700d8669ff12b7c4, password 8)
26+
0x5aeda56215b167893e80b4fe645ba6d5bab767de (private key 8d5366123cb560bb606379f90a0bfd4769eecc0557f1b362dcae9012b548b1e5, password 9)
27+
```
28+
29+
30+
## Running network
31+
32+
Use `./run-geth` command. Each time you run it, the blockchain will be reset to checkpoint state (which is contained in `blockchain.tar.gz`), so all changes made by the previous run will be rolled back. This is useful when running tests, but you can disable this behavior by passing `-R` flag: `./run-geth -R`.
33+
34+
By default, only two first accounts are unlocked when `geth` starts. To auto-unlock more accounts, edit `run-geth.sh` and change `--unlock` flag, e.g. `--unlock '0,1,2,3,4,5,6,7,8,9'` to unlock all ten accounts.
35+
36+
37+
## Bootstrapping new blockchain
38+
39+
This is needed if you want different parameters (e.g. gas limit, difficulty) than of the pre-bootstrapped chain included in this repo.
40+
41+
1. Remove `blockchain.tar.gz`.
42+
2. Edit parameters in `genesis.json`.
43+
3. If you have changed `config.chainId` in `genesis.json`, update `--networkid` flag in `run-geth.sh` and `init-blockchain.sh` to match it.
44+
4. Run `./init-blockchain.sh`.
45+
5. Run `./run-geth.sh -R` and make any changes you wish to checkpoint (adding accounts, making transactions). To add accounts from private keys, use `personal.importRawKey(key, password)`. Exit geth.
46+
6. Archive generated chain and accounts: `tar -cvzf blockchain.tar.gz .blockchain`.
47+
7. Update `geth-passwords.txt` if needed.

blockchain.tar.gz

15 KB
Binary file not shown.

genesis.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"nonce": "0x0000000000000042",
3+
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
4+
"difficulty": "0x01",
5+
"coinbase": "0x0000000000000000000000000000000000000000",
6+
"timestamp": "0x00",
7+
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
8+
"extraData": "0x",
9+
"gasLimit": "0x47e7c5",
10+
"config": {
11+
"chainId": 12342,
12+
"homesteadBlock": 0,
13+
"eip150Block": 0,
14+
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
15+
"eip155Block": 0,
16+
"eip158Block": 0,
17+
"ByzantiumBlock": 0,
18+
"ethash": {}
19+
},
20+
"alloc": {
21+
"0x0000000000000000000000000000000000000001": {"balance": "1"},
22+
"0x0000000000000000000000000000000000000002": {"balance": "1"},
23+
"0x0000000000000000000000000000000000000003": {"balance": "1"},
24+
"0x0000000000000000000000000000000000000004": {"balance": "1"},
25+
"0x627306090abab3a6e1400e9345bc60c78a8bef57": {"balance": "999000000000000000000"},
26+
"0xf17f52151ebef6c7334fad080c5704d77216b732": {"balance": "999000000000000000000"},
27+
"0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef": {"balance": "999000000000000000000"},
28+
"0x821aea9a577a9b44299b9c15c88cf3087f3b5544": {"balance": "999000000000000000000"},
29+
"0x0d1d4e623d10f9fba5db95830f7d3839406c6af2": {"balance": "999000000000000000000"},
30+
"0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e": {"balance": "999000000000000000000"},
31+
"0x2191ef87e392377ec08e7c08eb105ef5448eced5": {"balance": "999000000000000000000"},
32+
"0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5": {"balance": "999000000000000000000"},
33+
"0x6330a553fc93768f612722bb8c2ec78ac90b3bbc": {"balance": "999000000000000000000"},
34+
"0x5aeda56215b167893e80b4fe645ba6d5bab767de": {"balance": "999000000000000000000"}
35+
}
36+
}

geth-passwords.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0
2+
1
3+
2
4+
3
5+
4
6+
5
7+
6
8+
7
9+
8
10+
9

init-blockchain.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
rm -rf .blockchain
4+
mkdir -p .blockchain
5+
6+
set -x
7+
8+
geth \
9+
--datadir .blockchain \
10+
--networkid=12342 \
11+
init genesis.json

run-geth.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
set -e
3+
4+
CPULIMIT_INFO='Running without limiting CPU.
5+
Install cpulimit for best experience: https://github.com/opsengine/cpulimit
6+
7+
On Mac, you can use Homebrew:
8+
brew install cpulimit
9+
'
10+
11+
if [ "$1" = '-R' ]; then
12+
echo
13+
echo 'Not resetting blockchain'
14+
echo
15+
if ! [ -d '.blockchain' ]; then
16+
tar -xzf blockchain.tar.gz
17+
fi
18+
else
19+
echo
20+
echo 'Resetting blockchain...'
21+
echo
22+
rm -rf .blockchain
23+
tar -xzf blockchain.tar.gz
24+
fi
25+
26+
run() {
27+
if command -v cpulimit >/dev/null; then
28+
set -x
29+
exec cpulimit -i -l 50 "$@"
30+
else
31+
echo "$CPULIMIT_INFO"
32+
set -x
33+
exec nice -n 10 "$@"
34+
fi
35+
}
36+
37+
run geth \
38+
--datadir='.blockchain' \
39+
--networkid=12342 \
40+
--nodiscover \
41+
--maxpeers 0 \
42+
--port=30342 \
43+
--rpc --rpcapi='db,eth,net,web3,personal' \
44+
--rpcport '9545' --rpcaddr '127.0.0.1' --rpccorsdomain '*' \
45+
--unlock '0,1' \
46+
--password geth-passwords.txt \
47+
--mine \
48+
--minerthreads=1 \
49+
console

0 commit comments

Comments
 (0)