prysmaticlabs / prysm

Go implementation of Ethereum proof of stake
https://www.offchainlabs.com
GNU General Public License v3.0
3.47k stars 1.01k forks source link

accounts-v2 import panic if not using default wallet directory #6870

Closed SuburbanDad closed 4 years ago

SuburbanDad commented 4 years ago

🐞 Bug Report

Description

A clear and concise description of the problem... When importing keys into a basic wallet using `prysm.sh validator accounts-v2 import --keys-dir=...` if you are using a non-default location for the wallet, a panic occurs due to segfault (see below). **If you use the default/suggested wallet location, import works fine.** ### Has this worked before in a previous version? Yes, the previous version in which this bug was not present was: .... ## 🔬 Minimal Reproduction

🔥 Error

stack trace:

  
➜  prysm git:(master) ./prysm.sh validator accounts-v2 import --keys-dir=/home/pi/dev/validator_keys
Latest Prysm version is v1.0.0-alpha.18.
Validator is up to date.
Verifying binary integrity.
validator-v1.0.0-alpha.18-linux-arm64: OK
gpg: Signature made Mon 03 Aug 2020 03:08:13 PM PDT
gpg:                using RSA key 0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
gpg: Good signature from "Preston Van Loon " [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0AE0 051D 647B A3C1 A917  AF40 72E3 3E4D F1A5 036E
Verified /home/pi/dev/prysm/dist/validator-v1.0.0-alpha.18-linux-arm64 has been signed by Prysmatic Labs.
Starting Prysm validator accounts-v2 import --keys-dir=/home/pi/dev/validator_keys
Enter a wallet directory (default: /home/pi/.eth2validators/prysm-wallet-v2):
/tmp/test-wallet
[2020-08-04 09:45:43] ERROR main: Runtime panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
runtime/debug.Stack(0x400139d2a8, 0x3620e0, 0x1fc9b70)
        GOROOT/src/runtime/debug/stack.go:24 +0x88
main.main.func9()
        validator/main.go:345 +0x5c
panic(0x3620e0, 0x1fc9b70)
        GOROOT/src/runtime/panic.go:969 +0x11c
github.com/prysmaticlabs/prysm/validator/accounts/v2.(*Wallet).SaveWallet(0x0, 0x40002047c0, 0x40002047c0)
        validator/accounts/v2/wallet.go:221 +0x20
github.com/prysmaticlabs/prysm/validator/accounts/v2.createDirectKeymanagerWallet(0x400020fc80, 0x0, 0x8c2c20, 0x40002047c0)
        validator/accounts/v2/wallet_create.go:61 +0x28
github.com/prysmaticlabs/prysm/validator/accounts/v2.ImportAccount.func1(0x400020fc80, 0x28, 0x0, 0x0)
        validator/accounts/v2/accounts_import.go:29 +0x64
github.com/prysmaticlabs/prysm/validator/accounts/v2.createOrOpenWallet(0x400020fc80, 0x5c9818, 0x4000032000, 0x3bc540, 0x436f60)
        validator/accounts/v2/wallet.go:676 +0x88
github.com/prysmaticlabs/prysm/validator/accounts/v2.ImportAccount(0x400020fc80, 0x7, 0x400020fc80)
        validator/accounts/v2/accounts_import.go:24 +0x4c
github.com/prysmaticlabs/prysm/validator/accounts/v2.glob..func4(0x400020fc80, 0x8, 0xe)
        validator/accounts/v2/cmd_accounts.go:85 +0x28
github.com/urfave/cli/v2.(*Command).Run(0x1fe0b40, 0x400020fa00, 0x0, 0x0)
        external/com_github_urfave_cli_v2/command.go:164 +0x3ec
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0x400021e780, 0x400020f800, 0x0, 0x0)
        external/com_github_urfave_cli_v2/app.go:427 +0x824
github.com/urfave/cli/v2.(*Command).startApp(0x1fe06c0, 0x400020f800, 0x400139dce8, 0x18a10bc)
        external/com_github_urfave_cli_v2/command.go:279 +0x5a4
github.com/urfave/cli/v2.(*Command).Run(0x1fe06c0, 0x400020f800, 0x0, 0x0)
        external/com_github_urfave_cli_v2/command.go:94 +0x838
github.com/urfave/cli/v2.(*App).RunContext(0x400031fe00, 0x8ec4c0, 0x40000ba000, 0x40000a0040, 0x4, 0x4, 0x0, 0x0)
        external/com_github_urfave_cli_v2/app.go:306 +0x620
github.com/urfave/cli/v2.(*App).Run(...)
        external/com_github_urfave_cli_v2/app.go:215
main.main()
        validator/main.go:350 +0x918

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1d6ce88]

goroutine 1 [running]:
main.main.func9()
        validator/main.go:346 +0x10c
panic(0x3620e0, 0x1fc9b70)
        GOROOT/src/runtime/panic.go:969 +0x11c
github.com/prysmaticlabs/prysm/validator/accounts/v2.(*Wallet).SaveWallet(0x0, 0x40002047c0, 0x40002047c0)
        validator/accounts/v2/wallet.go:221 +0x20
github.com/prysmaticlabs/prysm/validator/accounts/v2.createDirectKeymanagerWallet(0x400020fc80, 0x0, 0x8c2c20, 0x40002047c0)
        validator/accounts/v2/wallet_create.go:61 +0x28
github.com/prysmaticlabs/prysm/validator/accounts/v2.ImportAccount.func1(0x400020fc80, 0x28, 0x0, 0x0)
        validator/accounts/v2/accounts_import.go:29 +0x64
github.com/prysmaticlabs/prysm/validator/accounts/v2.createOrOpenWallet(0x400020fc80, 0x5c9818, 0x4000032000, 0x3bc540, 0x436f60)
        validator/accounts/v2/wallet.go:676 +0x88
github.com/prysmaticlabs/prysm/validator/accounts/v2.ImportAccount(0x400020fc80, 0x7, 0x400020fc80)
        validator/accounts/v2/accounts_import.go:24 +0x4c
github.com/prysmaticlabs/prysm/validator/accounts/v2.glob..func4(0x400020fc80, 0x8, 0xe)
        validator/accounts/v2/cmd_accounts.go:85 +0x28
github.com/urfave/cli/v2.(*Command).Run(0x1fe0b40, 0x400020fa00, 0x0, 0x0)
        external/com_github_urfave_cli_v2/command.go:164 +0x3ec
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0x400021e780, 0x400020f800, 0x0, 0x0)
        external/com_github_urfave_cli_v2/app.go:427 +0x824
github.com/urfave/cli/v2.(*Command).startApp(0x1fe06c0, 0x400020f800, 0x400139dce8, 0x18a10bc)
        external/com_github_urfave_cli_v2/command.go:279 +0x5a4
github.com/urfave/cli/v2.(*Command).Run(0x1fe06c0, 0x400020f800, 0x0, 0x0)
        external/com_github_urfave_cli_v2/command.go:94 +0x838
github.com/urfave/cli/v2.(*App).RunContext(0x400031fe00, 0x8ec4c0, 0x40000ba000, 0x40000a0040, 0x4, 0x4, 0x0, 0x0)
        external/com_github_urfave_cli_v2/app.go:306 +0x620
github.com/urfave/cli/v2.(*App).Run(...)
        external/com_github_urfave_cli_v2/app.go:215
main.main()
        validator/main.go:350 +0x918
  

🌍 Your Environment

Operating System: tested on:

  
Ubuntu 18.04/arm64 , Raspberry Pi OS arm64
  

What version of Prysm are you running? (Which release)

  
v1.0.0-alpha.18-linux-arm64
  

Anything else relevant (validator index / public key)?

shayzluf commented 4 years ago

assigned to @rauljordan not sure if this issue got resolved already

rauljordan commented 4 years ago

Closing as unable to reproduce

prestonvanloon commented 4 years ago

This was probably fixed in #6875