Skip to content

Commit 27a3c68

Browse files
committed
Regsiter all common inputs
1 parent bd8737d commit 27a3c68

4 files changed

Lines changed: 150 additions & 11 deletions

File tree

mppj/config.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[simulation]
2+
seed = 42
3+
max_timestep = 15
4+
num_payment_obligations = 5
5+
6+
# Takers: have payment obligations, build cospend proposals using the order book
7+
[[wallet_types]]
8+
name = "taker"
9+
count = 1
10+
strategies = ["TakerStrategy"]
11+
script_type = "p2wpkh"
12+
13+
[wallet_types.scorer]
14+
fee_savings_weight = 1.0
15+
privacy_weight = 1.0
16+
payment_obligation_weight = 2.0
17+
coordination_weight = 1.0
18+
19+
# Makers: register UTXOs in the order book and participate in cospends
20+
[[wallet_types]]
21+
name = "maker"
22+
count = 3
23+
strategies = ["MakerStrategy"]
24+
script_type = "p2wpkh"
25+
26+
[wallet_types.scorer]
27+
fee_savings_weight = 0.5
28+
privacy_weight = 1.0
29+
payment_obligation_weight = 1.0
30+
coordination_weight = 2.0
31+
32+
# Aggregators: create aggregate proposals from pending interests
33+
# For now they are a distinct role that should not have payment obligations
34+
[[wallet_types]]
35+
name = "aggregator"
36+
count = 1
37+
strategies = ["AggregatorStrategy"]
38+
script_type = "p2wpkh"
39+
40+
[wallet_types.scorer]
41+
fee_savings_weight = 0.0
42+
privacy_weight = 0.0
43+
payment_obligation_weight = 0.0
44+
coordination_weight = 0.0

mppj/results.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"total_payment_obligations": 8,
3+
"percentage_payment_obligations_missed": 0.75,
4+
"total_block_weight_wu": 10100,
5+
"average_fee_cost_sats": 220,
6+
"dust_utxo_count": 0,
7+
"utxo_size_distribution_sats": [
8+
3519,
9+
4483,
10+
5409,
11+
16713,
12+
4999983177,
13+
4999994481,
14+
4999995407,
15+
4999996371,
16+
5000000000,
17+
5000000000,
18+
5000000000,
19+
5000000000,
20+
5000000000,
21+
5000000000,
22+
5000000000,
23+
5000000000,
24+
5000000000,
25+
5000000000,
26+
5000000000,
27+
5000000000,
28+
5000000000,
29+
5000000000,
30+
5000000000,
31+
5000000000,
32+
5000000000,
33+
5000000000,
34+
5000000000,
35+
5000000000,
36+
5000000000,
37+
5000000000,
38+
5000000000,
39+
5000000000,
40+
5000000000,
41+
5000000000,
42+
5000000000,
43+
5000000000,
44+
5000000000,
45+
5000000000,
46+
5000000000,
47+
5000000000,
48+
5000000000,
49+
5000000000,
50+
5000000000,
51+
5000000000,
52+
5000000000,
53+
5000000000,
54+
5000000220,
55+
5000000220
56+
],
57+
"wallet_utxo_stats": [
58+
{
59+
"wallet_id": 0,
60+
"dust_count": 0,
61+
"total_count": 21,
62+
"p50_sats": 5000000000,
63+
"p90_sats": 5000000000
64+
},
65+
{
66+
"wallet_id": 1,
67+
"dust_count": 0,
68+
"total_count": 8,
69+
"p50_sats": 5000000000,
70+
"p90_sats": 5000000000
71+
},
72+
{
73+
"wallet_id": 2,
74+
"dust_count": 0,
75+
"total_count": 8,
76+
"p50_sats": 5000000000,
77+
"p90_sats": 5000000000
78+
},
79+
{
80+
"wallet_id": 3,
81+
"dust_count": 0,
82+
"total_count": 6,
83+
"p50_sats": 5000000000,
84+
"p90_sats": 5000000000
85+
},
86+
{
87+
"wallet_id": 4,
88+
"dust_count": 0,
89+
"total_count": 5,
90+
"p50_sats": 5000000000,
91+
"p90_sats": 5000000000
92+
}
93+
]
94+
}

src/actions.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub(crate) enum Action {
5555
/// Aggregator creates an aggregate session from pending interests
5656
CreateAggregateProposal(Vec<CospendInterest>),
5757
/// Register a single UTXO in the order book (maker action)
58-
RegisterInput(Outpoint),
58+
RegisterInput(Vec<Outpoint>),
5959
/// Do nothing. There may be better oppurtunities to spend a payment obligation or participate in a payjoin.
6060
Wait,
6161
}
@@ -405,21 +405,20 @@ impl Strategy for MakerStrategy {
405405
.collect()
406406
})
407407
.collect();
408-
let common_input: Option<Outpoint> = per_action_spent
408+
let common_inputs: Vec<Outpoint> = per_action_spent
409409
.iter()
410410
.skip(1)
411411
.fold(
412412
per_action_spent.first().cloned().unwrap_or_default(),
413413
|acc, s| acc.intersection(s).copied().collect(),
414414
)
415-
.into_iter()
416-
.next();
417-
if let Some(outpoint) = common_input {
418-
if !state.registered_inputs.contains(&outpoint) {
419-
actions.push(Action::RegisterInput(outpoint));
420-
}
415+
.iter()
416+
.filter(|o| !state.registered_inputs.contains(o))
417+
.copied()
418+
.collect();
419+
if !common_inputs.is_empty() {
420+
actions.push(Action::RegisterInput(common_inputs));
421421
}
422-
423422
if actions.is_empty() {
424423
actions.push(Action::Wait);
425424
}

src/wallet.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,10 @@ impl<'a> WalletHandleMut<'a> {
576576
Action::ContinueParticipateInCospend(bulletin_board_id) => {
577577
self.participate_in_multi_party_payjoin(bulletin_board_id);
578578
}
579-
Action::RegisterInput(outpoint) => {
580-
self.register_input(outpoint);
579+
Action::RegisterInput(outpoints) => {
580+
for outpoint in outpoints {
581+
self.register_input(&outpoint);
582+
}
581583
}
582584
}
583585
}

0 commit comments

Comments
 (0)