From c57d1b44ef1b8cb903891e9783702c6682a18932 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 15 Jun 2021 17:34:07 -0600 Subject: [PATCH] Properly handle block_height in Bigtable bincode deserialization (#17990) * Default block_height on eof * Add comment to prevent future errors --- storage-bigtable/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/storage-bigtable/src/lib.rs b/storage-bigtable/src/lib.rs index 767d34684d..b78b145a2a 100644 --- a/storage-bigtable/src/lib.rs +++ b/storage-bigtable/src/lib.rs @@ -3,6 +3,7 @@ use log::*; use serde::{Deserialize, Serialize}; use solana_sdk::{ clock::{Slot, UnixTimestamp}, + deserialize_utils::default_on_eof, pubkey::Pubkey, signature::Signature, sysvar::is_sysvar_id, @@ -81,6 +82,9 @@ fn key_to_slot(key: &str) -> Option { // StoredConfirmedBlock holds the same contents as ConfirmedBlock, but is slightly compressed and avoids // some serde JSON directives that cause issues with bincode // +// Note: in order to continue to support old bincode-serialized bigtable entries, if new fields are +// added to ConfirmedBlock, they must either be excluded or set to `default_on_eof` here +// #[derive(Serialize, Deserialize)] struct StoredConfirmedBlock { previous_blockhash: String, @@ -89,6 +93,7 @@ struct StoredConfirmedBlock { transactions: Vec, rewards: StoredConfirmedBlockRewards, block_time: Option, + #[serde(deserialize_with = "default_on_eof")] block_height: Option, }