Skip to content

Privacy bundle interface #27

Open
arminsabouri wants to merge 9 commits intomasterfrom
bracketing
Open

Privacy bundle interface #27
arminsabouri wants to merge 9 commits intomasterfrom
bracketing

Conversation

@arminsabouri
Copy link
Copy Markdown
Collaborator

This is a large refactor. The major changes here are:

  • Collapse maker and taker roles into one multi party role
  • acceptance of a cospend proposal is now conditional on the wallet's own cost bracket, not unconditional
  • unilateral fallback planning considers all batching combinations, not just individual obligations
    • future work will also enumurate over chagne decomposition strategies
  • wallets won't enter a session unless they have enough viable unilateral exits
  • introduces PrivacyMetric/ErasedPrivacyMetric/PrivacyBundle traits, SubsetSumMetric, the input amount resolution on Plan, and wires it into CompositeScorer
  • cleans up the old flat privacy_weight: f64 field that the bundle replaces. And some other scoring weights that were never used in 0481ca8

Previously, MakerStrategy and TakerStrategy accepted cospend proposals
unconditionally: any invitation was accepted, any orderbook peer was
proposed to, regardless of whether joining the session was actually
cost-beneficial for the wallet.

Now the makers and takers only make commital actions (agg proposals) if 
they their best unilateral action is no worse than the agg proposal in terms of 
subjective cost.
Unilateral actions include all possible subsets of 
payment obligations as individual plans.
Copy link
Copy Markdown
Contributor

@bc1cindy bc1cindy left a comment

Choose a reason for hiding this comment

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

reviewing this PR made me zoom out and have a much clearer understanding now

im pretty impressed with the progress

dense-subset-sum owns the counting primitives and btsim owns the privacy metric (how primitives combine into a cost) and the decision making (how cost shapes action selection)

Comment thread src/metrics.rs Outdated
}

/// Generate all k-element subsets of `{0, 1, ..., n-1}` in lexicographic order.
fn combinations(n: usize, k: usize) -> Vec<Vec<usize>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does it make sense to convert to iter? the call site only consumes sequentially and currently allocs the entire powerset in Vec<Vec<usize>>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes that makes sense

Comment thread src/actions.rs Outdated
let cospend_proposals = wallet.pending_cospend_proposals();
let payment_obligations = wallet.unhandled_payment_obligations();
let registered_inputs = wallet.registered_input_outpoints();
let scorer = wallet.data().scorer.clone();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we use &wallet.data().scorer here? all usages are &self

with PrivacyBundle inside the scorer, its not cheap

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

no but we can use a reference. Thanks

with PrivacyBundle inside the scorer, its not cheap

PrivacyBundle is stateless.

@arminsabouri
Copy link
Copy Markdown
Collaborator Author

arminsabouri commented Apr 28, 2026

dense-subset-sum owns the counting primitives and btsim owns the privacy metric (how primitives combine into a cost) and the decision making (how cost shapes action selection)

Note that privacy metrics should live in the tx-indexer (there is a comment in the diff). Eventually the primitives you are working on should graduate to that repo as well.

makers and takers should behave uniformally. This will make future work on the 
cost function easier to reason about and implement. This distinction was initially
created as part of a POC / testing scaffolding. Agenst will make co spends as long as there
are orderbook utxos and PO's in the queue
stub the privacy cost to differentiate unilateral from cospend:
unilateral transactions should cost more, but we have no privacy terms rn.

This stubs a privacy weight for unilateral txs making cospends more preferabably when
they are not under time pressure.

Lastly, `ContributeOutputsToSession` was comparing single-PO contribution cost
against the global best unilateral cost (which batches all POs), causing
wallets to never contribute once accepted. Remove the cost gate from
contribution
Bundles are collections of privacy metrics / measures that evaluate
over a plan. A measure can output a value specific to its domain. The 
individual metrics define how to convert that into a satoshi amount 
wrt a privacy budget.
Just removing clutter
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.

2 participants