Tagged hashes for taproot#259
Conversation
|
Yes, really need that option for implementing both single-use seals and RGB assets: https://github.com/rgb-org/spec/blob/v1.0/01-OpenSeals.md#pay-to-contract |
|
The implementation works now, but is still blocked by the upstream hashes PR. Very interesting, though! |
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
- Coverage 86.19% 81.82% -4.37%
==========================================
Files 39 39
Lines 7394 7026 -368
==========================================
- Hits 6373 5749 -624
- Misses 1021 1277 +256
Continue to review full report at Codecov.
|
7f72d53 to
633ce66
Compare
|
This is where I wish const fn's were more mature. |
|
Now that taproot is getting closer and we're not any closer to be able to do something like that in |
|
This should all work, though. The only issue I was trying to solve last week is the serde serializer and deserializer of the hex value. I can't get it to work over the generic type. I'm getting some errors. I just pushed my update: rust-bitcoin/bitcoin_hashes#42 Feel free to take a look. |
dr-orlovsky
left a comment
There was a problem hiding this comment.
Pls see my comments: looks like this PR should belong to bitcoin_hashes and not here. Also I ask for exporting the macro, which I use in other project.
src/util/taproot.rs
Outdated
There was a problem hiding this comment.
Actually, I'm starting thinking that the whole taproot support in terms of tagged hashes should be part of bitcoin_hashes alike other bitcoin-specific Hash160 etc. While this things are taproot-related, they have no other functionality then pure hash computation.
There was a problem hiding this comment.
Changed my mind after the second thought: #259 (comment)
|
Created my version on top of yours (stevenroose#1); b/c it required rebase onto master now it looks like it worth doing it as a separate PR to master... |
a2ee044 to
e7b7574
Compare
|
@dr-orlovsky I redid this branch a bit with some of your suggestions and also using the |
|
Taproot got merged: bitcoin/bitcoin#19953 Also |
|
So I rebased this PR and it's now mergable using the new bitcoin_hashes version. However, we might want to discuss directly putting these hashes in bitcoin_hashes instead. They are hashes after all.. Not sure if there's merit of having them here separately. I can be convinced of either option, probably. EDIT: Ok I think we should probably have it here in the bitcoin crate. |
|
For me it seems that everything related to transaction- or block-specific data types must reside in |
src/util/taproot.rs
Outdated
There was a problem hiding this comment.
Changed my mind after the second thought: #259 (comment)
|
Rebased. |
apoelstra
left a comment
There was a problem hiding this comment.
utack, but we need to fix the macros for rust 1.29 in bitcoin_hashes.
elichai
left a comment
There was a problem hiding this comment.
I'd really love to see this using const fn but for now this is what we have
ACK
bump version to 6.0.0
* segments cache struct and evict method generalized * save segments to disk made generic inside the segments cache struct * save_dirty_segments logic refactorized * tbh I dont know waht I refactored here * removed io module inside storage/disk * you are right rabbit * store in segment moved to SegmentCache * sentinel headers creation moved to the Persistable trait and encapsulated there * unified sentinel item behaviour - no longer compiles bcs the tip_high calculation * renames * new struct to manage the hashmap of segments and tip height moved - doesnt compile yet, wip * get_headers generalized in the SegmentsCache struct - wip, not compiles * store headers logic moved to the SegmentsCache and introduced method to better handle tip_height and storage index - wip, no compiles * store_headers_impl using precomputed_hashes didn't provide real benefics with the current usage - wip, no compiles * removed unused StorageManager::get_headers_batch methos - wip, no compiles * removed warnings * ensure segment loaded moved inside the SegmentsCache with a logic change, we ask for a segment and if it doesn't exist in memory we load it from disk - wip, no compiles * const MAX_ACTIVE_SEGMENTS encapsulated - wip, no compiles * removed one commit as it is fixed * created a SegmentsCache::store_headers_at_height - wip, no compiles * removed inconsistency when loading segments metadata * removed to methods unused bcs now that behaviour is encapsulated * building SegmentCache yip_height when creating the struct * removed unused function * some refactor and removed the notification enum and related behaviour - wip, no compiles * disk storage manager worker no longer needs cloned headers to work * renamed segments stoage fields * removed new unused function * evict logic removed * save dirty segments logic moved into SegmentsCache * clippy warnings fixed * save dirty is now an instance method for the DiskStorageManager * when persisting segments we try to create the parent dirs to ensure they exist * improved logic to ensure different clear behaviour for SegmentsCache * correctly rebuilding the block reverse index * fixed bug found by test test_checkpoint_storage_indexing * fixed bug updating tip_height in SegmentCache thanks spotted by test test_filter_header_segments * fixed bug, we stop persisting segments after we find the first sentinel, to correctly initialize valid_count - bug spotted by test test_filter_header_persistence * refactor: HEADER_PER_SEGMENT encapsulated inside segment and renamed to ITEMS_PER_SEGMENT - wip, no compiles * block index rebuild logic moved into SegmentCache<BlockHeader> and load_segment_metadata renamed in flavor of a better name for its current behaviour being the block index contructor * added some cool inlines * fixed test that was creating a centinel filter header at height 0 making the segment not persist entirely * renamed header reference to item in segments.rs so its clear that the new struct can work with any struct * clippy warning fixed * logging when storing multiple items simplified * removed sentinel headers from the segments logic * unit tests for the segment and segment_cache structs after the refactor (rust-bitcoin#259) * removed unused methods after rebase * renamed and removed old documentation for store_headers_impl * refactorized and adjusted docs for conversion methods between stoage index, height and offset * removed old comments and forcing to give sync_base_height when creating the SegmentCache * quick fix to load sync_base_height if persisted before * review comments addressed * read block index operation made async * using atomic write where we write to disk
Currently blocked on rust-bitcoin/bitcoin_hashes#93.