Trait sov_modules_api::Spec
source · pub trait Spec {
type Address: RollupAddress + BorshSerialize + BorshDeserialize;
type Storage: Storage + Clone + Send + Sync;
type PublicKey: BorshDeserialize + BorshSerialize + Eq + Hash + Clone + Debug + Send + Sync + PublicKey;
type Hasher: Digest<OutputSize = U32>;
type Signature: BorshDeserialize + BorshSerialize + Eq + Clone + Debug + Signature<PublicKey = Self::PublicKey> + Send + Sync;
type Witness: Witness;
}
Expand description
The Spec
trait configures certain key primitives to be used by a by a particular instance of a rollup.
Spec
is almost always implemented on a Context object; since all Modules are generic
over a Context, rollup developers can easily optimize their code for different environments
by simply swapping out the Context (and by extension, the Spec).
For example, a rollup running in a STARK-based zkvm like Risc0 might pick Sha256 or Poseidon as its preferred hasher,
while a rollup running in an elliptic-curve based SNARK such as Placeholder
from the =nil; foundation might
prefer a Pedersen hash. By using a generic Context and Spec, a rollup developer can trivially customize their
code for either (or both!) of these environments without touching their module implementations.
Required Associated Types§
sourcetype Address: RollupAddress + BorshSerialize + BorshDeserialize
type Address: RollupAddress + BorshSerialize + BorshDeserialize
The Address type used on the rollup. Typically calculated as the hash of a public key.
sourcetype Storage: Storage + Clone + Send + Sync
type Storage: Storage + Clone + Send + Sync
Authenticated state storage used by the rollup. Typically some variant of a merkle-patricia trie.
type PublicKey: BorshDeserialize + BorshSerialize + Eq + Hash + Clone + Debug + Send + Sync + PublicKey
sourcetype Hasher: Digest<OutputSize = U32>
type Hasher: Digest<OutputSize = U32>
The hasher preferred by the rollup, such as Sha256 or Poseidon.