snarkVM
snarkVM copied to clipboard
[Proposal] Explore alternatives to traits to hold network and environment parameters
💥 Proposal
There's a network trait currently implemented by the tesnet3 struct to hold the parameters of the current test network.
This has a number of drawbacks:
- This trait implementation spreads all over the struct implementations of multiple repos, to be used in places that shouldn't be directly affected by network specifics, effectively spreading the knowledge instead of encapsulating it.
- Code using this trait is harder to write and especially to read than code that doesn't rely on traits.
- serde serialization/deserialization can get complicated if the struct use generics.
- Code that relies on generics is slower to compile.
These drawbacks can be more or less acceptable as long as there's a benefit to be gained in return. But considering that a Network struct is ultimately a bag of constants and functions and that the codebase will only deal with one network implementation at a time, it's likely that the trait can be replaced by a simpler alternative, like a plain module, a configuration file or a non-generic network struct.
The environment trait seems to be used similarly and thus the same kind of simplifcation can apply to it.