Repository navigation
Log the actual wallet file version and no longer publicly expose the "version" record - #15588
Conversation
|
Just to clarify, is the only user-visible change here replacing: with ? |
| bool fTmp = fReadOnly; | ||
| fReadOnly = false; | ||
| WriteVersion(CLIENT_VERSION); | ||
| Write(std::string("version"), CLIENT_VERSION); |
There was a problem hiding this comment.
Maybe something for a separate PR, but can we just drop this write entirely? It seems redundant given the write already in WalletBatch::LoadWallet, and better not to write the same field in two different places.
There was a problem hiding this comment.
I'm not sure that this is redundant. It's making sure that the version field exists, whereas WalletBatch::LoadWallet doesn't necessarily do that.
But we can remove this in a separate PR if it is redundant.
Yes. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
utACK 96a46f5 |
|
@meshcollider can you please take a look here |
jb55
left a comment
There was a problem hiding this comment.
Concept ACK, I reviewed the changes in detail and confirmed they make sense logically. I have a few comments before I Approach ACK. Let me know what you think.
|
|
||
| if (last_client < CLIENT_VERSION) // Update | ||
| WriteVersion(CLIENT_VERSION); | ||
| m_batch.Write(std::string("version"), CLIENT_VERSION); |
There was a problem hiding this comment.
I'm ok with open-coding this here since there is only one use of it, but for semantic clarity nit we could have just moved it into a static method named {Read,Write}LatestClientVersion or something.
There was a problem hiding this comment.
I prefer to leave it as is since these are the only uses of it. I had originally planned on removing these reads and writes entirely, but I was not certain that doing so wouldn't break backwards compatibility so I left them in.
| } | ||
| } else if (strType != "bestblock" && strType != "bestblock_nomerkle" && | ||
| strType != "minversion" && strType != "acentry") { | ||
| strType != "minversion" && strType != "acentry" && strType != "version") { |
There was a problem hiding this comment.
Leaving this comment for other reviewers when trying to understand it. The wallet logs any unknown records, since we're not handling the version record specifically anymore (it was a no-op), we don't want to log version as an unknown record. It is still read-in during LoadWallet.
nFileVersion is not the actual file version and is not used except in one place. So it is removed from CWalletScanState and changed so that it is just read at the place it is needed. Furthermore, the "version" record now only indicates the version of the highest versioned client that has opened a wallet file so the variable name is changed accordingly
The actual wallet file version is the minversion record, not the version record.
The "version" record that these functions read and write are not used anywhere in the code except for one place. There is no reason to expose these functions publicly. Furthermore, this avoids potential confusion as developers may mistake these functions for actually reading and writing the wallet version when they do not.
96a46f5 to
35e60e7
Compare
|
ACK 35e60e7, I compiled locally as a quick sanity check. |
meshcollider
left a comment
There was a problem hiding this comment.
Looks good, thanks! utACK 35e60e7
…ly expose the "version" record 35e60e7 Remove ReadVersion and WriteVersion (Andrew Chow) b3d4f6c Log the actual wallet file version (Andrew Chow) c88e87c Remove nFileVersion from CWalletScanState (Andrew Chow) Pull request description: The wallet file version is stored in the "minversion" record, not the "version" record. However "version" is no longer used anywhere except to record the highest versioned client which has opened a wallet file (which is currently only used to check whether this was most recently opened by a 0.4.0 or 0.5.0rc1 client which had a broken wallet encryption implementation). Furthermore, "version" was logged to the debug.log which is confusing because it is not the actual wallet file version. This PR changes it so that this confusion largely no longer exists. The wallet file version logging is changed to use "minversion" and reading and writing the "version" record is no longer publicly exposed to prevent potential confusion about whether the actual file version is being read or written. Lastly, in the one place it is actually used, the variable name is changed from nFileVersion to last_client to better reflect what that record actually represents. ACKs for top commit: jb55: ACK 35e60e7, I compiled locally as a quick sanity check. ryanofsky: utACK 35e60e7. This code still pretty confusing, but a little simpler now. And the previous log statement was really misleading and useless compared to the new one here. meshcollider: Looks good, thanks! utACK 35e60e7 Tree-SHA512: f782b2f215d07fbc9b806322bda8085445b81c02b65ca674a8c6a3e1de505a0abd050669afe0ead4778816144a1c18462e13930071cedb7227a058aeb39493f7
… publicly expose the "version" record 35e60e7 Remove ReadVersion and WriteVersion (Andrew Chow) b3d4f6c Log the actual wallet file version (Andrew Chow) c88e87c Remove nFileVersion from CWalletScanState (Andrew Chow) Pull request description: The wallet file version is stored in the "minversion" record, not the "version" record. However "version" is no longer used anywhere except to record the highest versioned client which has opened a wallet file (which is currently only used to check whether this was most recently opened by a 0.4.0 or 0.5.0rc1 client which had a broken wallet encryption implementation). Furthermore, "version" was logged to the debug.log which is confusing because it is not the actual wallet file version. This PR changes it so that this confusion largely no longer exists. The wallet file version logging is changed to use "minversion" and reading and writing the "version" record is no longer publicly exposed to prevent potential confusion about whether the actual file version is being read or written. Lastly, in the one place it is actually used, the variable name is changed from nFileVersion to last_client to better reflect what that record actually represents. ACKs for top commit: jb55: ACK 35e60e7, I compiled locally as a quick sanity check. ryanofsky: utACK 35e60e7. This code still pretty confusing, but a little simpler now. And the previous log statement was really misleading and useless compared to the new one here. meshcollider: Looks good, thanks! utACK 35e60e7 Tree-SHA512: f782b2f215d07fbc9b806322bda8085445b81c02b65ca674a8c6a3e1de505a0abd050669afe0ead4778816144a1c18462e13930071cedb7227a058aeb39493f7
… publicly expose the "version" record
merge bitcoin#15588...bitcoin#16475: backports
The wallet file version is stored in the "minversion" record, not the "version" record. However "version" is no longer used anywhere except to record the highest versioned client which has opened a wallet file (which is currently only used to check whether this was most recently opened by a 0.4.0 or 0.5.0rc1 client which had a broken wallet encryption implementation). Furthermore, "version" was logged to the debug.log which is confusing because it is not the actual wallet file version.
This PR changes it so that this confusion largely no longer exists. The wallet file version logging is changed to use "minversion" and reading and writing the "version" record is no longer publicly exposed to prevent potential confusion about whether the actual file version is being read or written. Lastly, in the one place it is actually used, the variable name is changed from nFileVersion to last_client to better reflect what that record actually represents.