ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
46.68k stars 19.67k forks source link

Unlock multipe accounts doesn't work when passed via comma separated and throws error "Fatal: Failed to unlock account <second_account_address_here> " #26068

Closed sahilrajput03 closed 1 year ago

sahilrajput03 commented 1 year ago

System information

Geth version: geth version:

Geth
Version: 1.10.25-stable
Git Commit: 69568c554880b3567bace64f8848ff1be27d084d
Git Commit Date: 20220915
Architecture: amd64
Go Version: go1.19.1
Operating System: linux
GOPATH=
GOROOT=

CL client & version: Kitty Terminal OS & Version:

                   -`                    array@arch-os
                  .o+`                   -------------
                 `ooo/                   OS: Arch Linux x86_64
                `+oooo:                  Host: HP Notebook
               `+oooooo:                 Kernel: 5.19.10-arch1-1
               -+oooooo+:                Uptime: 8 days, 7 hours, 43 mins
             `/:-:++oooo+:               Packages: 1606 (pacman)
            `/++++/+++++++:              Shell: bash 5.1.16
           `/++++++++++++++:             Resolution: 1920x1080
          `/+++ooooooooooooo/`           WM: i3
         ./ooosssso++osssssso+`          Theme: Materia-dark [GTK2], Adwaita [GTK3]
        .oossssso-````/ossssss+`         Icons: Papirus [GTK2], Adwaita [GTK3]
       -osssssso.      :ssssssso.        Terminal: tmux
      :osssssss/        osssso+++.       CPU: Intel i5-6200U (4) @ 2.800GHz
     /ossssssss/        +ssssooo/-       GPU: AMD ATI Radeon HD 8670A/8670M/8690M / R5 M330 / M430 / Radeon 520 Mobile
   `/ossssso+/:-        -:/+osssso+-     GPU: Intel Skylake GT2 [HD Graphics 520]
  `+sso+:-`                 `.-/+oso:    Memory: 4241MiB / 7849MiB

Expected behaviour

It should unlock all the accounts

Actual behaviour

It just unlocks first account and throws error saying the "address 2" can't be unlocked with given password.

Steps to reproduce the behaviour

Run this script: ./runBootNode.sh file from this file: Click here with that line uncommented and comment line: 25.

image

Backtrace

array@arch-os prod_mode$ ./startBootNode.sh
INFO [10-30|00:34:01.678] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:01.678] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:01.679] Set global gas cap                       cap=50,000,000
Address: {f1c8471df8772d9ace6fa116d5c5f077a3b7afe6}
INFO [10-30|00:34:04.039] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:04.039] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:04.040] Set global gas cap                       cap=50,000,000
Address: {d2fcf98a201fa4319f5856503e9f05df01ed2dda}
INFO [10-30|00:34:06.518] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:06.519] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:06.520] Set global gas cap                       cap=50,000,000
Address: {f67187621a1ce42ebcec146d644a2c321e3efa45}
INFO [10-30|00:34:08.945] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:08.945] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:08.946] Set global gas cap                       cap=50,000,000
Address: {506b010ff4b7f16ccab0b31453f4811564678b25}
INFO [10-30|00:34:11.451] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:11.453] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:11.456] Set global gas cap                       cap=50,000,000
INFO [10-30|00:34:11.458] Allocated cache and file handles         database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/chaindata cache=16.00MiB handles=16
INFO [10-30|00:34:11.475] Opened ancient database                  database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/chaindata/ancient/chain readonly=false
INFO [10-30|00:34:11.475] Writing custom genesis block
INFO [10-30|00:34:11.476] Persisted trie from memory database      nodes=6 size=850.00B time="55.574µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [10-30|00:34:11.476] Successfully wrote genesis state         database=chaindata hash=05866b..fcd9f4
INFO [10-30|00:34:11.476] Allocated cache and file handles         database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/lightchaindata cache=16.00MiB handles=16
INFO [10-30|00:34:11.490] Opened ancient database                  database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/lightchaindata/ancient/chain readonly=false
INFO [10-30|00:34:11.490] Writing custom genesis block
INFO [10-30|00:34:11.491] Persisted trie from memory database      nodes=6 size=850.00B time="51.01µs"  gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [10-30|00:34:11.491] Successfully wrote genesis state         database=lightchaindata hash=05866b..fcd9f4
INFO [10-30|00:34:11.529] Maximum peer count                       ETH=50 LES=0 total=50
INFO [10-30|00:34:11.530] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [10-30|00:34:11.534] Snap sync requested, enabling --snapshot
INFO [10-30|00:34:11.534] Set global gas cap                       cap=50,000,000
INFO [10-30|00:34:11.536] Allocated trie memory caches             clean=154.00MiB dirty=256.00MiB
INFO [10-30|00:34:11.536] Allocated cache and file handles         database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/chaindata cache=512.00MiB handles=262,144
INFO [10-30|00:34:11.553] Opened ancient database                  database=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/chaindata/ancient/chain readonly=false
INFO [10-30|00:34:11.553]
INFO [10-30|00:34:11.554] ---------------------------------------------------------------------------------------------------------------------------------------------------------
INFO [10-30|00:34:11.554] Chain ID:  1337 (unknown)
INFO [10-30|00:34:11.554] Consensus: Clique (proof-of-authority)
INFO [10-30|00:34:11.554]
INFO [10-30|00:34:11.554] Pre-Merge hard forks:
INFO [10-30|00:34:11.554]  - Homestead:                   0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/homestead.md)
INFO [10-30|00:34:11.554]  - Tangerine Whistle (EIP 150): 0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/tangerine-whistle.md)
INFO [10-30|00:34:11.554]  - Spurious Dragon/1 (EIP 155): 0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)
INFO [10-30|00:34:11.554]  - Spurious Dragon/2 (EIP 158): 0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/spurious-dragon.md)
INFO [10-30|00:34:11.554]  - Byzantium:                   0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/byzantium.md)
INFO [10-30|00:34:11.554]  - Constantinople:              0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/constantinople.md)
INFO [10-30|00:34:11.554]  - Petersburg:                  0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/petersburg.md)
INFO [10-30|00:34:11.554]  - Istanbul:                    0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/istanbul.md)
INFO [10-30|00:34:11.554]  - Berlin:                      0        (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/berlin.md)
INFO [10-30|00:34:11.554]  - London:                      <nil> (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/london.md)
INFO [10-30|00:34:11.554]
INFO [10-30|00:34:11.554] The Merge is not yet available for this network!
INFO [10-30|00:34:11.554]  - Hard-fork specification: https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/paris.md
INFO [10-30|00:34:11.554] ---------------------------------------------------------------------------------------------------------------------------------------------------------
INFO [10-30|00:34:11.554]
INFO [10-30|00:34:11.554] Initialising Ethereum protocol           network=1337 dbversion=<nil>
INFO [10-30|00:34:11.555] Loaded most recent local header          number=0 hash=05866b..fcd9f4 td=1 age=53y7mo4d
INFO [10-30|00:34:11.555] Loaded most recent local full block      number=0 hash=05866b..fcd9f4 td=1 age=53y7mo4d
INFO [10-30|00:34:11.555] Loaded most recent local fast block      number=0 hash=05866b..fcd9f4 td=1 age=53y7mo4d
WARN [10-30|00:34:11.555] Failed to load snapshot, regenerating    err="missing or corrupted snapshot"
INFO [10-30|00:34:11.555] Rebuilding state snapshot
INFO [10-30|00:34:11.556] Resuming state snapshot generation       root=f8752f..ba677c accounts=0 slots=0 storage=0.00B dangling=0 elapsed="234.585µs"
INFO [10-30|00:34:11.556] Regenerated local transaction journal    transactions=0 accounts=0
INFO [10-30|00:34:11.556] Generated state snapshot                 accounts=4 slots=0 storage=188.00B dangling=0 elapsed="724.948µs"
INFO [10-30|00:34:11.556] Gasprice oracle is ignoring threshold set threshold=2
WARN [10-30|00:34:11.556] Error reading unclean shutdown markers   error="leveldb: not found"
WARN [10-30|00:34:11.556] Engine API enabled                       protocol=eth
WARN [10-30|00:34:11.556] Engine API started but chain not configured for merge yet
INFO [10-30|00:34:11.556] Stored checkpoint snapshot to disk       number=0 hash=05866b..fcd9f4
INFO [10-30|00:34:11.557] Starting peer-to-peer node               instance=Geth/v1.10.25-stable-69568c55/linux-amd64/go1.19.1
INFO [10-30|00:34:11.566] New local node record                    seq=1,667,070,251,564 id=1e9c4fbba64aa0fa ip=127.0.0.1 udp=30303 tcp=30303
INFO [10-30|00:34:11.567] Started P2P networking                   self=enode://8979ae9f16da94efac383a4ccde4ae1c97643ebb8d608069a6b79e1f13ec3bb871625ccc95d6c258cd7cf991391e695e6d47f4a786ff67ecc518ef374bb18a95@127.0.0.1:30303
INFO [10-30|00:34:11.568] IPC endpoint opened                      url=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth.ipc
INFO [10-30|00:34:11.568] Generated JWT secret                     path=/home/array/test/blockchain/learn-geth/prod_mode/bootNode/geth/jwtsecret
INFO [10-30|00:34:11.569] HTTP server started                      endpoint=127.0.0.1:8545 auth=false prefix= cors= vhosts=localhost
INFO [10-30|00:34:11.570] WebSocket enabled                        url=ws://127.0.0.1:8551
INFO [10-30|00:34:11.570] HTTP server started                      endpoint=127.0.0.1:8551 auth=true  prefix= cors=localhost vhosts=localhost
INFO [10-30|00:34:12.804] Unlocked account                         address=0xF1C8471dF8772D9ACE6fa116d5C5f077A3b7AFe6
INFO [10-30|00:34:13.424] New local node record                    seq=1,667,070,251,565 id=1e9c4fbba64aa0fa ip=49.156.78.155 udp=30303 tcp=30303
WARN [10-30|00:34:15.659] Snapshot extension registration failed   peer=5df314b4 err="peer connected on snap without compatible eth support"
Fatal: Failed to unlock account 0xd2fCf98a201FA4319f5856503e9F05dF01eD2DDA (could not decrypt key with given password)

array@arch-os prod_mode$

Thanks.

karalabe commented 1 year ago

Check your password file. The password file is newline-separated.

You can have multiple passwords in it, where each line is for a specific account. If there are more accounts than lines, the last one is used to unlock the rest.

Now, there might be a quirk: if your editor automatically adds a trailing newline to the password file, it will be interpreted as containing 2 passwords: the first line, and the second (empty). In that case, account 2 and onwards will be attempted to be unlocked with the empty password, which can fail.

Your password file seems to contain 2 bytes: the character 1 and an invisible control character. Perhaps that's the problem?

$ hexdump my_password.txt 
0000000 0a31                                   
0000002
karalabe commented 1 year ago

Actually, 0a is the newline character, so that's the issue almost certainly.

sahilrajput03 commented 1 year ago

Amazing, @karalabe you are awesome!

Newline character was there as I can see it clearly the issue with echo command. Thanks a lot, I managed to unlock all accounts via that! Thanks a lot!

image

image