-
Notifications
You must be signed in to change notification settings - Fork 406
feat(chain): add new list_ordered_canonical_txs
method
#2027
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: release/chain-0.23.x
Are you sure you want to change the base?
feat(chain): add new list_ordered_canonical_txs
method
#2027
Conversation
6b76092
to
a28cfdf
Compare
Nice diagrams |
08e4ce8
to
70ee41b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
6239c8f
to
0aab769
Compare
d57a580
to
3b79cba
Compare
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.
The internals have completely changed. I don't think a point release would make any sense (we also have already merged other breaking changes). I recommend to just break the API.
Get rid of CanonicalIter
. Just have a single function that returns impl Iterator<Item = ...>
.
0a17091
to
71c3744
Compare
cc0f010
to
ac95bd7
Compare
ac95bd7
to
49bf2b3
Compare
573915f
to
d9b9318
Compare
I don't think you have to deprecate |
I think it's good to guide users towards the method with correct output, but I'm fine with keeping both too.
It's not only reversed, but as we start canonicalizing from any given anchored tx and walk ancestors, it fails to exhaust all the spending ones from it and it's ancestors. |
@ValuedMammal That's a good point about not deprecating Doing |
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.
Looks good. Happy to ACK after we un-deprecate list_canonical_txs
and update it's docs to point to list_ordered_canonical_txs
.
Also, shouldn't this PR point to the chain-0.23.x
branch?
It deprecates the existing `list_canonical_txs` and `try_list_canonical_txs` in favor of `list_ordered_canonical_txs` which guarantees topological ordering. The new `list_ordered_canonical_txs` ensures that spending transactions always appear after their inputs, topologically ordered in "spending order". - Add `TopologicalIterator` for level-based topological sorting - Use the `ChainPosition` for sorting within the same level - Add the new method to the canonicalization benchmarks - Update the new test to verify topological ordering correctness Co-Authored-By: Claude <noreply@anthropic.com>
- Update the `TopologicalIter` to take an Iterator<Item = CanonicalTx<'a, Arc<Transaction>, A> of canonical txs. - Update it's documentation to mention the Kahn's Algorithm. - Update it to use `a_tx.cmp(&b_tx)` instead.
d9b9318
to
9c4da10
Compare
Thanks, I've removed the deprecation in 9664402. It's valid to note that before merging the |
ACK tested locally, and I agree with the test expectations. No real opinion on deprecating |
Description
It introduces a new method for topological ordering canonical transactions,
list_ordered_canonical_txs
. It now ensures the dependency-based transaction processing, guaranteeing that parent transactions always appears before their children transaction.The existing
list_canonical_txs
andtry_list_canonical_txs
methods have been deprecated in favor of the new ordered version.Notes to the reviewers
"[...] For those reviewing, and wondering why we don't have a fallible try version of this method, it's because we don't have a fallible ChainOracle implementation - we will get rid of ChainOracle trait soon anyway."
This PR is intended for a point release so that bdk_wallet 2.x users can get a topologically sorted list of transactions (we need a point release on bdk_wallet 2.x as well).
It might be useful to take a look at the new test scenarios that I've added, it shows some specific scenarios where the current implementation and output of
canonical_txs
didn't output the transactions in topological order.Let me know if you think the TopologicalIter algorithm and/or API could be improved.
Changelog notice
Checklists
All Submissions:
New Features: