cleanup weight creds
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -58,8 +58,7 @@ namespace WalletWasabi.Tests.Helpers
cfg.MaxInputCountByAlice,
cfg.MinRegistrableAmount,
cfg.MaxRegistrableAmount,
- cfg.MinRegistrableWeight,
- cfg.MaxRegistrableWeight,
+ cfg.RegistrableWeightCredentials,
cfg.ConnectionConfirmationTimeout,
cfg.OutputRegistrationTimeout,
cfg.TransactionSigningTimeout,
@@ -131,7 +130,7 @@ namespace WalletWasabi.Tests.Helpers
wi.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(),
wi.NumberOfCredentials,
rnd,
- round?.MaxRegistrableWeightByAlice ?? 4300000000000ul);
+ round?.RegistrableWeightCredentials ?? 2000ul);
return (ac, wc, ai, wi);
}
@@ -159,7 +158,7 @@ namespace WalletWasabi.Tests.Helpers
new[] { amount?.Satoshi ?? (alice is null ? 1000L : alice.Coins.Select(x => x.Amount.Satoshi).Sum()) },
zeroPresentables.amountCredentials);
var (realWeightCredentialRequest, _) = weClient.CreateRequest(
- new[] { weight ?? alice?.CalculateRemainingWeightCredentials(round!.MaxRegistrableWeightByAlice) ?? 1000L },
+ new[] { weight ?? alice?.CalculateRemainingWeightCredentials(round!.RegistrableWeightCredentials) ?? 1000L },
zeroPresentables.weightCredentials);
return (realAmountCredentialRequest, realWeightCredentialRequest);
@@ -178,7 +177,7 @@ namespace WalletWasabi.Tests.Helpers
new[] { alice is null ? 1000L : alice.Coins.Select(x => x.Amount.Satoshi).Sum() },
zeroPresentables.amountCredentials);
var (realWeightCredentialRequest, _) = weClient.CreateRequest(
- new[] { alice?.CalculateRemainingWeightCredentials(round!.MaxRegistrableWeightByAlice) ?? 1000L },
+ new[] { alice?.CalculateRemainingWeightCredentials(round!.RegistrableWeightCredentials) ?? 1000L },
zeroPresentables.weightCredentials);
return new ConnectionConfirmationRequest(

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/ConfirmConnectionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/ConfirmConnectionTests.cs
@@ -132,7 +132,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
req.ZeroAmountCredentialRequests,
req.RealAmountCredentialRequests,
req.ZeroWeightCredentialRequests,
- WabiSabiFactory.CreateRealCredentialRequests(round, null, 1234).weightReq);
+ WabiSabiFactory.CreateRealCredentialRequests(round, null, 234).weightReq);
await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
var ex = Assert.Throws<WabiSabiProtocolException>(() => handler.ConfirmConnection(req));
Assert.Equal(WabiSabiProtocolErrorCode.IncorrectRequestedWeightCredentials, ex.ErrorCode);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
@@ -399,34 +399,11 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
Assert.Equal(WabiSabiProtocolErrorCode.TooMuchFunds, ex.ErrorCode);
}
- [Fact]
- public async Task NotEnoughWeightAsync()
- {
- MockArena arena = new();
- WabiSabiConfig cfg = new() { MinRegistrableWeight = 1000 };
- var round = WabiSabiFactory.CreateRound(cfg);
- arena.OnTryGetRound = _ => round;
- MockRpcClient rpc = new();
- using Key key = new();
-
- rpc.OnGetTxOutAsync = (_, _, _) => new()
- {
- Confirmations = 1,
- ScriptPubKeyType = "witness_v0_keyhash",
- TxOut = new TxOut(Money.Coins(1), key.PubKey.GetSegwitAddress(Network.Main))
- };
-
- await using PostRequestHandler handler = new(cfg, new Prison(), arena, rpc);
- var req = WabiSabiFactory.CreateInputsRegistrationRequest(key, round);
- var ex = await Assert.ThrowsAsync<WabiSabiProtocolException>(async () => await handler.RegisterInputAsync(req));
- Assert.Equal(WabiSabiProtocolErrorCode.NotEnoughWeight, ex.ErrorCode);
- }
-
[Fact]
public async Task TooMuchWeightAsync()
{
MockArena arena = new();
- WabiSabiConfig cfg = new() { MaxRegistrableWeight = 1 };
+ WabiSabiConfig cfg = new() { RegistrableWeightCredentials = 1 };
var round = WabiSabiFactory.CreateRound(cfg);
arena.OnTryGetRound = _ => round;
MockRpcClient rpc = new();

MODIFY
WalletWasabi/WabiSabi/Backend/Models/WabiSabiProtocolErrorCode.cs
WalletWasabi/WabiSabi/Backend/Models/WabiSabiProtocolErrorCode.cs
@@ -19,11 +19,10 @@ namespace WalletWasabi.WabiSabi.Backend.Models
NotEnoughFunds,
TooMuchFunds,
NonUniqueInputs,
- NotEnoughWeight,
- TooMuchWeight,
InputBanned,
InputNotWhitelisted,
AliceNotFound,
- IncorrectRequestedWeightCredentials
+ IncorrectRequestedWeightCredentials,
+ TooMuchWeight
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -22,8 +22,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
uint maxInputCountByAlice,
Money minRegistrableAmountByAlice,
Money maxRegistrableAmountByAlice,
- uint minRegistrableWeightByAlice,
- uint maxRegistrableWeightByAlice,
+ uint registrableWeightCredentials,
TimeSpan connectionConfirmationTimeout,
TimeSpan outputRegistrationTimeout,
TimeSpan transactionSigningTimeout,
@@ -33,8 +32,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
MaxInputCountByAlice = maxInputCountByAlice;
MinRegistrableAmountByAlice = minRegistrableAmountByAlice;
MaxRegistrableAmountByAlice = maxRegistrableAmountByAlice;
- MinRegistrableWeightByAlice = minRegistrableWeightByAlice;
- MaxRegistrableWeightByAlice = maxRegistrableWeightByAlice;
+ RegistrableWeightCredentials = registrableWeightCredentials;
ConnectionConfirmationTimeout = connectionConfirmationTimeout;
OutputRegistrationTimeout = outputRegistrationTimeout;
@@ -42,11 +40,11 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
Random = random;
AmountCredentialIssuer = new(new(Random), 2, random, MaxRegistrableAmountByAlice);
- WeightCredentialIssuer = new(new(Random), 2, random, MaxRegistrableWeightByAlice);
+ WeightCredentialIssuer = new(new(Random), 2, random, RegistrableWeightCredentials);
AmountCredentialIssuerParameters = AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters();
WeightCredentialIssuerParameters = WeightCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters();
- Hash = new(HashHelpers.GenerateSha256Hash($"{Id}{MaxInputCountByAlice}{MinRegistrableAmountByAlice}{MaxRegistrableAmountByAlice}{MinRegistrableWeightByAlice}{MaxRegistrableWeightByAlice}{AmountCredentialIssuerParameters}{WeightCredentialIssuerParameters}"));
+ Hash = new(HashHelpers.GenerateSha256Hash($"{Id}{MaxInputCountByAlice}{MinRegistrableAmountByAlice}{MaxRegistrableAmountByAlice}{RegistrableWeightCredentials}{AmountCredentialIssuerParameters}{WeightCredentialIssuerParameters}"));
}
public Round(Round blameOf)
@@ -55,8 +53,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
blameOf.MaxInputCountByAlice,
blameOf.MinRegistrableAmountByAlice,
blameOf.MaxRegistrableAmountByAlice,
- blameOf.MinRegistrableWeightByAlice,
- blameOf.MaxRegistrableWeightByAlice,
+ blameOf.RegistrableWeightCredentials,
blameOf.ConnectionConfirmationTimeout,
blameOf.OutputRegistrationTimeout,
blameOf.TransactionSigningTimeout,
@@ -75,8 +72,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
public uint MaxInputCountByAlice { get; }
public Money MinRegistrableAmountByAlice { get; }
public Money MaxRegistrableAmountByAlice { get; }
- public uint MinRegistrableWeightByAlice { get; }
- public uint MaxRegistrableWeightByAlice { get; }
+ public uint RegistrableWeightCredentials { get; }
public TimeSpan ConnectionConfirmationTimeout { get; }
public TimeSpan OutputRegistrationTimeout { get; }
public TimeSpan TransactionSigningTimeout { get; }
@@ -140,11 +136,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchFunds);
}
- if (inputWeightSum < MinRegistrableWeightByAlice)
- {
- throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.NotEnoughWeight);
- }
- if (inputWeightSum > MaxRegistrableWeightByAlice)
+ if (inputWeightSum > RegistrableWeightCredentials)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchWeight);
}
@@ -190,7 +182,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
var amountRealCredentialResponse = AmountCredentialIssuer.HandleRequest(realAmountCredentialRequests);
var weightRealCredentialResponse = WeightCredentialIssuer.HandleRequest(realWeightCredentialRequests);
- if (realWeightCredentialRequests.Delta != alice.CalculateRemainingWeightCredentials(MaxRegistrableWeightByAlice))
+ if (realWeightCredentialRequests.Delta != alice.CalculateRemainingWeightCredentials(RegistrableWeightCredentials))
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedWeightCredentials);
}

MODIFY
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
@@ -51,18 +51,15 @@ namespace WalletWasabi.WabiSabi.Backend
[JsonConverter(typeof(MoneyBtcJsonConverter))]
public Money MaxRegistrableAmount { get; set; } = Money.Coins(43000m);
- [DefaultValue(1)]
- [JsonProperty(PropertyName = "MinRegistrableWeight", DefaultValueHandling = DefaultValueHandling.Populate)]
- public uint MinRegistrableWeight { get; set; } = 1;
-
/// <summary>
+ /// How much weight units the server gives to alices per registrations.
+ /// If it's 1000, then about 400 alices can participate.
/// The width of the rangeproofs are calculated from this, so don't choose stupid numbers.
/// Consider that it applies to registrations, not for inputs. This usually consists one input, but can be more.
- /// 1000 / inputs looks good, so for 2 inputs it'd be 2000.
/// </summary>
- [DefaultValue(2000)]
- [JsonProperty(PropertyName = "MaxRegistrableWeight", DefaultValueHandling = DefaultValueHandling.Populate)]
- public uint MaxRegistrableWeight { get; set; } = 2000;
+ [DefaultValue(1000)]
+ [JsonProperty(PropertyName = "RegistrableWeightCredentials", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public uint RegistrableWeightCredentials { get; set; } = 1000;
[DefaultValue(true)]
[JsonProperty(PropertyName = "AllowNotedInputRegistration", DefaultValueHandling = DefaultValueHandling.Populate)]

cleanup weight creds