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-27 12:06:06 +00:00
|
|
|
cli do (totalValidators: int = 125000,
|
2019-03-18 03:54:08 +00:00
|
|
|
outputDir: string = "validators",
|
2019-03-27 12:06:06 +00:00
|
|
|
generateFakeKeys = false):
|
2019-02-15 16:33:32 +00:00
|
|
|
|
2019-03-27 12:06:06 +00:00
|
|
|
for i in 0 ..< totalValidators:
|
2019-03-07 13:59:28 +00:00
|
|
|
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)
|
2019-05-09 12:27:37 +00:00
|
|
|
domain = 3'u64
|
2018-12-28 16:51:40 +00:00
|
|
|
|
2019-05-09 12:27:37 +00:00
|
|
|
var
|
2019-03-07 13:59:28 +00:00
|
|
|
deposit = Deposit(
|
2019-05-09 12:27:37 +00:00
|
|
|
data: DepositData(
|
2019-04-29 16:48:30 +00:00
|
|
|
amount: MAX_EFFECTIVE_BALANCE,
|
2019-05-09 12:27:37 +00:00
|
|
|
pubkey: pubKey,
|
2019-06-14 16:21:04 +00:00
|
|
|
withdrawal_credentials: withdrawalCredentials))
|
2019-05-09 12:27:37 +00:00
|
|
|
|
|
|
|
deposit.data.signature =
|
|
|
|
bls_sign(privkey, signing_root(deposit.data).data,
|
|
|
|
domain)
|
2019-03-07 13:59:28 +00:00
|
|
|
|
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!"
|