Split `MaxVsizePerAlice` & `MaxVsizeAllocationPerAlice`
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -62,7 +62,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var aliceClient = new AliceClient(round.Id, arenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
- Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1), CancellationToken.None);
+ Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1), roundState.MaxVsizeAllocationPerAlice, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));
await confirmationTask;

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -65,9 +65,8 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
Money.Coins(.25m)
};
- var ProtocolConstants_MaxVsizePerAlice = (long)aliceArenaClient.VsizeCredentialClient.MaxAmount;
var inputVsize = Constants.P2wpkhInputVirtualSize;
- var inputRemainingVsizes = new[] { ProtocolConstants_MaxVsizePerAlice - inputVsize };
+ var inputRemainingVsizes = new[] { roundState.MaxVsizeAllocationPerAlice - inputVsize };
// Phase: Input Registration
Assert.Equal(Phase.InputRegistration, round.Phase);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -66,7 +66,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var aliceClient = new AliceClient(round.Id, aliceArenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
await aliceClient.RegisterInputAsync(CancellationToken.None);
- Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1), CancellationToken.None);
+ Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(1), roundState.MaxVsizeAllocationPerAlice, CancellationToken.None);
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromMinutes(1));
await confirmationTask;

MODIFY
WalletWasabi/WabiSabi/Client/AliceClient.cs
WalletWasabi/WabiSabi/Client/AliceClient.cs
@@ -47,19 +47,18 @@ namespace WalletWasabi.WabiSabi.Client
Logger.LogInfo($"Round ({RoundId}), Alice ({AliceId}): Registered an input.");
}
- public async Task ConfirmConnectionAsync(TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
+ public async Task ConfirmConnectionAsync(TimeSpan connectionConfirmationTimeout, long vsizeAllocationToRequest, CancellationToken cancellationToken)
{
- while (!await TryConfirmConnectionAsync(cancellationToken).ConfigureAwait(false))
+ while (!await TryConfirmConnectionAsync(vsizeAllocationToRequest, cancellationToken).ConfigureAwait(false))
{
await Task.Delay(connectionConfirmationTimeout / 2, cancellationToken).ConfigureAwait(false);
}
}
- private async Task<bool> TryConfirmConnectionAsync(CancellationToken cancellationToken)
+ private async Task<bool> TryConfirmConnectionAsync(long vsizeAllocationToRequest, CancellationToken cancellationToken)
{
var inputVsize = Coin.ScriptPubKey.EstimateInputVsize();
- var totalInputVsize = ArenaClient.VsizeCredentialClient.MaxAmount;
- var inputRemainingVsizes = new[] { (long)totalInputVsize - inputVsize };
+ var inputRemainingVsizes = new[] { vsizeAllocationToRequest - inputVsize };
var totalFeeToPay = FeeRate.GetFee(Coin.ScriptPubKey.EstimateInputVsize());
var totalAmount = Coin.Amount;

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -69,7 +69,7 @@ namespace WalletWasabi.WabiSabi.Client
aliceClients = await RegisterCoinsAsync(aliceClients, cancellationToken).ConfigureAwait(false);
// Confirm coins.
- aliceClients = await ConfirmConnectionsAsync(aliceClients, roundState.ConnectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
+ aliceClients = await ConfirmConnectionsAsync(aliceClients, roundState.MaxVsizeAllocationPerAlice, roundState.ConnectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
// Output registration.
roundState = await RoundStatusUpdater.CreateRoundAwaiter(roundState.Id, rs => rs.Phase == Phase.OutputRegistration, cancellationToken).ConfigureAwait(false);
@@ -131,13 +131,13 @@ namespace WalletWasabi.WabiSabi.Client
return completedRequests.Where(x => x is not null).Cast<AliceClient>().ToList();
}
- private async Task<List<AliceClient>> ConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
+ private async Task<List<AliceClient>> ConfirmConnectionsAsync(IEnumerable<AliceClient> aliceClients, long maxVsizeAllocationPerAlice, TimeSpan connectionConfirmationTimeout, CancellationToken cancellationToken)
{
async Task<AliceClient?> ConfirmConnectionTask(AliceClient aliceClient)
{
try
{
- await aliceClient.ConfirmConnectionAsync(connectionConfirmationTimeout, cancellationToken).ConfigureAwait(false);
+ await aliceClient.ConfirmConnectionAsync(connectionConfirmationTimeout, maxVsizeAllocationPerAlice, cancellationToken).ConfigureAwait(false);
return aliceClient;
}
catch (Exception e)

MODIFY
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
@@ -24,17 +24,15 @@ namespace WalletWasabi.WabiSabi.Crypto
public WabiSabiClient(
CredentialIssuerParameters credentialIssuerParameters,
WasabiRandom randomNumberGenerator,
- ulong maxAmount,
+ ulong rangeProofUpperBound,
ZeroCredentialPool zeroCredentialPool)
{
- MaxAmount = maxAmount;
- RangeProofWidth = (int)Math.Ceiling(Math.Log2(MaxAmount));
+ RangeProofWidth = (int)Math.Ceiling(Math.Log2(rangeProofUpperBound));
RandomNumberGenerator = Guard.NotNull(nameof(randomNumberGenerator), randomNumberGenerator);
CredentialIssuerParameters = Guard.NotNull(nameof(credentialIssuerParameters), credentialIssuerParameters);
ZeroCredentialPool = zeroCredentialPool;
}
- public ulong MaxAmount { get; }
public int RangeProofWidth { get; }
public int NumberOfCredentials => ProtocolConstants.CredentialNumber;

MODIFY
WalletWasabi/WabiSabi/Models/RoundState.cs
WalletWasabi/WabiSabi/Models/RoundState.cs
@@ -15,8 +15,9 @@ namespace WalletWasabi.WabiSabi.Models
FeeRate FeeRate,
Phase Phase,
TimeSpan ConnectionConfirmationTimeout,
- ulong MaxAmountPerAlice,
- ulong MaxVsizePerAlice,
+ long MaxAmountPerAlice,
+ long MaxVsizePerAlice,
+ long MaxVsizeAllocationPerAlice,
MultipartyTransactionState CoinjoinState)
{
public static RoundState FromRound(Round round) =>
@@ -28,7 +29,8 @@ namespace WalletWasabi.WabiSabi.Models
round.Phase,
round.ConnectionConfirmationTimeout,
ProtocolConstants.MaxAmountPerAlice,
- (ulong)round.MaxVsizePerAlice,
+ round.MaxVsizePerAlice,
+ round.MaxVsizePerAlice,
round.CoinjoinState);
public TState Assert<TState>() where TState : MultipartyTransactionState =>
@@ -39,9 +41,9 @@ namespace WalletWasabi.WabiSabi.Models
};
public WabiSabiClient CreateAmountCredentialClient(ZeroCredentialPool zeroAmountCredentialPool, WasabiRandom random) =>
- new WabiSabiClient(AmountCredentialIssuerParameters, random, MaxAmountPerAlice, zeroAmountCredentialPool);
+ new WabiSabiClient(AmountCredentialIssuerParameters, random, (ulong)MaxAmountPerAlice, zeroAmountCredentialPool);
public WabiSabiClient CreateVsizeCredentialClient(ZeroCredentialPool zeroVsizeCredentialPool, WasabiRandom random) =>
- new WabiSabiClient(VsizeCredentialIssuerParameters, random, MaxVsizePerAlice, zeroVsizeCredentialPool);
+ new WabiSabiClient(VsizeCredentialIssuerParameters, random, (ulong)MaxVsizePerAlice, zeroVsizeCredentialPool);
}
}

MODIFY
WalletWasabi/WabiSabi/ProtocolContants.cs
WalletWasabi/WabiSabi/ProtocolContants.cs
@@ -3,7 +3,7 @@ namespace WalletWasabi.WabiSabi
public static class ProtocolConstants
{
public const int CredentialNumber = 2;
- public const ulong MaxAmountPerAlice = 4_300_000_000_000ul;
+ public const long MaxAmountPerAlice = 4_300_000_000_000l;
public const string WabiSabiProtocolIdentifier = "WabiSabi_v1.0";
public const string DomainStrobeSeparator = "domain-separator";

Split `MaxVsizePerAlice` & `MaxVsizeAllocationPerAlice`