From 91d0595631cc5f5bffc42a4b04d5015d2be659b1 Mon Sep 17 00:00:00 2001 From: Artem Fomiuk <88630083+Artemka374@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:23:44 +0300 Subject: [PATCH] fix: bincode deserialize for WitnessInputData (#3055) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Fix bincode deserialization for WitnessInputData ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk_supervisor fmt` and `zk_supervisor lint`. --- core/lib/prover_interface/src/inputs.rs | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/core/lib/prover_interface/src/inputs.rs b/core/lib/prover_interface/src/inputs.rs index f5f389362ddd..28bc1998312b 100644 --- a/core/lib/prover_interface/src/inputs.rs +++ b/core/lib/prover_interface/src/inputs.rs @@ -213,6 +213,25 @@ pub struct WitnessInputData { pub eip_4844_blobs: Eip4844Blobs, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct WitnessInputDataLegacy { + pub vm_run_data: VMRunWitnessInputDataLegacy, + pub merkle_paths: WitnessInputMerklePaths, + pub previous_batch_metadata: L1BatchMetadataHashes, + pub eip_4844_blobs: Eip4844Blobs, +} + +impl From for WitnessInputData { + fn from(value: WitnessInputDataLegacy) -> Self { + Self { + vm_run_data: value.vm_run_data.into(), + merkle_paths: value.merkle_paths, + previous_batch_metadata: value.previous_batch_metadata, + eip_4844_blobs: value.eip_4844_blobs, + } + } +} + impl StoredObject for WitnessInputData { const BUCKET: Bucket = Bucket::WitnessInput; @@ -222,7 +241,17 @@ impl StoredObject for WitnessInputData { format!("witness_inputs_{key}.bin") } - serialize_using_bincode!(); + fn serialize(&self) -> Result, BoxedError> { + zksync_object_store::bincode::serialize(self).map_err(Into::into) + } + + fn deserialize(bytes: Vec) -> Result { + zksync_object_store::bincode::deserialize::(&bytes).or_else(|_| { + zksync_object_store::bincode::deserialize::(&bytes) + .map(Into::into) + .map_err(Into::into) + }) + } } #[derive(Debug, Clone, Serialize, Deserialize)]