Separate VsizeAllocation completely
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -23,7 +23,7 @@ namespace WalletWasabi.Tests.Helpers
{
public static class WabiSabiFactory
{
- private static readonly int MaxVsizePerAlice = (1 << 8) - 1;
+ private static readonly int MaxVsizeAllocationPerAlice = (1 << 8) - 1;
public static Coin CreateCoin(OutPoint? prevout = null, Key? key = null, Money? value = null)
=> new(prevout ?? BitcoinFactory.CreateOutPoint(), new TxOut(value ?? Money.Coins(1), BitcoinFactory.CreateScript(key)));
@@ -147,11 +147,11 @@ namespace WalletWasabi.Tests.Helpers
var zeroPresentables = CreateZeroCredentials(amClient, vsClient, amIssuer, vsIssuer);
var alice = round?.Alices.FirstOrDefault();
var (realAmountCredentialRequest, _) = amClient.CreateRequest(
- new[] { amount?.Satoshi ?? alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizePerAlice },
+ new[] { amount?.Satoshi ?? alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizeAllocationPerAlice },
zeroPresentables.amountCredentials,
CancellationToken.None);
var (realVsizeCredentialRequest, _) = vsClient.CreateRequest(
- new[] { vsize ?? alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizePerAlice) ?? MaxVsizePerAlice },
+ new[] { vsize ?? alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizeAllocationPerAlice) ?? MaxVsizeAllocationPerAlice },
zeroPresentables.vsizeCredentials,
CancellationToken.None);
@@ -165,11 +165,11 @@ namespace WalletWasabi.Tests.Helpers
var zeroPresentables = CreateZeroCredentials(amClient, vsClient, amIssuer, vsIssuer);
var alice = round?.Alices.FirstOrDefault();
var (realAmountCredentialRequest, _) = amClient.CreateRequest(
- new[] { alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizePerAlice },
+ new[] { alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizeAllocationPerAlice },
zeroPresentables.amountCredentials,
CancellationToken.None);
var (realVsizeCredentialRequest, _) = vsClient.CreateRequest(
- new[] { alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizePerAlice) ?? MaxVsizePerAlice },
+ new[] { alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizeAllocationPerAlice) ?? MaxVsizeAllocationPerAlice },
zeroPresentables.vsizeCredentials,
CancellationToken.None);
@@ -207,7 +207,7 @@ namespace WalletWasabi.Tests.Helpers
zeroPresentables.amountCredentials,
CancellationToken.None);
var (realVsizeCredentialRequest, weVal) = vsClient.CreateRequest(
- new[] { alice.CalculateRemainingVsizeCredentials(round.MaxVsizePerAlice) },
+ new[] { alice.CalculateRemainingVsizeCredentials(round.MaxVsizeAllocationPerAlice) },
zeroPresentables.vsizeCredentials,
CancellationToken.None);
@@ -235,10 +235,10 @@ namespace WalletWasabi.Tests.Helpers
var alice = round?.Alices.FirstOrDefault();
var (amCredentialRequest, amValid) = amClient.CreateRequest(
- new[] { alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizePerAlice },
+ new[] { alice?.CalculateRemainingAmountCredentials(round!.FeeRate).Satoshi ?? MaxVsizeAllocationPerAlice },
zeroPresentables.amountCredentials,
CancellationToken.None);
- long startingVsizeCredentialAmount = alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizePerAlice) ?? MaxVsizePerAlice;
+ long startingVsizeCredentialAmount = alice?.CalculateRemainingVsizeCredentials(round!.MaxVsizeAllocationPerAlice) ?? MaxVsizeAllocationPerAlice;
var (vsCredentialRequest, weValid) = vsClient.CreateRequest(
new[] { startingVsizeCredentialAmount },
zeroPresentables.vsizeCredentials,
@@ -283,7 +283,7 @@ namespace WalletWasabi.Tests.Helpers
foreach (var ccresp in ccresps)
{
var alice = round.Alices.First(x => x.Id == ccresp.aliceId);
- var startingVsizeCredentialAmount = alice.CalculateRemainingVsizeCredentials(round!.MaxVsizePerAlice);
+ var startingVsizeCredentialAmount = alice.CalculateRemainingVsizeCredentials(round!.MaxVsizeAllocationPerAlice);
var script = BitcoinFactory.CreateScript();
var vsize = script.EstimateOutputVsize();
var amountCredentialRequestData = ccresp.amountClient.CreateRequest(Array.Empty<long>(), ccresp.amountCredentials, CancellationToken.None);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PostRequests/RegisterInputFailureTests.cs
@@ -91,7 +91,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
await using ArenaRequestHandler handler = new(cfg, new(), arena, WabiSabiFactory.CreateMockRpc(key));
// TODO add configuration parameter
- round.InitialInputVsizeAllocation = (int)round.MaxVsizePerAlice;
+ round.InitialInputVsizeAllocation = (int)round.MaxVsizeAllocationPerAlice;
// Add an alice
await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));
@@ -337,7 +337,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PostRequests
// to register anything.
WabiSabiConfig cfg = new() { MaxInputCountByRound = 100_000 };
var round = WabiSabiFactory.CreateRound(cfg);
- Assert.Equal(0, round.MaxVsizePerAlice);
+ Assert.Equal(0, round.MaxVsizeAllocationPerAlice);
using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);
using Key key = new();

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/InputRegistrationHandler.cs
@@ -93,12 +93,12 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchFunds);
}
- if (alice.TotalInputVsize > round.MaxVsizePerAlice)
+ if (alice.TotalInputVsize > round.MaxVsizeAllocationPerAlice)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchVsize);
}
- if (round.RemainingInputVsizeAllocation < round.MaxVsizePerAlice)
+ if (round.RemainingInputVsizeAllocation < round.MaxVsizeAllocationPerAlice)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.VsizeQuotaExceeded);
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -300,7 +300,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
var realAmountCredentialRequests = request.RealAmountCredentialRequests;
var realVsizeCredentialRequests = request.RealVsizeCredentialRequests;
- if (realVsizeCredentialRequests.Delta != alice.CalculateRemainingVsizeCredentials(round.MaxVsizePerAlice))
+ if (realVsizeCredentialRequests.Delta != alice.CalculateRemainingVsizeCredentials(round.MaxVsizeAllocationPerAlice))
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedVsizeCredentials, $"Round ({request.RoundId}): Incorrect requested vsize credentials.");
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -21,10 +21,11 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
CoinjoinState = new ConstructionState(txParams);
InitialInputVsizeAllocation = CoinjoinState.Parameters.MaxTransactionSize - MultipartyTransactionParameters.SharedOverhead;
- MaxVsizePerAlice = InitialInputVsizeAllocation / RoundParameters.MaxInputCountByRound;
+ MaxRegistrableVsize = InitialInputVsizeAllocation / RoundParameters.MaxInputCountByRound;
+ MaxVsizeAllocationPerAlice = MaxRegistrableVsize;
AmountCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, MaxRegistrableAmount);
- VsizeCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, (ulong)MaxVsizePerAlice);
+ VsizeCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, (ulong)MaxRegistrableVsize);
AmountCredentialIssuerParameters = AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters();
VsizeCredentialIssuerParameters = VsizeCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters();
@@ -36,7 +37,8 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
public Network Network => RoundParameters.Network;
public Money MinRegistrableAmount => RoundParameters.MinRegistrableAmount;
public Money MaxRegistrableAmount => RoundParameters.MaxRegistrableAmount;
- public int MaxVsizePerAlice { get; }
+ public int MaxRegistrableVsize { get; }
+ public int MaxVsizeAllocationPerAlice { get; }
public FeeRate FeeRate => RoundParameters.FeeRate;
public CredentialIssuer AmountCredentialIssuer { get; }
public CredentialIssuer VsizeCredentialIssuer { get; }
@@ -61,7 +63,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
public DateTimeOffset TransactionSigningStart { get; private set; }
public DateTimeOffset TransactionBroadcastingStart { get; private set; }
public int InitialInputVsizeAllocation { get; internal set; } // for testing. replace for: CoinjoinState.Parameters.MaxTransactionSize - MultipartyTransactionParameters.SharedOverhead;
- public int RemainingInputVsizeAllocation => InitialInputVsizeAllocation - InputCount * MaxVsizePerAlice;
+ public int RemainingInputVsizeAllocation => InitialInputVsizeAllocation - InputCount * MaxVsizeAllocationPerAlice;
private RoundParameters RoundParameters { get; }
@@ -140,7 +142,8 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
=> StrobeHasher.Create(ProtocolConstants.RoundStrobeDomain)
.Append(ProtocolConstants.RoundMinRegistrableAmountStrobeLabel, MinRegistrableAmount)
.Append(ProtocolConstants.RoundMaxRegistrableAmountStrobeLabel, MaxRegistrableAmount)
- .Append(ProtocolConstants.RoundMaxVsizePerAliceStrobeLabel, MaxVsizePerAlice)
+ .Append(ProtocolConstants.RoundMaxRegistrableVsizeStrobeLabel, MaxRegistrableVsize)
+ .Append(ProtocolConstants.RoundMaxVsizePerAliceStrobeLabel, MaxVsizeAllocationPerAlice)
.Append(ProtocolConstants.RoundAmountCredentialIssuerParametersStrobeLabel, AmountCredentialIssuerParameters)
.Append(ProtocolConstants.RoundVsizeCredentialIssuerParametersStrobeLabel, VsizeCredentialIssuerParameters)
.Append(ProtocolConstants.RoundFeeRateStrobeLabel, FeeRate.FeePerK)

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

MODIFY
WalletWasabi/WabiSabi/ProtocolContants.cs
WalletWasabi/WabiSabi/ProtocolContants.cs
@@ -12,6 +12,7 @@ namespace WalletWasabi.WabiSabi
public const string RoundStrobeDomain = "round-parameters";
public const string RoundMinRegistrableAmountStrobeLabel = "minimum-registrable-amount";
public const string RoundMaxRegistrableAmountStrobeLabel = "maximum-registrable-amount";
+ public const string RoundMaxRegistrableVsizeStrobeLabel = "maximum-registrable-vsize";
public const string RoundMaxVsizePerAliceStrobeLabel = "per-alice-vsize-allocation";
public const string RoundAmountCredentialIssuerParametersStrobeLabel = "amount-credential-issuer-parameters";
public const string RoundVsizeCredentialIssuerParametersStrobeLabel = "vsize-credential-issuer-parameters";

Separate VsizeAllocation completely