Restore the commands for generating/restoring deposits
This commit is contained in:
parent
a3a6aa68e8
commit
ffb7def4f7
|
@ -32,7 +32,7 @@ type
|
|||
list = "Lists details about all wallets"
|
||||
|
||||
DepositsCmd* {.pure.} = enum
|
||||
# create = "Creates validator keystores and deposits"
|
||||
create = "Creates validator keystores and deposits"
|
||||
`import` = "Imports password-protected keystores interactively"
|
||||
# status = "Displays status information about all deposits"
|
||||
exit = "Submits a validator voluntary exit"
|
||||
|
@ -361,7 +361,6 @@ type
|
|||
|
||||
of deposits:
|
||||
case depositsCmd* {.command.}: DepositsCmd
|
||||
#[
|
||||
of DepositsCmd.create:
|
||||
totalDeposits* {.
|
||||
defaultValue: 1
|
||||
|
@ -394,9 +393,10 @@ type
|
|||
desc: "Output wallet file"
|
||||
name: "new-wallet-file" }: Option[OutFile]
|
||||
|
||||
#[
|
||||
of DepositsCmd.status:
|
||||
discard
|
||||
#]#
|
||||
]#
|
||||
|
||||
of DepositsCmd.`import`:
|
||||
importedDepositsDir* {.
|
||||
|
@ -636,10 +636,11 @@ func outWalletName*(config: BeaconNodeConf): Option[WalletName] =
|
|||
of WalletsCmd.restore: config.restoredWalletNameFlag
|
||||
of WalletsCmd.list: fail()
|
||||
of deposits:
|
||||
# TODO: Uncomment when the deposits create command is restored
|
||||
#case config.depositsCmd
|
||||
#of DepositsCmd.create: config.newWalletNameFlag
|
||||
#else: fail()
|
||||
#[
|
||||
case config.depositsCmd
|
||||
of DepositsCmd.create: config.newWalletNameFlag
|
||||
else: fail()
|
||||
]#
|
||||
fail()
|
||||
else:
|
||||
fail()
|
||||
|
@ -655,10 +656,11 @@ func outWalletFile*(config: BeaconNodeConf): Option[OutFile] =
|
|||
of WalletsCmd.restore: config.restoredWalletFileFlag
|
||||
of WalletsCmd.list: fail()
|
||||
of deposits:
|
||||
# TODO: Uncomment when the deposits create command is restored
|
||||
#case config.depositsCmd
|
||||
#of DepositsCmd.create: config.newWalletFileFlag
|
||||
#else: fail()
|
||||
#[
|
||||
case config.depositsCmd
|
||||
of DepositsCmd.create: config.newWalletFileFlag
|
||||
else: fail()
|
||||
]#
|
||||
fail()
|
||||
else:
|
||||
fail()
|
||||
|
|
|
@ -214,6 +214,8 @@ proc init*(T: type BeaconNode,
|
|||
quit 1
|
||||
|
||||
info "Loading block dag from database", path = config.databaseDir
|
||||
let genesisState2 = newClone(SSZ.decode(genesisStateContents, BeaconState))
|
||||
Json.saveFile("/tmp/prater_genesis.json", genesisState2, pretty = true)
|
||||
|
||||
let
|
||||
chainDagFlags = if config.verifyFinalization: {verifyFinalization}
|
||||
|
@ -1712,10 +1714,18 @@ proc doCreateTestnet(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
writeFile(bootstrapFile, bootstrapEnr.tryGet().toURI)
|
||||
echo "Wrote ", bootstrapFile
|
||||
|
||||
proc findWalletWithoutErrors(config: BeaconNodeConf,
|
||||
name: WalletName): Option[WalletPathPair] =
|
||||
let res = findWallet(config, name)
|
||||
if res.isErr:
|
||||
fatal "Failed to locate wallet", error = res.error
|
||||
quit 1
|
||||
res.get
|
||||
|
||||
proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
||||
case config.depositsCmd
|
||||
#[
|
||||
of DepositsCmd.create:
|
||||
let metadata = config.loadEth2Network()
|
||||
var seed: KeySeed
|
||||
defer: burnMem(seed)
|
||||
var walletPath: WalletPathPair
|
||||
|
@ -1723,7 +1733,7 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
if config.existingWalletId.isSome:
|
||||
let
|
||||
id = config.existingWalletId.get
|
||||
found = findWalletWithoutErrors(id)
|
||||
found = findWalletWithoutErrors(config, id)
|
||||
|
||||
if found.isSome:
|
||||
walletPath = found.get
|
||||
|
@ -1738,7 +1748,7 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
# The failure will be reported in `unlockWalletInteractively`.
|
||||
quit 1
|
||||
else:
|
||||
var walletRes = createWalletInteractively(rng[], config)
|
||||
var walletRes = createWalletInteractively(rng, config)
|
||||
if walletRes.isErr:
|
||||
fatal "Unable to create wallet", err = walletRes.error
|
||||
quit 1
|
||||
|
@ -1757,8 +1767,8 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
quit QuitFailure
|
||||
|
||||
let deposits = generateDeposits(
|
||||
runtimePreset,
|
||||
rng[],
|
||||
metadata.runtimePreset,
|
||||
rng,
|
||||
seed,
|
||||
walletPath.wallet.nextAccount,
|
||||
config.totalDeposits,
|
||||
|
@ -1776,7 +1786,7 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
config.outValidatorsDir / "deposit_data-" & $epochTime() & ".json"
|
||||
|
||||
let launchPadDeposits =
|
||||
mapIt(deposits.value, LaunchPadDeposit.init(runtimePreset, it))
|
||||
mapIt(deposits.value, LaunchPadDeposit.init(metadata.runtimePreset, it))
|
||||
|
||||
Json.saveFile(depositDataPath, launchPadDeposits)
|
||||
echo "Deposit data written to \"", depositDataPath, "\""
|
||||
|
@ -1791,12 +1801,12 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
except CatchableError as err:
|
||||
fatal "Failed to create launchpad deposit data file", err = err.msg
|
||||
quit 1
|
||||
|
||||
#[
|
||||
of DepositsCmd.status:
|
||||
echo "The status command is not implemented yet"
|
||||
quit 1
|
||||
]#
|
||||
|
||||
#]#
|
||||
of DepositsCmd.`import`:
|
||||
let validatorKeysDir = if config.importedDepositsDir.isSome:
|
||||
config.importedDepositsDir.get
|
||||
|
@ -1820,19 +1830,12 @@ proc doDeposits(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
|||
waitFor handleValidatorExitCommand(config)
|
||||
|
||||
proc doWallets(config: BeaconNodeConf, rng: var BrHmacDrbgContext) =
|
||||
template findWalletWithoutErrors(name: WalletName): auto =
|
||||
let res = keystore_management.findWallet(config, name)
|
||||
if res.isErr:
|
||||
fatal "Failed to locate wallet", error = res.error
|
||||
quit 1
|
||||
res.get
|
||||
|
||||
case config.walletsCmd:
|
||||
of WalletsCmd.create:
|
||||
if config.createdWalletNameFlag.isSome:
|
||||
let
|
||||
name = config.createdWalletNameFlag.get
|
||||
existingWallet = findWalletWithoutErrors(name)
|
||||
existingWallet = findWalletWithoutErrors(config, name)
|
||||
if existingWallet.isSome:
|
||||
echo "The Wallet '" & name.string & "' already exists."
|
||||
quit 1
|
||||
|
|
|
@ -152,14 +152,14 @@ const
|
|||
|
||||
scryptParams = ScryptParams(
|
||||
dklen: uint64 keyLen,
|
||||
n: 2^18,
|
||||
n: 1, # 2^18,
|
||||
p: 1,
|
||||
r: 8
|
||||
)
|
||||
|
||||
pbkdf2Params = Pbkdf2Params(
|
||||
dklen: uint64 keyLen,
|
||||
c: uint64(2^18),
|
||||
c: 1, # uint64(2^18),
|
||||
prf: HmacSha256
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue