Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jnano on March 05, 2019, 01:27:19 AM



Title: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 05, 2019, 01:27:19 AM
Since upgrading from v0.15 to v0.17 the log shows:
Unknown wallet records: 1

Can this be considered normal? What might the unknown record be?


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: Pmalek on March 05, 2019, 03:42:13 PM
I am not sure what you are trying to do when you get this error. That error seems to appear when you try to load too many wallets in bitcoin core due to limitations in memory. If you have too many wallets you might have ran out of memory to store them. 

Have a look at this and see if this is what you are doing as well.
https://bitcoin.stackexchange.com/questions/82954/bitcoin-core-0-17-fails-after-loading-too-many-wallets


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 06, 2019, 12:03:39 AM
2 wallet files.

It's logged on every startup of Core.



Title: Re: Is "Unknown wallet records" >0 normal?
Post by: khaled0111 on March 06, 2019, 12:50:36 AM
Maybe because the wallet is encrypted.

I think this code is the one generating the message you got:

Code:
LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. Unknown wallet records: %u\n",
           wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, wss.m_unknown_records);

debug log number of unknown wallet records on load #12888 (https://github.com/bitcoin/bitcoin/pull/12888/files)


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 06, 2019, 02:51:50 AM
Yeah, it's encrypted, with 0 plaintext keys.
How does this lead to the unknown one?


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: Heisenberg_Hunter on March 11, 2019, 06:48:00 AM
The primary question is "Are you trying to upgrade the wallet and that is when this error comes in the debug.log?"
If not, what are you trying to achieve?
The unknown wallet records has occured in v0.17 due to the fact that there has been significant changes in the code between 0.15 and 0.17

The v0.15 code didn't consist of the unknown wallet record line and they were like

Code:
nKeys = nCKeys = nWatchKeys = nKeyMeta = 0;
...
LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total\n",
           wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys);

While in the v0.17, unknown wallet records has been added replacing the older lines and they were like

Code:
nKeys = nCKeys = nWatchKeys = nKeyMeta = m_unknown_records = 0;
...
} else if (strType != "bestblock" && strType != "bestblock_nomerkle"){
            wss.m_unknown_records++;
...
LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. Unknown wallet records: %u\n",
           wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, wss.m_unknown_records);

Going by the code, the unknown records are initially assigned to 0, but if the string type is not equal to the bestblock and bestblock_nomerkle value, unknown records seems to increase to 1 value and as such they are printed in the Unknown Wallet Records in the below line. (I am not completely sure of this, if this seems to be wrong someone try to correct me)

You should post the debug.log file here, so that we can get a clear insight on what is happening.
Probably if the wallet is encrypted, upgradewallet command will not work.


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 12, 2019, 01:59:20 AM
I'm not trying to achieve anything other than understand the root cause.

The wallet was created in v0.15. I never ran with -upgradewallet (not explicitly anyway), though since the second start with v0.17 the wallet files have nFileVersion = 170001. Each wallet file shows an equal number (for that wallet) of "encrypted", "w/ metadata", and "total" records, and 0 plaintext.
Do I need to manually -upgradewallet to fully enable v0.16/0.17/segwit features?

If that's the reason for a single unknown record, how would one go about upgrading an encrypted wallet?
Issue #14422 (https://github.com/bitcoin/bitcoin/issues/14422) doesn't suggest a solution.

Yes, I know the log message format was changed in the newer version, I can read the nearby code fine. But that doesn't clarify the core reason because I've no idea whether or not the presence of other strTypes is normal or expected. If it's simply the result of using an encrypted wallet file created before v0.16, that's a misleading log message that should, perhaps, be improved.


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: achow101 on March 12, 2019, 04:33:16 AM
This is a known bug and has been fixed: https://github.com/bitcoin/bitcoin/pull/13967. The error is nothing to be worried about and can be safely ignored. All that happened is that we forgot a to handle a record type in the main wallet database reading loop (the record is read before this loop) in the change that adds logging of unknown records in that loop.


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 13, 2019, 01:11:20 AM
Thanks for explaining.

Is doing a manual -upgradewallet normally necessary, and if so, is encryption a hindrance?
nFileVersion has changed by itself between 0.15 and 0.17, so by the looks of it it's automatic in this case.



Title: Re: Is "Unknown wallet records" >0 normal?
Post by: achow101 on March 13, 2019, 04:14:17 AM
The warning you are seeing has nothing to do with whether or not your wallet has been upgraded. That warning is simply the result of new error logging code. In fact, the record that is unknown is one that has been in Bitcoin Core for an extremely long time. It may even be present in the very first version of the Bitcoin client.

Is doing a manual -upgradewallet normally necessary,
Yes. The wallet will not be upgraded automatically for you.

and if so, is encryption a hindrance?
No.

nFileVersion has changed by itself between 0.15 and 0.17, so by the looks of it it's automatic in this case.
nFileVersion is completely unrelated to wallet upgrades. It is in fact completely unused and only kept around for backwards compatibility reasons. It only indicates the highest version client that has opened a wallet file (because that was important in the past).


Title: Re: Is "Unknown wallet records" >0 normal?
Post by: jnano on March 13, 2019, 07:45:18 PM
I know the wallet.dat version is unrelated, I just thought I'd ask since it was brought up earlier.
I'd best start a new thread.