Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some fail tips on nimbus_beacon_node deposits import #6270

Open
wants to merge 6 commits into
base: unstable
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion beacon_chain/validators/keystore_management.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1811,18 +1811,30 @@ proc importKeystoresFromDir*(rng: var HmacDrbgContext, meth: ImportMethod,
burnMem(singleSaltSalt)

try:
for file in walkDirRec(importedDir):
let importedFiles = walkDirRec(importedDir).toSeq
if importedFiles.len == 0:
fatal "No keystore file found at keystore path"
quit 1

var
invalidFlag = false
hasValid = false
for file in importedFiles:
let filenameParts = splitFile(file)
if toLowerAscii(filenameParts.ext) != ".json":
invalidFlag = true
continue

# In case we are importing from eth2.0-deposits-cli, the imported
# validator_keys directory will also include a "deposit_data" file
# intended for uploading to the launchpad. We'll skip it to avoid
# the "Invalid keystore" warning that it will trigger.
if filenameParts.name.startsWith("deposit_data"):
invalidFlag = true
continue

hasValid = true

let keystore =
try:
Json.loadFile(file, Keystore,
Expand Down Expand Up @@ -1892,6 +1904,10 @@ proc importKeystoresFromDir*(rng: var HmacDrbgContext, meth: ImportMethod,

if password.len == 0:
break
if not hasValid and invalidFlag:
fatal "No valid keystore file found; the keystore file must have a .json extension and not start with deposit_data"
quit 1

except OSError:
fatal "Failed to access the imported deposits directory"
quit 1
Expand Down
Loading