You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
6aa81fe test(bitcoind): Test 6-block reorg to `filter_iter_detects_reorgs` test (志宇)
4b295ee docs(bip158): Update `FilterIter` documentation (valued mammal)
2181c4b feat(rpc)!: `FilterIter` API redesign (valued mammal)
Pull request description:
Previously `FilterIter` did not detect or handle reorgs between `next` calls, meaning that if a reorg occurred, we might process blocks from a stale fork potentially resulting in an invalid wallet state. This PR aims to fix that by adding logic to explicitly check for and respond to a reorg on every call to `next`.
### Notes to the reviewers
The old implementation required storing block IDs of scanned blocks before creating a checkpoint update, but because the interface was split across different methods, it introduced a timing risk between method calls which, when we consider the possibility of reorgs, made the implementation somewhat brittle.
To address this, we make sure that 1) Finding the start block and 2) Updating the internal checkpoint are directly tied to the logic of `next`. Since the checkpoint in practice is derived from a clone of the local chain, this ensures that the checkpoint returned by `next` can always find a connection point with the receiver. Additionally we now emit a checkpoint at every height to ensure that any "must-include" heights are not missing.
For example usage see `examples/filter_iter.rs`
fixes#1848
### Changelog notice
Fixed
- `FilterIter` now handles reorgs to ensure consistency of the header chain.
Changed
- `Event` is now a struct instead of enum
Added
- `FilterIter::new` constructor that takes as input a reference to the RPC client, checkpoint, and a list of SPKs.
- `Error::ReorgDepthExceeded` variant
- `Error::TryFromInt` variant
Removed
- `FilterIter::new_with_height`
- `FilterIter::new_with_checkpoint`
- `EventInner` type
- `FilterIter::get_tip`
- `FilterIter::chain_update`
- `Error::NoScripts` variant
### Checklists
#### All Submissions:
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
#### New Features:
* [x] I've added tests for the new feature
* [x] I've added docs for the new feature
#### Bugfixes:
* [x] This pull request breaks the existing API
* [x] I've added tests to reproduce the issue which are now passing
* [x] I'm linking the issue being fixed by this PR
ACKs for top commit:
ValuedMammal:
ACK 6aa81fe
evanlinjin:
ACK 6aa81fe
oleonardolima:
tACK 6aa81fe
LagginTimes:
ACK 6aa81fe
Tree-SHA512: 4aebec0184f9cb0ba601811409cf782ab3ad1536bb2dd1f177b2263df5fe99739a675734aa00b28af1dd1bce77071ac18ac7f2c3e849cbd876a3639981af390a
0 commit comments