eons-finance / ALQO

ALQO is a digital currency that enables instant payments to anyone, anywhere in the world.
MIT License
14 stars 9 forks source link

fFirstRun shouldn't be set unconditionally true in init.cpp #8

Closed walkjivefly closed 4 years ago

walkjivefly commented 4 years ago

Describe the issue

Testing the fix for issue #7, started the new code and it complained about being unable to generate initial key (new chain was previously synced and wallet shutdown normally). Debug.log says

GUI: QGradient::setColorAt: Color position must be specified in the range 0 to 1
GUI: QLayout: Attempting to add QLayout "" to ALQOGUI "", which already has a layout
2019-12-11 18:04:39 AppInit2 : parameter interaction: -listen=0 -> setting -discover=0
2019-12-11 18:04:39 AppInit2 : parameter interaction: -listen=0 -> setting -listenonion=0
2019-12-11 18:04:39
2019-12-11 18:04:39 ALQO version v6.1.0.0-35ba7f1d1 (2019-12-12 01:53:58 +0800)
2019-12-11 18:04:39 Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2019-12-11 18:04:39 Default data directory /home/mark/.alqocrypto
2019-12-11 18:04:39 Using data directory /home/mark/.alqocrypto
2019-12-11 18:04:39 Using config file /home/mark/.alqocrypto/alqo.conf
2019-12-11 18:04:39 Using at most 16 connections (1024 file descriptors available)
2019-12-11 18:04:39 Using 4 threads for script verification
2019-12-11 18:04:39 scheduler thread start
2019-12-11 18:04:39 Binding RPC on address 0.0.0.0 port 20481 failed.
2019-12-11 18:04:39 HTTP: creating work queue of depth 16
2019-12-11 18:04:39 HTTP: starting 4 worker threads
2019-12-11 18:04:39 Creating backup of "/home/mark/.alqocrypto/wallet.dat" -> "/home/mark/.alqocrypto/backups/wallet.dat.2019-12-11-18-04"
2019-12-11 18:04:39 Using wallet wallet.dat
2019-12-11 18:04:39 init message: Verifying wallet...
2019-12-11 18:04:39 CDBEnv::Open: LogDir=/home/mark/.alqocrypto/database ErrorFile=/home/mark/.alqocrypto/db.log
2019-12-11 18:04:39 init message: Loading block index...
2019-12-11 18:04:39 Opening LevelDB in /home/mark/.alqocrypto/zerocoin
2019-12-11 18:04:39 Opened LevelDB successfully
2019-12-11 18:04:39 Opening LevelDB in /home/mark/.alqocrypto/sporks
2019-12-11 18:04:39 Opened LevelDB successfully
2019-12-11 18:04:39 Opening LevelDB in /home/mark/.alqocrypto/blocks/index
2019-12-11 18:04:39 Opened LevelDB successfully
2019-12-11 18:04:39 Opening LevelDB in /home/mark/.alqocrypto/chainstate
2019-12-11 18:04:39 Opened LevelDB successfully
2019-12-11 18:04:39 init message: Loading sporks...
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_2_SWIFTTX found in database
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_3_SWIFTTX_BLOCK_FILTERING found in database
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_5_MAX_VALUE found in database
2019-12-11 18:04:39 LoadSporksFromDB : loaded spork SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT with value 4070908800 : Thu Jan  1 07:00:00 2099

2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT found in database
2019-12-11 18:04:39 LoadSporksFromDB : loaded spork SPORK_10_MASTERNODE_PAY_UPDATED_NODES with value 4070908800 : Thu Jan  1 07:00:00 2099

2019-12-11 18:04:39 LoadSporksFromDB : loaded spork SPORK_13_ENABLE_SUPERBLOCKS with value 4070908800 : Thu Jan  1 07:00:00 2099

2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_14_NEW_PROTOCOL_ENFORCEMENT found in database
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2 found in database
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_16_ZEROCOIN_MAINTENANCE_MODE found in database
2019-12-11 18:04:39 LoadSporksFromDB : no previous value for SPORK_17_CHOKE_CONTROL_MODE found in database
2019-12-11 18:04:39 init message: Loading block index...
2019-12-11 18:04:39 LoadBlockIndexDB: last block file = 0
2019-12-11 18:04:39 LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=2686, size=1198233, heights=0...2685, time=2019-12-05...2019-12-10)
2019-12-11 18:04:39 Checking all blk files are present...
2019-12-11 18:04:39 LoadBlockIndexDB: Last shutdown was prepared: true
2019-12-11 18:04:39 LoadBlockIndexDB(): transaction index enabled
2019-12-11 18:04:39 LoadBlockIndexDB(): hashBestChain=63c7706f3395febea5a1503166b9c7cae99fa514d6d0a8fc84ba0c23c507e562 height=2685 date=2019-12-10 13:27:56 progress=0.871860
2019-12-11 18:04:39 init message: Verifying blocks...
2019-12-11 18:04:39 Verifying last 100 blocks at level 4
2019-12-11 18:04:39 No coin database inconsistencies in last 101 blocks (202 transactions)
2019-12-11 18:04:39  block index             197ms
2019-12-11 18:04:39 init message: Loading wallet...
2019-12-11 18:04:39 nFileVersion = 6010000
2019-12-11 18:04:39 Keys: 0 plaintext, 2002 encrypted, 2002 w/ metadata, 2002 total
2019-12-11 18:04:39 Performing wallet upgrade to 61000
2019-12-11 18:04:47 ERROR: AppInit2 Unable to generate initial key
2019-12-11 18:04:47 PrepareShutdown: In progress...
2019-12-11 18:04:47 StopNode()
2019-12-11 18:04:47 scheduler thread interrupt
2019-12-11 18:04:48 Shutdown: done

Can you reliably reproduce the issue?

If so, please list the steps to reproduce below:

  1. Run the new wallet (QT or daemon) in a clean datadir
  2. Shut it down
  3. Restart it. Bam => "Error: Unable to generate initial key" and it shuts down.

Expected behavior

Second and subsequent runs should not fail to start

Actual behavior

daemon fails with "Error: Unable to generate initial key" QT fails with "thread safe box: Unable to generate initial key" and both shutdown

Screenshots.

If the issue is related to the GUI, screenshots can be added to this issue via drag & drop.

What version of PIVX Core are you using?

ALQO version v6.1.0.0-35ba7f1d1 self-compiled

Machine specs:

Any extra information that might be useful in the debugging process.

fFirstRun probably shouldn't be set unconditionally true in init.cpp

barrystyle commented 4 years ago

This is as it appears in the PIVX codebase; i'm unable to replicate the issue as well..

walkjivefly commented 4 years ago

Pfft, typical. Weirdness follows me around. Maybe you can repro with my .alqocrypto datadir? If not I guess it's something local to my machine which hopefully won't persist once I'm running the official release 6.x linux64 build.

alqocrypto-issue-008.zip

barrystyle commented 4 years ago

Hm actually, did you run the very first 6.0 release binary for linux before this? Try remove ./config/alqocrypto if it exists in your home directory and try again..

walkjivefly commented 4 years ago

Yes, I think I did. Removing the .config/ALQOCRYPTO/ALQO-Qt.conf allowed the QT wallet to start. Shutdown and restarted again OK. Shutdown again and started daemon OK.

Not sure why, since

mark@x230:~/.config/ALQOCRYPTO$ diff ALQO-Qt.conf~ ALQO-Qt.conf
19c19
< lightTheme=false
---
> lightTheme=true
27c27
< nWindowPos=@Point(98 33)
---
> nWindowPos=@Point(95 36)

but I'm not complaining ;-) Closed, thanks for the help.

MiCoSa79 commented 4 years ago

I have the same issue. After running the wallet first time, everything is fine. I can also shut it down and restart it. But as soon as i encrypt the wallet, i cant start it anymore and always get the above Error: Unable to generate initial key Wallet shuts down after the error message. Windows QT-Wallet If i delete the wallet.dat and let the wallet generate a new one after that, everything is fine again, so it seems to me that it has something to do with the encryption.

walkjivefly commented 4 years ago

Ah, good point, @MiCoSa79. I forgot I had encrypted the wallet the first time (just did it automatically and didn't think to mention it). And yes, once the wallet is encrypted it won't restart. Re-opening the issue.

Also, worth mentioning, when the wallet encryption completes and the wallet shuts down it says pivx server stopping

mark@x230:~/src/ALQO/src$ ./alqo-cli encryptwallet "one two three"
wallet encrypted; pivx server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup.
mark@x230:~/src/ALQO/src$ ./alqod
ALQO server starting
mark@x230:~/src/ALQO/src$ Error: Unable to generate initial key

mark@x230:~/src/ALQO/src$ 
barrystyle commented 4 years ago

image Able to reproduce the error.. investigating..

barrystyle commented 4 years ago

Resolved by https://github.com/ALQO-Universe/ALQO/pull/14