0xPolygonZero / plonky2

Apache License 2.0
755 stars 278 forks source link

Handle arbitrary, different `Stark` types as argument #1610

Open hratoanina opened 1 month ago

hratoanina commented 1 month ago

A long-standing problem has been to handle a collection of different STARKs in Plonky2. The problem is that Stark is a trait, and that its instantiations are created externally to the crate, in the project using starky. This prevents us from writing any kind of generic code for multi-STARK systems in plonky2, even though this is what we would want to following https://github.com/0xPolygonZero/plonky2/pull/1600.

Batched STARKs require to work with (e.g.) a Vec of different, arbitrary defined types implementing Stark. The issue is that Stark is not object-safe, meaning that we can't do something like Vec<Box<dyn Stark>>. Some possible solutions have been mentioned (@atanmarko, @dlubarov, @BGluth, @0xaatif):

Having a good solution would be extremely nice, but if needed we can just keep things as is and leave any multi-STARK code to the calling project.