p2p: Avoid InitError when downgrading peers.dat#24201
Conversation
|
Part of the reason why I am using strncmp is because AddrMan (AddrManImpl) -> Unserialize might be called somewhere else, so I didn't want to touch it. I should probably re-work AddrManImpl to use a new exception class that wraps around std::ios_base::failure and only throw exception in the case of version mismatch... but I wanted to get feedback first. |
|
Yeah, I think it should be thrown directly where the version is read |
|
Fixed. Also, 2 jobs on the first commit's CI have been running for 10 hours... is this caused by my strncmp? |
|
On second look, I wonder if we should also |
kallewoof
left a comment
There was a problem hiding this comment.
ACK 96c9d9c7efa13128df74cebf8dda7d1e5db1f9c6
|
Squashed. |
luke-jr
left a comment
There was a problem hiding this comment.
utACK, w/ some thoughts for improvement (can be followups)
|
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. |
|
Assigned 23.0 |
|
@junderw: Can you explain why you made this WIP? One of multiple considerations for whether it should be included in the 23.0 milestone or not. |
|
Sorry, I misunderstood. I made it WIP because I thought I still hadn't finished all the outstanding issues with the PR. After reviewing my own commit I understand I was just confused. There's a spelling error I'll fix right now. |
|
Unrelated test failed for some reason. |
I don't think that's an issue Maybe you can follow 1 or 2 or both:
|
fixes bitcoin#24188 When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one, while creating a backup in peers.dat.bak.
|
Squashed all commits into one. |
|
Sorry for the confusion @junderw :) Great to see this has been merged. Thanks! |
d41ed32 p2p: Avoid InitError when downgrading peers.dat (junderw) Pull request description: fixes bitcoin#24188 (also see bitcoin#22762 (comment)) When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded Bitcoin Core version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one. ACKs for top commit: prayank23: reACK bitcoin@d41ed32 kallewoof: reACK d41ed32 Tree-SHA512: c8e625fe36ce0b1aab6c8ef7241c8954038bb856f2de27bdc4814dc9a60e51be28815c7d77d0f96eace49687a0cea02deb713978bbd3a5add742f50a675f2a40
Summary: ``` When downgrading, a peers.dat with a future version that has a minimum required version larger than the downgraded version would cause an InitError. This commit changes this behavior to overwrite the existing peers.dat with a new empty one, while creating a backup in peers.dat.bak. ``` Backport of [[bitcoin/bitcoin#24201 | core#24201]]. This can't be used with the recent v4 format update but will make for a better UX if the peers.dat format is changed in the future. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Differential Revision: https://reviews.bitcoinabc.org/D12348
fixes #24188 (also see #22762 (comment))
When downgrading, a peers.dat with a future version that has a minimum
required version larger than the downgraded Bitcoin Core version would cause an InitError.
This commit changes this behavior to overwrite the existing peers.dat with
a new empty one.