2018-12-19 12:58:53 +00:00
|
|
|
import
|
|
|
|
os, ospaths, strutils, strformat,
|
2019-02-06 17:56:04 +00:00
|
|
|
chronos, 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
|
|
|
|
|
|
|
|
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-07 13:59:28 +00:00
|
|
|
cli do (validators: int = 100000,
|
|
|
|
outputDir: string = "validators"):
|
2019-02-15 16:33:32 +00:00
|
|
|
|
2019-03-07 13:59:28 +00:00
|
|
|
for i in 0 ..< validators:
|
|
|
|
# there can apparently be tops 4M validators so we use 7 digits..
|
|
|
|
let
|
|
|
|
depositFn = outputDir / &"v{i:07}.deposit.json"
|
|
|
|
privKeyFn = outputDir / &"v{i:07}.privkey.json"
|
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
|
|
|
|
privKey = makeFakeValidatorPrivKey(i)
|
|
|
|
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(
|
|
|
|
privkey, hash_tree_root_final(proofOfPossessionData).data,
|
|
|
|
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,
|
|
|
|
timestamp: now(),
|
|
|
|
deposit_input: DepositInput(
|
|
|
|
pubkey: pubKey,
|
|
|
|
proof_of_possession: proofOfPossession,
|
|
|
|
withdrawal_credentials: withdrawalCredentials)))
|
|
|
|
|
|
|
|
writeFile(privKeyFn, privKey)
|
|
|
|
writeFile(depositFn, deposit)
|
|
|
|
|
|
|
|
echo "Keys generated by this tool are only for testing!"
|