Repository navigation
Introduce keyed set structures for inputs and outputs - #109
yuval-block wants to merge 1 commit into
Conversation
9ec4abb to
bd1ba6d
Compare
This comment has been minimized.
This comment has been minimized.
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
|
@xstoicunicornx iirc you had some concerns about representing conflicts between the sets in a previous iteration, i bit the bullet and made this representation more explicit, i thought it would complicate things but having implemented it's simpler than i expected |
bd1ba6d to
3752992
Compare
range-diff for force push bd1ba6d1de → 3752992766
|
3752992 to
128d272
Compare
128d272 to
868947d
Compare
868947d to
1f619ad
Compare
1f619ad to
ba82f99
Compare
range-diff for force push 1f619ad941 → ba82f99d44
|
ba82f99 to
1b40522
Compare
range-diff for force push ba82f99d44 → 1b40522363
|
1 similar comment
range-diff for force push ba82f99d44 → 1b40522363
|
1b40522 to
a6d7b49
Compare
range-diff for force push 1b40522363 → a6d7b49f63
|
range-diff for force push 1b40522363 → a6d7b49f63
|
a6d7b49 to
0b8384f
Compare
range-diff for force push a6d7b49f63 → 0b8384fb5c
|
103b805 to
9442a7d
Compare
range-diff for force push 103b805377 → 9442a7d917
|
9442a7d to
15e3bcc
Compare
range-diff for force push 9442a7d917 → 15e3bcc2f7
|
15e3bcc to
52a877b
Compare
range-diff for force push 15e3bcc2f7 → 52a877bd3e
|
52a877b to
fd8eb7e
Compare
range-diff for force push 52a877bd3e → fd8eb7e9dc
|
fd8eb7e to
bbeaafa
Compare
range-diff for force push fd8eb7e9dc → bbeaafa8bf
|
bbeaafa to
1aa57fc
Compare
range-diff for force push bbeaafa8bf → 1aa57fc30c
|
| /// Entries with the same key are joined, and the rest are unioned. A frozen | ||
| /// set's keys are fixed, so each distinct set of frozen keys is also kept. | ||
| /// The join is clean only if there is at most one distinct frozen key set and | ||
| /// it equals the keys of the entries. So a frozen set joins cleanly with |
There was a problem hiding this comment.
Doc claims same-key frozen joins always clean
ResultKeyedSet's doc says a frozen set joins cleanly with frozen sets of the same keys, but is_ok/try_unwrap also require every entry to be conflict-free; same-key entries with unequal values make the join unclean, as frozen_sets_with_the_same_keys_join_entry_by_entry asserts.
oakagent · automated · 1aa57fc
| } | ||
|
|
||
| impl<K, V> Freezable<K, V> { | ||
| /// Returns the underlying KeyedSet |
There was a problem hiding this comment.
nit:
| /// Returns the underlying KeyedSet | |
| /// Returns the underlying [`KeyedSet`] |
| /// A PSBT's inputs or outputs are frozen once they are no longer modifiable. In a given PSBT this | ||
| /// enum tag must track the `tx_modifiable_flags` in the `Global` struct. |
There was a problem hiding this comment.
Is this trackign done in a different PR ?
There was a problem hiding this comment.
As far as I can tell this PR doesn't care about global flags.
| if !self.frozen.contains(&keys) { | ||
| self.frozen.push(keys); | ||
| } |
There was a problem hiding this comment.
What if it contains only a subset of the keys ?
There was a problem hiding this comment.
that represents a conflict, e.g. PSBT A unmodifiable with {a,b} was merged into PSBT B modifiable with {a, b, c} would have entries {a,b,c} and a frozen key set of {a,b} which is a cnflict
| self.len().is_ok() | ||
| } | ||
|
|
||
| fn add_frozen(&mut self, keys: HashSet<K>) { |
There was a problem hiding this comment.
Its odd that you would want to add mutability to a frozen part of the datastructure. i.e if outputs are "frozen" via global flags we I believe it would violate BIP370 if you added more outputs.
There was a problem hiding this comment.
two PSBTs can disagree on whether or not they are modifiable, in a way that is still coherent to join, e.g. if PSBT A is unmodifiable and has inputs {a,b,c} and PSBT B is modifiable and has inputs {a,b}, then there is no conflict when merging them, and PSBT B may have fields associated with those inputs that merge cleanly into A
This abstraction stores a set of inputs or outputs, keyed by their identifier. This this behaves like the set of identifiers that can union or conflict when joined depending on whether or not it is frozen. Additionally, with each identifier is also associated a value, so this also works like a hashmap. These values are joined recursively, so a set being frozen only means its identifier set is immutable.
1aa57fc to
2e33c8c
Compare
range-diff for force push 1aa57fc30c → 2e33c8cdd8
|
2e33c8c to
b04356d
Compare
range-diff for force push 2e33c8cdd8 → b04356d5b8
|
b04356d to
621eee1
Compare
range-diff for force push b04356d5b8 → 621eee135d
|
621eee1 to
8393653
Compare
range-diff for force push 621eee135d → 839365306e
|
This abstraction stores a set of inputs or outputs, keyed by their identifier.
This this behaves like the set of identifiers that can union or conflict when joined depending on whether or not it is frozen.
Additionally, with each identifier is also associated a value, so this also works like a hashmap. These values are joined recursively, so a set being frozen only means its identifier set is immutable.