Trust-Machines / wsts

Weighted Schnorr Threshold Signatures
Apache License 2.0
26 stars 12 forks source link

Use layered traits to dedup common coordinator code #37

Open xoloki opened 10 months ago

xoloki commented 10 months ago

The original frost::Coordinator provided basic functionality, but the new fire::Coordinator does much more in terms of handling timeouts etc, even without the byzantine handling.

In a reasonable OO language, it would be trivial to pull the common code into a base class. Rust, sadly, is not reasonable in this way.

To make this work in Rust, do the following:

  1. define a coordinator::common::Coordinator trait, where we put common functionality
  2. define a coordinator::common::Fields trait, which has accessors for common fields
  3. common::Coordinator is a subtrait of common::Fields, which gives it access to needed fields
  4. fire::Coordinator will then impl both common traits, with some boilerplate to connect its data fields to the trait (this can be replaced by a macro)
  5. frost::Coordinator will do the same as fire::Coordinator. If they use a macro then they will actually manage to inherit code from the base trait in a reasonably sane way