2018-12-19 12:58:53 +00:00
|
|
|
import
|
|
|
|
os, ospaths, strutils, strformat,
|
2019-03-18 03:54:08 +00:00
|
|
|
chronos, blscurve, nimcrypto, json_serialization, confutils,
|
2019-02-14 22:03:45 +00:00
|
|
|
spec/[datatypes, digest, crypto], conf, time, ssz,
|
2018-12-19 12:58:53 +00:00
|
|
|
../tests/testutil
|
|
|
|
|
2019-03-18 03:54:08 +00:00
|
|
|
proc writeTextFile(filename: string, contents: string) =
|
|
|
|
writeFile(filename, contents)
|
|
|
|
echo "Wrote ", filename
|
|
|
|
|
2018-12-19 12:58:53 +00:00
|
|
|
proc writeFile(filename: string, value: auto) =
|
|
|
|
Json.saveFile(filename, value, pretty = true)
|
2018-12-28 16:51:40 +00:00
|
|
|
echo "Wrote ", filename
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2019-03-18 03:54:08 +00:00
|
|
|
cli do (validators: int = 125000,
|
|
|
|
outputDir: string = "validators",
|
|
|
|
generateFakeKeys = true):
|
2019-02-15 16:33:32 +00:00
|
|
|
|
2019-03-07 13:59:28 +00:00
|
|
|
for i in 0 ..< validators:
|
|
|
|
let
|
2019-03-18 03:54:08 +00:00
|
|
|
v = validatorFileBaseName(i)
|
|
|
|
depositFn = outputDir / v & ".deposit.json"
|
|
|
|
privKeyFn = outputDir / v & ".privkey"
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2019-03-07 13:59:28 +00:00
|
|
|
if existsFile(depositFn) and existsFile(privKeyFn):
|
|
|
|
continue
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2019-03-07 13:59:28 +00:00
|
|
|
let
|
2019-03-18 03:54:08 +00:00
|
|
|
privKey = if generateFakeKeys: makeFakeValidatorPrivKey(i)
|
|
|
|
else: ValidatorPrivKey.random
|
2019-03-07 13:59:28 +00:00
|
|
|
pubKey = privKey.pubKey()
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2018-12-28 16:51:40 +00:00
|
|
|
let
|
|
|
|
withdrawalCredentials = makeFakeHash(i)
|
|
|
|
|
|
|
|
proofOfPossessionData = DepositInput(
|
|
|
|
pubkey: pubKey,
|
2019-02-07 20:13:10 +00:00
|
|
|
withdrawal_credentials: withdrawalCredentials)
|
2018-12-28 16:51:40 +00:00
|
|
|
|
2019-02-05 16:13:29 +00:00
|
|
|
proofOfPossession = bls_sign(
|
2019-03-25 16:46:31 +00:00
|
|
|
privkey, hash_tree_root(proofOfPossessionData).data,
|
2019-02-05 16:13:29 +00:00
|
|
|
0 # TODO - domain
|
|
|
|
)
|
2018-12-19 12:58:53 +00:00
|
|
|
|
2019-03-07 13:59:28 +00:00
|
|
|
let
|
|
|
|
deposit = Deposit(
|
|
|
|
deposit_data: DepositData(
|
|
|
|
amount: MAX_DEPOSIT_AMOUNT,
|
2019-03-22 15:49:37 +00:00
|
|
|
timestamp: 0, # TODO https://github.com/ethereum/eth2.0-specs/pull/834
|
2019-03-07 13:59:28 +00:00
|
|
|
deposit_input: DepositInput(
|
|
|
|
pubkey: pubKey,
|
|
|
|
proof_of_possession: proofOfPossession,
|
|
|
|
withdrawal_credentials: withdrawalCredentials)))
|
|
|
|
|
2019-03-18 03:54:08 +00:00
|
|
|
writeTextFile(privKeyFn, $privKey)
|
2019-03-07 13:59:28 +00:00
|
|
|
writeFile(depositFn, deposit)
|
|
|
|
|
2019-03-18 03:54:08 +00:00
|
|
|
if generateFakeKeys:
|
|
|
|
echo "Keys generated by this tool are only for testing!"
|