|
1 | | -//! Signature-verification test fixture types (leanSpec PR #717 schema). |
| 1 | +//! Signature-verification test fixture types (leanSpec PR #799 schema). |
2 | 2 | //! |
3 | 3 | //! Used both by the offline spec-test runner and the Hive |
4 | 4 | //! `/lean/v0/test_driver/verify_signatures/run` endpoint, which receive the |
5 | 5 | //! same JSON shapes from the lean spec-assets simulator. |
6 | 6 | //! |
7 | | -//! Fixture shape after PR #717: |
| 7 | +//! Fixture shape after PR #799: |
8 | 8 | //! |
9 | 9 | //! signedBlock: |
10 | 10 | //! block: {...standard block fields...} |
11 | | -//! proof: { data: "0x<hex-encoded merged Type-2 bytes>" } |
| 11 | +//! proof: { proof: { data: "0x<hex-encoded merged Type-2 bytes>" } } |
12 | 12 |
|
13 | 13 | use crate::{Block, TestInfo, TestState}; |
14 | | -use ethlambda_types::block::{ByteList512KiB, SignedBlock}; |
| 14 | +use ethlambda_types::block::SignedBlock; |
15 | 15 | use serde::Deserialize; |
16 | 16 | use std::collections::HashMap; |
17 | 17 | use std::fmt; |
@@ -56,28 +56,21 @@ pub struct VerifySignaturesTest { |
56 | 56 | pub struct TestSignedBlock { |
57 | 57 | #[serde(alias = "message")] |
58 | 58 | pub block: Block, |
59 | | - pub proof: ProofField, |
| 59 | + pub proof: MergedProof, |
60 | 60 | } |
61 | 61 |
|
62 | | -/// Merged Type-2 proof bytes, in either fixture shape. |
| 62 | +/// Merged Type-2 proof container for `SignedBlock.proof` (leanSpec PR #799). |
63 | 63 | /// |
64 | | -/// leanSpec PR #799 typed `SignedBlock.proof` as a multi-signature container, |
65 | | -/// nesting the bytes one level deeper: `{ "proof": { "data": "0x..." } }`. |
66 | | -/// The flat `{ "data": "0x..." }` shape (PR #717) is still accepted since the |
67 | | -/// Hive test driver receives the same JSON from older spec-assets simulators. |
| 64 | +/// The multi-signature container nests the raw lean-multisig wire one level |
| 65 | +/// deep: `{ "proof": { "data": "0x..." } }`. |
68 | 66 | #[derive(Debug, Clone, Deserialize)] |
69 | | -#[serde(untagged)] |
70 | | -pub enum ProofField { |
71 | | - Typed { proof: HexBytes }, |
72 | | - Flat(HexBytes), |
| 67 | +pub struct MergedProof { |
| 68 | + pub proof: HexBytes, |
73 | 69 | } |
74 | 70 |
|
75 | | -impl ProofField { |
| 71 | +impl MergedProof { |
76 | 72 | pub fn decode(&self) -> Result<Vec<u8>, hex::FromHexError> { |
77 | | - match self { |
78 | | - Self::Typed { proof } => proof.decode(), |
79 | | - Self::Flat(bytes) => bytes.decode(), |
80 | | - } |
| 73 | + self.proof.decode() |
81 | 74 | } |
82 | 75 | } |
83 | 76 |
|
@@ -130,21 +123,16 @@ impl TestSignedBlock { |
130 | 123 | /// Materialize a `SignedBlock` preserving the fixture-supplied merged |
131 | 124 | /// Type-2 proof bytes verbatim. |
132 | 125 | /// |
133 | | - /// The typed shape carries the raw lean-multisig wire, so it gets wrapped |
134 | | - /// into the SSZ-container envelope `SignedBlock.proof` stores. The flat |
135 | | - /// shape already includes that envelope and passes through unchanged. |
| 126 | + /// The container carries the raw lean-multisig wire, so it gets wrapped |
| 127 | + /// into the SSZ-container envelope that `SignedBlock.proof` stores. |
136 | 128 | pub fn try_into_signed_block_with_proofs(self) -> Result<SignedBlock, SignedBlockConvertError> { |
137 | 129 | let bytes = self |
138 | 130 | .proof |
139 | 131 | .decode() |
140 | 132 | .map_err(|err| SignedBlockConvertError::InvalidProofHex(err.to_string()))?; |
141 | 133 | let len = bytes.len(); |
142 | | - let proof = match self.proof { |
143 | | - ProofField::Typed { .. } => SignedBlock::wrap_merged_proof(&bytes) |
144 | | - .map_err(|_| SignedBlockConvertError::ProofTooLarge(len))?, |
145 | | - ProofField::Flat(_) => ByteList512KiB::try_from(bytes) |
146 | | - .map_err(|_| SignedBlockConvertError::ProofTooLarge(len))?, |
147 | | - }; |
| 134 | + let proof = SignedBlock::wrap_merged_proof(&bytes) |
| 135 | + .map_err(|_| SignedBlockConvertError::ProofTooLarge(len))?; |
148 | 136 | Ok(SignedBlock { |
149 | 137 | message: self.block.into(), |
150 | 138 | proof, |
|
0 commit comments