Refactor Taproot to use `LeafScript` instead of tuple in APIs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the taproot module APIs that use (TapScriptBuf, LeafVersion) and the TaprootSpendInfo map type. The issue asks maintainers to choose among several API and storage designs, including unsafe layout changes; no implementation path or tests are specified, so done means reaching a design decision before making the refactor.
Written by the indexing model from the issue text.
Description
The taproot module contains a bunch of things that use (TapScriptBuf, LeafVersion) (to-be-renamed to TaprootLeaf) instead of LeafScript. The dedicated type would be nicer as it could provide convenience methods, easier remembering of which field is which, shorter name...
I plan to do this but I have also figured out a way to bypass the annoying limitation of BTreeMap (and HashMap) around Borrow, so that we could access the map using LeafScript<&TaprootLeaf> instead of forcing owned keys! (Technically, it needs to go through conversion that is explicit but internally no-op) However this requires (reasonable) unsafe internally and specific layout of LeafScript. We have these options:
- Force using
LeafScript<Box<TaprootLeaf>>instead ofLeafScript<TaprootLeafBuf>as the key stored in the map - this dropscapacitywhich could be a good thing, if the keys are generally produced as fixed (likely) and havelen == capacity(I don't think likely) but could also hurt performance if the capacity needs to shrink (and even worse if it needs to regrow but I don't see people taking out the scripts and then appending something to them as realistic) - Add and publicly expose an additional
LeafScriptBufwrapper type that hacks this (it needs to storeLeafScript<NonNull<TaprootLeaf>>andcapacityseparately). This increases our API surface, and may store capacity uselessly. - We can also support both (if we do the second, the first is trivial to add) but we need to choose one for
TaprootSpendInfounless we want to complicate the API by adding a generic parameter to it, which seems annoying although it could also allow usingHashMapinstead ofBTreeMapwhich appears interesting. - We can instead wrap the map, so that
ScriptMerkleProofMapbecomes a proper newtype and delegate all the API. This could even selectHashMapinternally instdbuilds, keeps the door open for changes but decreases interoperability withstdmaps. We could have conversions but those might or might not be costly and we wouldn't be able to guarantee performance here. And we would need to write a lot of boilerplate to delegate everything. (Though LLMs should be able to do this.)
So which solution do we want?
I personally think first seems the best but the last is also a bit tempting.
- Dominant language
- Rust
- Stars
- 2.7k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 41
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-bitcoin/rust-bitcoin
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-bitcoin/rust-bitcoin#7291 ·
Maintainers usually reply within 1 day
-
primitives: `Witness` is missing functionality to read the items in reverse orderPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
rust-bitcoin/rust-bitcoin#7176 · 8 comments ·
Maintainers usually reply within 1 day
-
p2p: `VersionMessage` decoding rejects a missing relay byte, which BIP37 makes optionalPossibly taken @nyonson claimed this 27 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
rust-bitcoin/rust-bitcoin#7073 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-bitcoin/rust-bitcoin#6793 · 30 comments ·
Maintainers usually reply within 1 day
-
Use ubuntu 26 in CIPossibly taken @Yunusabdul38 claimed this 203 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-bitcoin/rust-bitcoin#6175 · 3 comments ·
Maintainers usually reply within 1 day
All issues in rust-bitcoin/rust-bitcoin
Similar issues
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area: engine bug needs milestone
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Mudcrab-Team/mudcrab#1197 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
zeabur-oss/builder#304 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prometheion/ares#159 ·
Maintainers usually reply within 1 day
-
Multi-select question chips show no picked state; on touch the last tap looks like the only pickOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
eliasstravik/herdr-projects#1710 · 1 comment ·