Skip to main content

reth_trie_common/
execution_witness.rs

1/// Controls how execution witnesses are generated.
2#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
5pub enum ExecutionWitnessMode {
6    /// Produces the legacy execution witness format.
7    #[default]
8    Legacy,
9    /// Produces the canonical spec currently implemented in
10    /// ethereum/execution-specs@projects/zkevm. The main differences with the
11    /// legacy format are:
12    /// - For the `bytecode` field:
13    ///     - It contains only bytecodes required for execution, compared to Legacy which also
14    ///       contains created bytecode.
15    ///     - Compared to Legacy, it does not include empty bytecodes (i.e. 0x80).
16    ///     - Values are sorted lexicographically ascending.
17    /// - For the `state` field:
18    ///     - Avoids including empty nodes (i.e. 0x80).
19    ///     - Compared to legacy, it does not include storage trie root nodes if no storage is
20    ///       accessed.
21    ///     - It contains the minimum amount of siblings for post-state root calculation, since it
22    ///       does updates/insertions first and then deletions. Compared to legacy which does the
23    ///       post-state calculation with removals and then insertions/updates, which results in
24    ///       more siblings.
25    ///     - Values are sorted lexicographically ascending.
26    Canonical,
27}
28
29impl ExecutionWitnessMode {
30    /// Returns `true` if the mode is [`Self::Canonical`].
31    pub const fn is_canonical(self) -> bool {
32        matches!(self, Self::Canonical)
33    }
34}