Added key output and BLS generation

This commit is contained in:
Bruno Skvorc 2019-07-29 12:52:01 +02:00
parent 9796e817f1
commit 26557f2982
4 changed files with 156 additions and 31 deletions

View File

@ -12,9 +12,9 @@ You will have to pollute your system a little for this to work. Luckily, it work
### Start ### Start
Change the mnemonic to your own in `.env.example` and rename `.env.example` to `.env`. 1. Clone repo and modify the mnemonic in the `.env` file.
2. If you want to add some pre-created private keys, add them to the `.mykeys` file.
- Run `node start.js` with optional flags 3. Run `node start.js`. Optionally, pass in a `v` argument to autogenerate that many validators (`v=10`) and/or the `mykeys` argument to make the script read the keys specified in step 2.
The blockchain database will be stored in the `deploy/db` subfolder. The `deploy/keys` subfolder will have keys for relevant accounts generated, including the address to the deposit contract. The `deploy/faucet` folder will contain a simple web UI for a faucet. The blockchain database will be stored in the `deploy/db` subfolder. The `deploy/keys` subfolder will have keys for relevant accounts generated, including the address to the deposit contract. The `deploy/faucet` folder will contain a simple web UI for a faucet.
@ -22,20 +22,20 @@ The blockchain database will be stored in the `deploy/db` subfolder. The `deploy
Augment `start.js` with flags, .e.g. `node start.js v=50 mykeys`: Augment `start.js` with flags, .e.g. `node start.js v=50 mykeys`:
- `v` : Number of validators to generate. These validators will be generated with 32.1 ether each and will auto-deposit 32 ether to the deposit contract. Their private keys will be in `deploy/keys` @TODO, `account_keys_path` in Ganache seems bugged. - `v` : Number of validators to generate. These validators will be generated with 32.1 ether each and will auto-deposit 32 ether to the deposit contract. Their private keys will be in `deploy/keys`. Defaults to 10 if omitted, but only triggers default is `mykeys` argument not provided.
- `mykeys`: This is a boolean flag, so just include it to activate it. Passing this in will make the boostrapper read a `.mykeys.json` file in the root of the project, looking for private keys. The file should be a JSON object of address=>privkey pairs, `0x` included. These keys will then also be included as validators: they will be given 32.1 ether and deposit it into the contract. See `.mykeys.example` for example. - `mykeys`: This is a boolean flag, so just include it to activate it. Passing this in will make the boostrapper read a `.mykeys.json` file in the root of the project, looking for private keys. The file should be a JSON object of (address => privkey) pairs, `0x` included. These keys will then also be included as validators: they will be given 32.1 ether and deposit it into the contract. See `.mykeys.example` for example.
### Hosting ### Hosting
To host the generated blockchain online, upload the `deploy` folder somewhere and `cd` into it. The generator is deterministic. You always end up with the same addresses, accounts and balances if you use the same mnemonic and `.mykeys` list. Thus, to host it somewhere, simply clone this repo to the server and run it the same way you do locally.
- Run Ganache from the existing database with `yarn run ganache`. This auto-reads from `./db` and opens up web3/RPC so others can connect to your Ganache and try being validators. - `node start.js` will run the blockchain and start the server in listen mode with RPC/Web3 allowed
- Run the faucet with `yarn run faucet --port 8080`. The faucet will be hosted on port 8080. - `yarn run faucet --port 8080` will host the ether faucet at `localhost:8080`
- @TODO Run the simple UI for validators to deposit Ether and check their balance with `yarn run validator-ui`. - `yarn run validator-ui --port 8081` will host the validator UI at `localhost:8081` // @TODO
### Other commands ### Other commands
- To clean the DB and start over delete `deploy/db/*` or run `yarn run clean`. - To clean the DB and start over run `yarn run clean`.
## Contributing ## Contributing

View File

@ -6,6 +6,7 @@
"author": "Bruno Škvorc <bruno@bitfalls.com>", "author": "Bruno Škvorc <bruno@bitfalls.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@chainsafe/bls-js": "^0.1.5",
"dotenv": "^8.0.0", "dotenv": "^8.0.0",
"ethers": "^4.0.33", "ethers": "^4.0.33",
"ganache-cli": "^6.5.0" "ganache-cli": "^6.5.0"

116
start.js

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,21 @@
# yarn lockfile v1 # yarn lockfile v1
"@chainsafe/amcl@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@chainsafe/amcl/-/amcl-0.1.0.tgz#8a49445402561e3dcf9d536b78e2dc225b159b22"
integrity sha512-XzVLRxAqkkFeLA9T3ro1gn8llV3y6FIN38bRgmp5HvOJyfBprotKa6973J7BL7X566R6uztoNweK8ng40G08tw==
"@chainsafe/bls-js@^0.1.5":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@chainsafe/bls-js/-/bls-js-0.1.5.tgz#00fed1ef879aa4668092e7010fa21f5bf19f569e"
integrity sha512-etAnBTthmeub8igCx08Ww3TQRkK93bwM8nUNE5LNE3W1s1tySka7qsYcdmOKICJNTa7ARV/MbVnBg1nAUwntZQ==
dependencies:
"@chainsafe/amcl" "0.1.0"
assert "^1.4.1"
js-sha256 "^0.9.0"
secure-random "^1.1.1"
"@types/node@^10.3.2": "@types/node@^10.3.2":
version "10.14.13" version "10.14.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.13.tgz#ac786d623860adf39a3f51d629480aacd6a6eec7" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.13.tgz#ac786d623860adf39a3f51d629480aacd6a6eec7"
@ -22,6 +37,14 @@ ansi-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=
assert@^1.4.1:
version "1.5.0"
resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb"
integrity sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==
dependencies:
object-assign "^4.1.1"
util "0.10.3"
bn.js@4.11.8, bn.js@^4.4.0: bn.js@4.11.8, bn.js@^4.4.0:
version "4.11.8" version "4.11.8"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
@ -156,6 +179,11 @@ hash.js@^1.0.0:
inherits "^2.0.3" inherits "^2.0.3"
minimalistic-assert "^1.0.1" minimalistic-assert "^1.0.1"
inherits@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=
inherits@^2.0.1, inherits@^2.0.3: inherits@^2.0.1, inherits@^2.0.3:
version "2.0.4" version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
@ -188,6 +216,11 @@ isexe@^2.0.0:
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
js-sha256@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==
js-sha3@0.5.7: js-sha3@0.5.7:
version "0.5.7" version "0.5.7"
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7"
@ -245,6 +278,11 @@ number-is-nan@^1.0.0:
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
os-locale@^2.0.0: os-locale@^2.0.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2"
@ -308,6 +346,11 @@ scrypt-js@2.0.4:
resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.4.tgz#32f8c5149f0797672e551c07e230f834b6af5f16" resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.4.tgz#32f8c5149f0797672e551c07e230f834b6af5f16"
integrity sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw== integrity sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw==
secure-random@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/secure-random/-/secure-random-1.1.2.tgz#ed103b460a851632d420d46448b2a900a41e7f7c"
integrity sha512-H2bdSKERKdBV1SwoqYm6C0y+9EA94v6SUBOWO8kDndc4NoUih7Dv6Tsgma7zO1lv27wIvjlD0ZpMQk7um5dheQ==
set-blocking@^2.0.0: set-blocking@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
@ -384,6 +427,13 @@ strip-eof@^1.0.0:
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=
util@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"
integrity sha1-evsa/lCAUkZInj23/g7TeTNqwPk=
dependencies:
inherits "2.0.1"
uuid@2.0.1: uuid@2.0.1:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.1.tgz#c2a30dedb3e535d72ccf82e343941a50ba8533ac" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.1.tgz#c2a30dedb3e535d72ccf82e343941a50ba8533ac"