Make sure to create rounds for round changes.
MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -119,7 +119,7 @@ namespace WalletWasabi.Tests.RegressionTests
// <-------------------------->
var states = await satoshiClient.GetAllRoundStatesAsync();
- Assert.Equal(2, states.Count());
+ Assert.Single(states);
foreach (var rs in states)
{
// Never changes.

MODIFY
WalletWasabi/CoinJoin/Coordinator/Coordinator.cs
WalletWasabi/CoinJoin/Coordinator/Coordinator.cs
@@ -213,7 +213,7 @@ namespace WalletWasabi.CoinJoin.Coordinator
}
}
- public async Task MakeSureInputregistrableRoundRunningAsync(Money? feePerInputs = null, Money? feePerOutputs = null)
+ public async Task MakeSureInputregistrableRoundRunningAsync()
{
using (await RoundsListLock.LockAsync().ConfigureAwait(false))
{
@@ -223,12 +223,18 @@ namespace WalletWasabi.CoinJoin.Coordinator
var round = new CoordinatorRound(RpcClient, UtxoReferee, RoundConfig, confirmationTarget, RoundConfig.ConfirmationTarget, RoundConfig.ConfirmationTargetReductionRate, TimeSpan.FromSeconds(RoundConfig.InputRegistrationTimeout));
round.CoinJoinBroadcasted += Round_CoinJoinBroadcasted;
round.StatusChanged += Round_StatusChangedAsync;
- await round.ExecuteNextPhaseAsync(RoundPhase.InputRegistration, feePerInputs, feePerOutputs).ConfigureAwait(false);
+ round.PhaseChanged += Round_PhaseChangedAsync;
+ await round.ExecuteNextPhaseAsync(RoundPhase.InputRegistration).ConfigureAwait(false);
Rounds.Add(round);
}
}
}
+ private async void Round_PhaseChangedAsync(object? sender, RoundPhase e)
+ {
+ await MakeSureInputregistrableRoundRunningAsync().ConfigureAwait(false);
+ }
+
/// <summary>
/// Depending on the number of unconfirmed coinjoins lower the confirmation target.
/// https://github.com/zkSNACKs/WalletWasabi/issues/1155
@@ -273,9 +279,6 @@ namespace WalletWasabi.CoinJoin.Coordinator
{
var round = sender as CoordinatorRound;
- Money feePerInputs = null;
- Money feePerOutputs = null;
-
// If success save the coinjoin.
if (status == CoordinatorRoundStatus.Succeded)
{
@@ -313,8 +316,8 @@ namespace WalletWasabi.CoinJoin.Coordinator
int currentConfirmationTarget = await AdjustConfirmationTargetAsync(lockCoinJoins: false).ConfigureAwait(false);
var fees = await CoordinatorRound.CalculateFeesAsync(RpcClient, currentConfirmationTarget).ConfigureAwait(false);
- feePerInputs = fees.feePerInputs;
- feePerOutputs = fees.feePerOutputs;
+ var feePerInputs = fees.feePerInputs;
+ var feePerOutputs = fees.feePerOutputs;
Money newDenominationToGetInWithactiveOutputs = activeOutputAmount - (feePerInputs + (2 * feePerOutputs));
if (newDenominationToGetInWithactiveOutputs < RoundConfig.Denomination)
@@ -373,8 +376,9 @@ namespace WalletWasabi.CoinJoin.Coordinator
if (status is CoordinatorRoundStatus.Aborted or CoordinatorRoundStatus.Succeded)
{
round.StatusChanged -= Round_StatusChangedAsync;
+ round.PhaseChanged -= Round_PhaseChangedAsync;
round.CoinJoinBroadcasted -= Round_CoinJoinBroadcasted;
- await MakeSureInputregistrableRoundRunningAsync(feePerInputs, feePerOutputs).ConfigureAwait(false);
+ await MakeSureInputregistrableRoundRunningAsync().ConfigureAwait(false);
}
}
catch (Exception ex)
@@ -481,6 +485,7 @@ namespace WalletWasabi.CoinJoin.Coordinator
foreach (CoordinatorRound round in Rounds)
{
round.StatusChanged -= Round_StatusChangedAsync;
+ round.PhaseChanged -= Round_PhaseChangedAsync;
round.CoinJoinBroadcasted -= Round_CoinJoinBroadcasted;
}

MODIFY
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
@@ -228,7 +228,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
InputRegistrationTimesout = DateTimeOffset.UtcNow + InputRegistrationTimeout;
}
- public async Task ExecuteNextPhaseAsync(RoundPhase expectedPhase, Money? feePerInputs = null, Money? feePerOutputs = null)
+ public async Task ExecuteNextPhaseAsync(RoundPhase expectedPhase)
{
using (await RoundSynchronizerLock.LockAsync().ConfigureAwait(false))
{
@@ -243,7 +243,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
return;
}
- await MoveToInputRegistrationAsync(feePerInputs, feePerOutputs).ConfigureAwait(false);
+ await MoveToInputRegistrationAsync().ConfigureAwait(false);
}
else if (Status != CoordinatorRoundStatus.Running) // Aborted or succeeded, swallow.
{
@@ -629,20 +629,12 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
Phase = RoundPhase.ConnectionConfirmation;
}
- private async Task MoveToInputRegistrationAsync(Money feePerInputs, Money feePerOutputs)
+ private async Task MoveToInputRegistrationAsync()
{
// Calculate fees.
- if (feePerInputs is null || feePerOutputs is null)
- {
(Money feePerInputs, Money feePerOutputs) fees = await CalculateFeesAsync(RpcClient, AdjustedConfirmationTarget).ConfigureAwait(false);
- FeePerInputs = feePerInputs ?? fees.feePerInputs;
- FeePerOutputs = feePerOutputs ?? fees.feePerOutputs;
- }
- else
- {
- FeePerInputs = feePerInputs;
- FeePerOutputs = feePerOutputs;
- }
+ FeePerInputs = fees.feePerInputs;
+ FeePerOutputs = fees.feePerOutputs;
Status = CoordinatorRoundStatus.Running;
}

Make sure to create rounds for round changes.