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