Currently our sad path rounds return only a list of criminals with no information on what crime(s) they committed. In the future we might want to offer this information to tofn users so they can better decide how to punish criminals. (For example, maybe some crimes do not deserve as much punishment as others.)
Due to this design, our tests for malicious behaviour check only that sign participants agree on the list of criminals. This is bad because we cannot ensure code coverage by tests. Code coverage is especially important in complicated cases such as r8_fail_randomizer.
We should enhance our tests to check for specific crimes. Our current design does not allow for such checking, so we should change the design to allow it. Thus, I have pushed a new branch with a prototype design change.
Overview
add a new field final_output2 of type SignOutput2 to Sign, mirroring the existing final_output, SignOutput.
SignOutput2 replaces Vec<Criminal> with Vec<Vec<Crime>>. The idea is that sad path now returns a list of crimes for each participant. ie. crimes[i] is a list of crimes committed by participant i. Crimes lists may be empty, and each participant has a list, even if it's empty (which happens when a participant is honest).
This design is open to discussion. I thought it best to return as much information about crimes as possible, so that we have maximal freedom to decide on penalties for criminals. For example, if we allowed only one crime per participant then perhaps a criminal might cause tofn to overwrite a very bad crime with a not-so-bad crime, thus evading proper punishment.
The intent is to allow for a gradual migration to the new design. Each sad-path round can be converted from Vec<Criminal> to Vec<Vec<Crime>> independently of the others. After migration is complete, we delete everything without a 2 at the end and rename everything with a 2.
I implemented 2 examples: r3_fail.rs (easy prototype) and r8_fail_randomizer.rs (complicated example). The remaining sad-path files can follow the same pattern.
I added test cases for the new examples in test_cases2.rs. You can add more test cases here for each sad-path round as you go. I added a execute_test_case2 function to tests/mod.rs mirroring execute_test_case.
There's a helper function to_criminals used to convert a Vec<Vec<Crime>> to Vec<Criminal> expected by the tofn library API so we don't break anything.
Tidying
I deleted ONE_CRIMINAL_TEST_CASES and associated code because those tests are redundant. simple_tests does the job much more cleanly.
Log messages about malicious behaviours or crimes now use the debug display feature for enums for a more consistent presentation.
Currently our sad path rounds return only a list of criminals with no information on what crime(s) they committed. In the future we might want to offer this information to tofn users so they can better decide how to punish criminals. (For example, maybe some crimes do not deserve as much punishment as others.)
Due to this design, our tests for malicious behaviour check only that sign participants agree on the list of criminals. This is bad because we cannot ensure code coverage by tests. Code coverage is especially important in complicated cases such as
r8_fail_randomizer
.We should enhance our tests to check for specific crimes. Our current design does not allow for such checking, so we should change the design to allow it. Thus, I have pushed a new branch with a prototype design change.
Overview
final_output2
of typeSignOutput2
toSign
, mirroring the existingfinal_output
,SignOutput
.SignOutput2
replacesVec<Criminal>
withVec<Vec<Crime>>
. The idea is that sad path now returns a list of crimes for each participant. ie.crimes[i]
is a list of crimes committed by participanti
. Crimes lists may be empty, and each participant has a list, even if it's empty (which happens when a participant is honest).Vec<Criminal>
toVec<Vec<Crime>>
independently of the others. After migration is complete, we delete everything without a2
at the end and rename everything with a2
.r3_fail.rs
(easy prototype) andr8_fail_randomizer.rs
(complicated example). The remaining sad-path files can follow the same pattern.test_cases2.rs
. You can add more test cases here for each sad-path round as you go. I added aexecute_test_case2
function totests/mod.rs
mirroringexecute_test_case
.to_criminals
used to convert aVec<Vec<Crime>>
toVec<Criminal>
expected by the tofn library API so we don't break anything.Tidying
ONE_CRIMINAL_TEST_CASES
and associated code because those tests are redundant.simple_tests
does the job much more cleanly.