gballet / multiproof-rs

A rust implementation of Alexey Akhunov's multiproof algorithm
Apache License 2.0
33 stars 8 forks source link

Add NodeEncoding trait #24

Open axic opened 5 years ago

gballet commented 5 years ago

I understand that this is still in progress and it might change. Still, I'm commenting so that you don't spend too much time going in the wrong direction: in its current state, this code binds Node serialization to rlp. The idea behind that library is to factor the algorithm and leave details such as the encoding format.

So if someone (presumably in the eth1 world) needs RLP, they just need to implement rlp::Encodable (which is already done). If someone wants to use SSZ, then they will need to implement somthing like ssz::Encodable. And if someone wants JSON (currently in the pipe), they can implement serde::Serializable.

Maybe I misunderstand what you're trying to do. Just please update the description when you have a moment.

axic commented 5 years ago

I'm not sure what is the confusion, but since the the proof builder and verifier both internally encode things, you need a trait to run that encoding, which is not tied to RLP.

And this is only the first step. You'd provide different impls of Node to make_multiproof and rebuild which either fully use RLP or SSZ, but this trait is shared between the two.