Trac issueshttps://gitlab.torproject.org/legacy/trac/-/issues2020-06-13T15:01:55Zhttps://gitlab.torproject.org/legacy/trac/-/issues/20285can't create valid case 2b3 consens weight calculation2020-06-13T15:01:55Zpastlycan't create valid case 2b3 consens weight calculationEven if #20284 is fixed, I still can come up with values that produce a `Wed` that is too large. Maybe I'm not trying hard enough, but I can't get case 2b3 to execute successfully.
For example, let
```
M=80
E=20
G=30
D=10
T=M+E+G+D
``...Even if #20284 is fixed, I still can come up with values that produce a `Wed` that is too large. Maybe I'm not trying hard enough, but I can't get case 2b3 to execute successfully.
For example, let
```
M=80
E=20
G=30
D=10
T=M+E+G+D
```
In case 2b2, `Wed = (weight_scale*(D - 2*E + G + M))/(3*D) = 26667`. That's bigger than `weight_scale`. It (and `Wmd`) trigger case 2b3, which doesn't do anything about a too large `Wed` and thus `networkstatus_check_weights()` fails.
I admit I don't know how reasonable the values are that I came up with above. I am writing test cases so #14881 can be closed though, and just about any weird combination should be handled without failing. Right?
I don't know what the correct resolution is, so not patch/branch incoming at this time.Tor: unspecifiedhttps://gitlab.torproject.org/legacy/trac/-/issues/20284consensus weight case 2b3 does not follow dir-spec2020-07-31T12:42:39Zpastlyconsensus weight case 2b3 does not follow dir-spec[dir-spec](https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2681) says the following.
```
If M > T/3, then the Wmd weight above will become negative. Set it to 0
in this case:
Wmd = 0
Wgd = weight_scale - Wed
```
The ...[dir-spec](https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2681) says the following.
```
If M > T/3, then the Wmd weight above will become negative. Set it to 0
in this case:
Wmd = 0
Wgd = weight_scale - Wed
```
The code dutifully sets `Wmd` to 0, but neglects `Wgd`.
I assume the spec is correct and the intended behavior. Branch incoming once I get a ticket number.Tor: unspecifiedpastlypastlyhttps://gitlab.torproject.org/legacy/trac/-/issues/20272constraint broken in case 1 of consensus weight calculation2020-06-13T15:01:52Zpastlyconstraint broken in case 1 of consensus weight calculation[dir-spec](https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2648) specifies the constraint `Wmg == Wmd` in case 1, but also that
```
Wmg = (weight_scale*(2*G-E-M))/(3*G)
Wmd = weight_scale/3
```
This constraint is impossibl...[dir-spec](https://gitweb.torproject.org/torspec.git/tree/dir-spec.txt#n2648) specifies the constraint `Wmg == Wmd` in case 1, but also that
```
Wmg = (weight_scale*(2*G-E-M))/(3*G)
Wmd = weight_scale/3
```
This constraint is impossible to satisfy unless it just happens that `(2G-E-M)/G == 1`.
Indeed, in my testing of `networkstatus_compute_bw_weights_v10`, I found that `Wmg` and `Wmd` were calculated as above, but the constraint was ignored.
The easy solution is to change the spec, but that would ignore the logic that went into having that constraint in the first place. I do not know the logic that went into designing the consensus weight calculations, so I do not know if this solution is appropriate.Tor: unspecified