boltlabs-inc / zeekoe

Zero-knowledge layer-2 payment channels
MIT License
24 stars 1 forks source link

Decide on storage format for database + versioning #99

Open yaymukund opened 3 years ago

yaymukund commented 3 years ago

There are broadly two approaches we've considered:

  1. impl sqlx::Encode/Decode for all the important types. This doesn't work transitively - if my parent struct is composed of fields that are all Encode/Decode then I need to either insert the struct as a table (i.e. each field gets its own column) or I need to impl Encode/Decode for the parent struct. But this gives us complete control over how we represent the data.

  2. Rely on bincode::serialize/deserialize for complex structs. This lets us reuse a macro impl_sqlx_for_bincode_ty!(Foo) that simply calls bincode::serialize/deserialize to Encode/Decode for any struct that implements Serialize/Deserialize.

It looks like bincode provides some fairly strong storage guarantees so long-term I am leaning towards approach 2, perhaps wrapped to include some version bytes at the front.

yaymukund commented 3 years ago

I've moved this into the "Maybe milestone 4" epic since this isn't part of M3.