|
| 1 | +use crate::{test_utils::TestRandom, *}; |
| 2 | +use derivative::Derivative; |
| 3 | +use serde::{Deserialize, Serialize}; |
| 4 | +use ssz_derive::{Decode, Encode}; |
| 5 | +use test_random_derive::TestRandom; |
| 6 | +use tree_hash_derive::TreeHash; |
| 7 | + |
| 8 | +#[derive( |
| 9 | + Default, |
| 10 | + Debug, |
| 11 | + Clone, |
| 12 | + Serialize, |
| 13 | + Deserialize, |
| 14 | + Encode, |
| 15 | + Decode, |
| 16 | + TreeHash, |
| 17 | + TestRandom, |
| 18 | + Derivative, |
| 19 | + arbitrary::Arbitrary, |
| 20 | +)] |
| 21 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 22 | +#[arbitrary(bound = "E: EthSpec")] |
| 23 | +#[serde(bound = "E: EthSpec")] |
| 24 | +#[ssz(struct_behaviour = "transparent")] |
| 25 | +#[serde(transparent)] |
| 26 | +pub struct BanderwagonGroupElement<E: EthSpec> { |
| 27 | + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] |
| 28 | + inner: FixedVector<u8, E::BytesPerBanderwagonElement>, |
| 29 | +} |
| 30 | + |
| 31 | +#[derive( |
| 32 | + Default, |
| 33 | + Debug, |
| 34 | + Clone, |
| 35 | + Serialize, |
| 36 | + Deserialize, |
| 37 | + Encode, |
| 38 | + Decode, |
| 39 | + TreeHash, |
| 40 | + TestRandom, |
| 41 | + Derivative, |
| 42 | + arbitrary::Arbitrary, |
| 43 | +)] |
| 44 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 45 | +#[arbitrary(bound = "E: EthSpec")] |
| 46 | +#[serde(bound = "E: EthSpec")] |
| 47 | +#[ssz(struct_behaviour = "transparent")] |
| 48 | +#[serde(transparent)] |
| 49 | +pub struct BanderwagonFieldElement<E: EthSpec> { |
| 50 | + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] |
| 51 | + inner: FixedVector<u8, E::BytesPerBanderwagonElement>, |
| 52 | +} |
| 53 | + |
| 54 | +#[derive( |
| 55 | + Default, |
| 56 | + Debug, |
| 57 | + Clone, |
| 58 | + Serialize, |
| 59 | + Deserialize, |
| 60 | + Encode, |
| 61 | + Decode, |
| 62 | + TreeHash, |
| 63 | + TestRandom, |
| 64 | + Derivative, |
| 65 | + arbitrary::Arbitrary, |
| 66 | +)] |
| 67 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 68 | +#[arbitrary(bound = "E: EthSpec")] |
| 69 | +#[serde(bound = "E: EthSpec")] |
| 70 | +#[ssz(struct_behaviour = "transparent")] |
| 71 | +#[serde(transparent)] |
| 72 | +pub struct Stem<E: EthSpec> { |
| 73 | + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] |
| 74 | + inner: FixedVector<u8, E::MaxStemLength>, |
| 75 | +} |
| 76 | + |
| 77 | +#[derive( |
| 78 | + Default, |
| 79 | + Debug, |
| 80 | + Clone, |
| 81 | + Serialize, |
| 82 | + Deserialize, |
| 83 | + Encode, |
| 84 | + Decode, |
| 85 | + TreeHash, |
| 86 | + TestRandom, |
| 87 | + Derivative, |
| 88 | + arbitrary::Arbitrary, |
| 89 | +)] |
| 90 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 91 | +#[arbitrary(bound = "E: EthSpec")] |
| 92 | +#[serde(bound = "E: EthSpec")] |
| 93 | +#[ssz(struct_behaviour = "transparent")] |
| 94 | +#[serde(transparent)] |
| 95 | +pub struct StateDiffValue<E: EthSpec> { |
| 96 | + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] |
| 97 | + inner: FixedVector<u8, E::BytesPerSuffixStateDiffValue>, |
| 98 | +} |
| 99 | + |
| 100 | +#[derive( |
| 101 | + Default, |
| 102 | + Debug, |
| 103 | + Clone, |
| 104 | + Serialize, |
| 105 | + Deserialize, |
| 106 | + Encode, |
| 107 | + Decode, |
| 108 | + TreeHash, |
| 109 | + TestRandom, |
| 110 | + Derivative, |
| 111 | + arbitrary::Arbitrary, |
| 112 | +)] |
| 113 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 114 | +#[arbitrary(bound = "E: EthSpec")] |
| 115 | +#[serde(bound = "E: EthSpec")] |
| 116 | +pub struct SuffixStateDiff<E: EthSpec> { |
| 117 | + //#[serde(with = "eth2_serde_utils::quoted_u8")] |
| 118 | + pub suffix: u8, |
| 119 | + // `None` means not currently present. |
| 120 | + pub current_value: Optional<StateDiffValue<E>>, |
| 121 | + // `None` means value is not updated. |
| 122 | + pub new_value: Optional<StateDiffValue<E>>, |
| 123 | +} |
| 124 | + |
| 125 | +#[derive( |
| 126 | + Default, |
| 127 | + Debug, |
| 128 | + Clone, |
| 129 | + Serialize, |
| 130 | + Deserialize, |
| 131 | + Encode, |
| 132 | + Decode, |
| 133 | + TreeHash, |
| 134 | + TestRandom, |
| 135 | + Derivative, |
| 136 | + arbitrary::Arbitrary, |
| 137 | +)] |
| 138 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 139 | +#[arbitrary(bound = "E: EthSpec")] |
| 140 | +#[serde(bound = "E: EthSpec")] |
| 141 | +pub struct StemStateDiff<E: EthSpec> { |
| 142 | + pub stem: Stem<E>, |
| 143 | + pub suffix_diffs: VariableList<SuffixStateDiff<E>, E::MaxVerkleWidth>, |
| 144 | +} |
| 145 | + |
| 146 | +#[derive( |
| 147 | + Default, |
| 148 | + Debug, |
| 149 | + Clone, |
| 150 | + Serialize, |
| 151 | + Deserialize, |
| 152 | + Encode, |
| 153 | + Decode, |
| 154 | + TreeHash, |
| 155 | + TestRandom, |
| 156 | + Derivative, |
| 157 | + arbitrary::Arbitrary, |
| 158 | +)] |
| 159 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 160 | +#[arbitrary(bound = "E: EthSpec")] |
| 161 | +#[serde(bound = "E: EthSpec")] |
| 162 | +#[ssz(struct_behaviour = "transparent")] |
| 163 | +#[serde(transparent)] |
| 164 | +pub struct StateDiff<E: EthSpec> { |
| 165 | + pub inner: VariableList<StemStateDiff<E>, E::MaxStems>, |
| 166 | +} |
| 167 | + |
| 168 | +#[derive( |
| 169 | + Default, |
| 170 | + Debug, |
| 171 | + Clone, |
| 172 | + Serialize, |
| 173 | + Deserialize, |
| 174 | + Encode, |
| 175 | + Decode, |
| 176 | + TreeHash, |
| 177 | + TestRandom, |
| 178 | + Derivative, |
| 179 | + arbitrary::Arbitrary, |
| 180 | +)] |
| 181 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 182 | +#[arbitrary(bound = "E: EthSpec")] |
| 183 | +#[serde(bound = "E: EthSpec")] |
| 184 | +pub struct IpaProof<E: EthSpec> { |
| 185 | + pub cl: FixedVector<BanderwagonGroupElement<E>, E::IpaProofDepth>, |
| 186 | + pub cr: FixedVector<BanderwagonGroupElement<E>, E::IpaProofDepth>, |
| 187 | + pub final_evaluation: BanderwagonFieldElement<E>, |
| 188 | +} |
| 189 | + |
| 190 | +#[derive( |
| 191 | + Default, |
| 192 | + Debug, |
| 193 | + Clone, |
| 194 | + Serialize, |
| 195 | + Deserialize, |
| 196 | + Encode, |
| 197 | + Decode, |
| 198 | + TreeHash, |
| 199 | + TestRandom, |
| 200 | + Derivative, |
| 201 | + arbitrary::Arbitrary, |
| 202 | +)] |
| 203 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 204 | +#[arbitrary(bound = "E: EthSpec")] |
| 205 | +#[serde(bound = "E: EthSpec")] |
| 206 | +#[ssz(struct_behaviour = "transparent")] |
| 207 | +#[serde(transparent)] |
| 208 | +pub struct StemValue<E: EthSpec> { |
| 209 | + #[serde(with = "ssz_types::serde_utils::hex_fixed_vec")] |
| 210 | + inner: FixedVector<u8, E::MaxStemLength>, |
| 211 | +} |
| 212 | + |
| 213 | +#[derive( |
| 214 | + Default, |
| 215 | + Debug, |
| 216 | + Clone, |
| 217 | + Serialize, |
| 218 | + Deserialize, |
| 219 | + Encode, |
| 220 | + Decode, |
| 221 | + TreeHash, |
| 222 | + TestRandom, |
| 223 | + Derivative, |
| 224 | + arbitrary::Arbitrary, |
| 225 | +)] |
| 226 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 227 | +#[arbitrary(bound = "E: EthSpec")] |
| 228 | +#[serde(bound = "E: EthSpec")] |
| 229 | +pub struct VerkleProof<E: EthSpec> { |
| 230 | + pub other_stems: VariableList<StemValue<E>, E::MaxStems>, |
| 231 | + #[serde(with = "ssz_types::serde_utils::hex_var_list")] |
| 232 | + pub depth_extension_present: VariableList<u8, E::MaxStems>, |
| 233 | + pub commitments_by_path: VariableList<BanderwagonGroupElement<E>, E::MaxCommittments>, |
| 234 | + pub d: BanderwagonGroupElement<E>, |
| 235 | + pub ipa_proof: IpaProof<E>, |
| 236 | +} |
| 237 | + |
| 238 | +#[derive( |
| 239 | + Default, |
| 240 | + Debug, |
| 241 | + Clone, |
| 242 | + Serialize, |
| 243 | + Deserialize, |
| 244 | + Encode, |
| 245 | + Decode, |
| 246 | + TreeHash, |
| 247 | + TestRandom, |
| 248 | + Derivative, |
| 249 | + arbitrary::Arbitrary, |
| 250 | +)] |
| 251 | +#[derivative(PartialEq, Hash(bound = "E: EthSpec"))] |
| 252 | +#[arbitrary(bound = "E: EthSpec")] |
| 253 | +#[serde(bound = "E: EthSpec")] |
| 254 | +pub struct ExecutionWitness<E: EthSpec> { |
| 255 | + pub state_diff: StateDiff<E>, |
| 256 | + pub verkle_proof: VerkleProof<E>, |
| 257 | +} |
0 commit comments