Closed dpc closed 2 weeks ago
@elsirion
If I'm reading it right, the only way 502 could assert this way, would be if WaitingForConfirmations
was emitted twice?
Another flake, this time with fedimint-wallet-tests::fedimint_wallet_tests peg_out_fail_refund
fedimint-workspace-lcov-ci> Unexpected state WaitingForConfirmations(WaitingForConfirmationsDepositState { tweak_key: KeyPair(#5fae9b66639b1d28), btc_transaction: Transaction { version: 0, lock_time: PackedLockTime(0), input: [], output: [TxOut { value: 6000, script_pubkey: Script(OP_0 OP_PUSHBYTES_32 594eeb6bf5ed5da6204db6b83d5157c6b91f9ea39f73e9243618e1b8e86b3821) }] }, out_idx: 0 })
https://github.com/fedimint/fedimint/actions/runs/8872810356/job/24357681665#step:8:310
// It's important to start the subscription first and then query the database to
// not lose any transitions in the meantime.
let new_transitions =
self.subscribe_all_operations()
.await
.filter_map(move |state: S| async move {
if state.operation_id() == operation_id {
trace!(%operation_id, ?state, "Received state transition notification");
Some(state)
} else {
None
}
});
Ah right. We can return states from the DB and then the subscribed ones, and there can overlap.
The question is - what do we do about it? The whole thing is kind of a clumsy construction, IMO.
We could de-duplicate, but in theory overlap can be arbitrarily long.
We could make client worry about it, but that's error prone and crappy UX.
We could use db as the ultimate source and use notifications only as a wakup, which seems most reliable, but will be a larger refactor, possibly part of #5006 .
@elsirion Thoughts?
Making the client worry about it only reduces DX, not UX since modules implement the translation between these low-level state machine notifications and high-level operation states. These functions should probably ignore duplicate states :/
Edit: and yes, once we re-work the reactor we should use the DB as source of truth.
OK, I think I've found a proper way to dedup all instances there: #5173. It does come from an assamption that the same exact state can't happen twice.
@elsirion
Most probably should not happen after #5173 landed.
https://github.com/fedimint/fedimint/actions/runs/8854215897/job/24316806541