Skip to content

introduce joinable variant of PSBT Global struct - #72

Merged
arminsabouri merged 1 commit into
struct-macrofrom
global
Nov 12, 2026
Merged

arminsabouri merged 1 commit into
struct-macrofrom
global

Conversation

@yuval-block

Copy link
Copy Markdown
Collaborator

Add ResultGlobal and GlobalExt so PSBT global fields can be lifted into the result domain, where Join is available and works recursively.

This is the first production expansion of joinable_struct!, so the collection lifting traits introduced earlier become live infrastructure here rather than dormant scaffolding, and their dead_code expectations are removed.

Input and output counts still join as scalar values here. The later UnorderedPsbt commit reconciles counts against the joined input and output sets, because that decision needs both collections in scope.

@yuval-block
yuval-block added this pull request to stack #71 November 11, 2026 19:14
@github-code-quality

github-code-quality Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

struct-macro 9db606e global 1b728dc +/-
100% 100% 0%
View coverage of the 1 most impacted file.
File struct-macro 9db606e global 1b728dc +/-
crates/concurre...struct_macro.rs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 12, 2026 18:59 UTC

@github-actions

Copy link
Copy Markdown
range-diff for force push 88f2159e3a → 2b2df2d609 November 11, 2026 19:32 UTC: 1 modified; 1 commit; same base 9889d0b565

reproduce: git range-diff 9889d0b..88f2159 9889d0b..2b2df2d

1:  88f2159e3a +172 -29 6f ! 1:  2b2df2d609 +178  -1 3f result domain variant of PSBT global fields
1: 88f2159e3a ! 1: 2b2df2d609 result domain variant of PSBT global fields
@@ Commit message
     UnorderedPsbt commit reconciles counts against the joined input and
     output sets, because that decision needs both collections in scope.
 
- ## crates/concurrent-psbt/src/collections/btreemap.rs ##
-@@ crates/concurrent-psbt/src/collections/btreemap.rs: use crate::lattice::join::{Join, JoinMut};
- use crate::lattice::partial::{JoinResult, PartialJoin};
- 
- /// Extension trait for lifting `BTreeMap<K, V>` values to `Ok`, entering the result domain.
--#[cfg_attr(
--    not(test),
--    expect(
--        dead_code,
--        reason = "used once PSBT field types join in the result domain"
--    )
--)]
- pub(crate) trait BTreeMapExt {
-     type Key;
-     type Value: PartialJoin;
-@@ crates/concurrent-psbt/src/collections/btreemap.rs: impl<K: Ord, V: PartialJoin> BTreeMapExt for BTreeMap<K, V> {
- 
- /// Extension trait for `BTreeMap<K, JoinResult<V>>` — `is_ok` checks all values,
- /// `try_unwrap` extracts the plain map or returns `self` on conflict.
--#[cfg_attr(
--    not(test),
--    expect(
--        dead_code,
--        reason = "used once PSBT field types join in the result domain"
--    )
--)]
- pub(crate) trait ResultBTreeMapExt: Sized {
-     type Key;
-     type Value: PartialJoin;
-
- ## crates/concurrent-psbt/src/collections/option.rs ##
-@@ crates/concurrent-psbt/src/collections/option.rs: where
- }
- 
- /// Extension trait for lifting `Option<V>` into the result domain.
--#[cfg_attr(
--    not(test),
--    expect(
--        dead_code,
--        reason = "used once PSBT field types join in the result domain"
--    )
--)]
- pub(crate) trait OptionExt {
-     type Item: PartialJoin;
-     /// Lift each inner value to `Ok`, preserving `None`.
-@@ crates/concurrent-psbt/src/collections/option.rs: impl<V: PartialJoin> OptionExt for Option<V> {
- }
- 
- /// Extension trait for `Option<JoinResult<V>>` — conflict detection and extraction.
--#[cfg_attr(
--    not(test),
--    expect(
--        dead_code,
--        reason = "used once PSBT field types join in the result domain"
--    )
--)]
- pub(crate) trait ResultOptionExt {
-     type Value: PartialJoin;
-     /// Returns `true` if the option is `None` or contains `Ok`.
-
- ## crates/concurrent-psbt/src/lib.rs ##
-@@ crates/concurrent-psbt/src/lib.rs: mod psbt;
- 
- pub use lattice::join::{Join, JoinMut};
- pub use lattice::partial::{Conflict, JoinResult, PartialJoin};
-+pub use psbt::global;
-
  ## crates/concurrent-psbt/src/psbt/global.rs (new) ##
 @@
 +#![allow(clippy::result_large_err)]
++#![cfg_attr(
++    not(test),
++    expect(
++        dead_code,
++        reason = "exported once UnorderedPsbt composes the PSBT types"
++    )
++)]
 +
 +//! PSBT global field merging.
 +//!
@@ crates/concurrent-psbt/src/psbt/mod.rs
 @@
  #[macro_use]
  mod joinable_struct_macro;
-+pub mod global;
++pub(crate) mod global;
  mod values;

@github-actions

Copy link
Copy Markdown
range-diff for force push 2b2df2d609 → 53f1339f66 November 11, 2026 19:43 UTC: 1 unchanged; 1 commit; base 9889d0b565 → 5a2d70eae9 (diverged, 5 ahead and 1 behind)

reproduce: git range-diff 9889d0b..2b2df2d 5a2d70e..53f1339

1:  2b2df2d609 +178 -1 3f = 1:  53f1339f66 +178 -1 3f result domain variant of PSBT global fields

@github-actions

Copy link
Copy Markdown
range-diff for force push 53f1339f66 → 9e4d035276 November 11, 2026 22:43 UTC: 1 modified; 1 commit; base 5a2d70eae9 → 9d3ba507d1 (diverged, 1 ahead and 1 behind)

reproduce: git range-diff 5a2d70e..53f1339 9d3ba50..9e4d035

1:  53f1339f66 +178 -1 3f ! 1:  9e4d035276 +178 -4 3f result domain variant of PSBT global fields
1: 53f1339f66 ! 1: 9e4d035276 result domain variant of PSBT global fields
@@ Commit message
     Add ResultGlobal and GlobalExt so PSBT global fields can be lifted into
     the result domain, where `Join` is available and works recursively.
 
-    This is the first production expansion of joinable_struct!, so the
-    collection lifting traits introduced earlier become live infrastructure
-    here rather than dormant scaffolding, and their dead_code expectations
-    are removed.
+    This is the first expansion of joinable_struct!. The module stays
+    crate-private under a dead_code expectation until UnorderedPsbt
+    composes it with the input and output sets and exports it.
 
     Input and output counts still join as scalar values here. The later
     UnorderedPsbt commit reconciles counts against the joined input and
@@ crates/concurrent-psbt/src/psbt/global.rs (new)
 
  ## crates/concurrent-psbt/src/psbt/joinable_struct_macro.rs ##
 @@
- /// 3. `Join for $Result`
- /// 4. `$Result::is_ok`
- /// 5. `$Result::try_unwrap`
--#[expect(unused_macros, reason = "expanded by the PSBT field types")]
+ /// The field list must name at least one field: `is_ok` is generated as the
+ /// conjunction of the per-field checks, which has no expansion for an empty
+ /// list.
+-#[cfg_attr(
+-    not(all(test, feature = "unit-tests")),
+-    expect(unused_macros, reason = "expanded by the PSBT field types")
+-)]
  macro_rules! joinable_struct {
      // ── Entry point ──────────────────────────────────────────
      (

@github-actions

Copy link
Copy Markdown
range-diff for force push 53f1339f66 → 9e4d035276 November 11, 2026 22:43 UTC: 1 modified; 1 commit; base 5a2d70eae9 → 9d3ba507d1 (diverged, 1 ahead and 1 behind)

reproduce: git range-diff 5a2d70e..53f1339 9d3ba50..9e4d035

1:  53f1339f66 +178 -1 3f ! 1:  9e4d035276 +178 -4 3f result domain variant of PSBT global fields
1: 53f1339f66 ! 1: 9e4d035276 result domain variant of PSBT global fields
@@ Commit message
     Add ResultGlobal and GlobalExt so PSBT global fields can be lifted into
     the result domain, where `Join` is available and works recursively.
 
-    This is the first production expansion of joinable_struct!, so the
-    collection lifting traits introduced earlier become live infrastructure
-    here rather than dormant scaffolding, and their dead_code expectations
-    are removed.
+    This is the first expansion of joinable_struct!. The module stays
+    crate-private under a dead_code expectation until UnorderedPsbt
+    composes it with the input and output sets and exports it.
 
     Input and output counts still join as scalar values here. The later
     UnorderedPsbt commit reconciles counts against the joined input and
@@ crates/concurrent-psbt/src/psbt/global.rs (new)
 
  ## crates/concurrent-psbt/src/psbt/joinable_struct_macro.rs ##
 @@
- /// 3. `Join for $Result`
- /// 4. `$Result::is_ok`
- /// 5. `$Result::try_unwrap`
--#[expect(unused_macros, reason = "expanded by the PSBT field types")]
+ /// The field list must name at least one field: `is_ok` is generated as the
+ /// conjunction of the per-field checks, which has no expansion for an empty
+ /// list.
+-#[cfg_attr(
+-    not(all(test, feature = "unit-tests")),
+-    expect(unused_macros, reason = "expanded by the PSBT field types")
+-)]
  macro_rules! joinable_struct {
      // ── Entry point ──────────────────────────────────────────
      (

@yuval-block
yuval-block marked this pull request as ready for review November 11, 2026 22:48
@yuval-block yuval-block mentioned this pull request Nov 11, 2026
@yuval-block yuval-block changed the title result domain variant of PSBT global fields introduce joinable variant of PSBT Global struct Nov 12, 2026
@oakagent

Copy link
Copy Markdown

@yuval-block 9e4d035 is clean; the ACK waits on one open point and the description:

One open point:

  • crates/concurrent-psbt/src/psbt/global.rs:42 oakagent: "Enabling psbt-v2/silent-payments makes concurrent-psbt fail to compile with E0063 because global.rs omits sp_ecdh_shares and sp_dleq_proofs; is tha..." (no reply yet)

The description:

  • "their dead_code expectations are removed": the collection lifting traits keep their dead_code expectations, and the new global module is pub(crate) under its own dead_code expectation until UnorderedPsbt exports it (crates/concurrent-psbt/src/collections/btreemap.rs:10)

oak · automated

@arminsabouri arminsabouri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeACK
oakagent''s comment makes sense. There are some comments on #68 that should be resolved too. Then the whole stack can be merged

Add ResultGlobal and GlobalExt so PSBT global fields can be lifted into
the result domain, where `Join` is available and works recursively.

This is the first expansion of joinable_struct!. The module stays
crate-private under a dead_code expectation until UnorderedPsbt
composes it with the input and output sets and exports it.

Input and output counts still join as scalar values here. The later
UnorderedPsbt commit reconciles counts against the joined input and
output sets, because that decision needs both collections in scope.
@github-actions

Copy link
Copy Markdown
range-diff for force push 9e4d035276 → 1b728dcc94 November 12, 2026 18:47 UTC: 1 modified; 1 commit; base 9d3ba507d1 → 94c1abc38e (diverged, 3 ahead and 1 behind)

reproduce: git range-diff 9d3ba50..9e4d035 94c1abc..1b728dc

1:  9e4d035276 +178 -4 3f ! 1:  1b728dcc94 +178 -4 3f result domain variant of PSBT global fields
1: 9e4d035276 ! 1: 1b728dcc94 result domain variant of PSBT global fields
@@ crates/concurrent-psbt/src/psbt/global.rs (new)
 +            let mut fields = Vec::new();
 +            a.wrap()
 +                .join(b.wrap())
-+                .for_each_conflict(|field, _| fields.push(field.to_owned()));
++                .for_each_conflict(|field, _, _| fields.push(field.to_owned()));
 +            assert_eq!(fields, ["tx_version"]);
 +        }
 +    }

@github-actions

Copy link
Copy Markdown
range-diff for force push 9e4d035276 → 1b728dcc94 November 12, 2026 18:47 UTC: 1 modified; 1 commit; base 9d3ba507d1 → 94c1abc38e (diverged, 3 ahead and 1 behind)

reproduce: git range-diff 9d3ba50..9e4d035 94c1abc..1b728dc

1:  9e4d035276 +178 -4 3f ! 1:  1b728dcc94 +178 -4 3f result domain variant of PSBT global fields
1: 9e4d035276 ! 1: 1b728dcc94 result domain variant of PSBT global fields
@@ crates/concurrent-psbt/src/psbt/global.rs (new)
 +            let mut fields = Vec::new();
 +            a.wrap()
 +                .join(b.wrap())
-+                .for_each_conflict(|field, _| fields.push(field.to_owned()));
++                .for_each_conflict(|field, _, _| fields.push(field.to_owned()));
 +            assert_eq!(fields, ["tx_version"]);
 +        }
 +    }

@arminsabouri arminsabouri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK

@arminsabouri
arminsabouri added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 227c7b5 Nov 12, 2026
11 of 12 checks passed
@arminsabouri
arminsabouri deleted the global branch November 12, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants