-
Notifications
You must be signed in to change notification settings - Fork 416
refactor(esplora): clear remaining panic paths #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
evanlinjin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
Some great simplifications in logic. Some parts are over-engineered.
Note that panics and expects indicate that "we should never hit this - unless there is a bug!" and I think it's justified to have them (where reasonable).
|
Updated PR due to great feedback from Evan, Mammal, Leonardo. Noteworthy:
|
evanlinjin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid returning errors for internal logic bugs in BDK itself.
crates/esplora/src/lib.rs
Outdated
| pub enum Error { | ||
| Client(esplora_client::Error), | ||
| Checkpoint(CheckPoint<BlockHash>), | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're missing doc-comments for the Error type and it's variants!
We should make it obvious to the reader when the Error::CheckPoint variant occurs.
Edit: I don't think the CheckPoint variant is needed, so this Error type is not needed either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good, Error type removed
crates/esplora/src/blocking_ext.rs
Outdated
| tip = tip | ||
| .extend(conflicts.into_iter().rev().map(|b| (b.height, b.hash))) | ||
| .expect("evicted are in order"); | ||
| .map_err(Error::Checkpoint)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think panic/expect here is more appropriate.
CheckPoint::extendonly errors if a block is not higher than the previous.- The logic to populate
conflictsuses heights fromlocal_tip.local_tipis guaranteed to have ordered heights (since it is aCheckPointtype).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, I reverted this so it uses expect again
a5bf97f to
d4244e3
Compare
|
I believe all review comments are addressed now; to recap current state this PR adds logic around removing panic tied to remote input, while leaving panics where appropriate based on PR review feedback. Thanks again for taking time to review this as I iterated on it (happy to continue tweaking if needed)! |
ValuedMammal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK d4244e3
Note: I think it would make sense to use gap_limit = stop_gap.max(parallel_requests). Related discussion #2053 (comment) and bitcoindevkit/bdk_wallet#63.
@ValuedMammal I just updated PR to use |
|
Need to debug a CI fail. Maybe try rebasing this PR onto master. Edit: As a workaround, pinning the rust toolchain to ACK 074aed1 |
|
This is a bit of a blocker for the 2.3 release of bdk-ffi, I'd like to include it in there if possible. @reez do you mind trying the pin workaround proposed by @ValuedMammal? |
@thunderbiscuit sure let me give my context @ValuedMammal has ACK’d this PR a few times, so after his last comment #2053 (comment) and because I didn’t want him to have to keep review+ACK’ing if no change actually needed on this PR I pinged him to ask if he wanted me to try either/both of those in this PR or keep the PR as is. My understanding is keep the PR as is (and maybe there would be a new issue opened scoped to resolve the coverage job), so I explicitly did not do the pin workaround for those reasons. Additionally @oleonardolima has reviewed this previously and also let me know he’d be giving this PR a final review too, I know he’s been traveling a bunch though so there’s no rush from me on that. Then from the bdk-ffi side of things my view point is this would be nice-to-have but is not a blocker for 2.3 release. |
The CI fix is now in a separate PR #2080. |
|
Thanks for the heads up! I'll try to keep an eye on that PR so when it gets merged I can rebase this PR on it if needed for this PR to be merged. |
ValuedMammal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 92dc6dd
Description
This PR clears remaining panic paths from bdk_esplora, replacing them with proper error handling.
Attempting to address bitcoindevkit/bdk_wallet#30 for Esplora
Notes to the reviewers
Open to any and all feedback on this.
Other PR's made along these lines:
unwrap()s andexpect()s #1981 (electrum)chain_updateerrors if no point of connection #1971 (esplora)Changelog notice
bdk_esplora.rs.Checklists
All Submissions:
New Features:
Bugfixes: