From 7fade4e21f6ca4b8837cbfd703fc756e289be262 Mon Sep 17 00:00:00 2001 From: deuszx Date: Thu, 16 Jan 2025 18:04:58 +0100 Subject: [PATCH] Serialize Keccak256 as array, not slice. --- linera-base/src/crypto.rs | 6 +++--- linera-chain/src/chain.rs | 2 +- linera-chain/src/unit_tests/chain_tests.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linera-base/src/crypto.rs b/linera-base/src/crypto.rs index 09f47431821..aa0e3e4d90b 100644 --- a/linera-base/src/crypto.rs +++ b/linera-base/src/crypto.rs @@ -166,7 +166,7 @@ impl Serialize for CryptoHash { if serializer.is_human_readable() { serializer.serialize_str(&self.to_string()) } else { - serializer.serialize_newtype_struct("CryptoHash", &self.0) + serializer.serialize_newtype_struct("CryptoHash", &self.0 .0) } } } @@ -183,10 +183,10 @@ impl<'de> Deserialize<'de> for CryptoHash { } else { #[derive(Deserialize)] #[serde(rename = "CryptoHash")] - struct Foo(B256); + struct Foo([u8; 32]); let value = Foo::deserialize(deserializer)?; - Ok(Self(value.0)) + Ok(Self(value.0.into())) } } } diff --git a/linera-chain/src/chain.rs b/linera-chain/src/chain.rs index 99f8f2fb3cc..0d5fa35cd0b 100644 --- a/linera-chain/src/chain.rs +++ b/linera-chain/src/chain.rs @@ -148,7 +148,7 @@ static STATE_HASH_COMPUTATION_LATENCY: LazyLock = LazyLock::new(|| }); /// The BCS-serialized size of an empty `ExecutedBlock`. -const EMPTY_EXECUTED_BLOCK_SIZE: usize = 93; +const EMPTY_EXECUTED_BLOCK_SIZE: usize = 91; /// An origin, cursor and timestamp of a unskippable bundle in our inbox. #[derive(Debug, Clone, Serialize, Deserialize, async_graphql::SimpleObject)] diff --git a/linera-chain/src/unit_tests/chain_tests.rs b/linera-chain/src/unit_tests/chain_tests.rs index 9752e25fdfb..c504e11a47e 100644 --- a/linera-chain/src/unit_tests/chain_tests.rs +++ b/linera-chain/src/unit_tests/chain_tests.rs @@ -112,7 +112,7 @@ async fn test_block_size_limit() { let mut chain = ChainStateView::new(chain_id).await; // The size of the executed valid block below. - let maximum_executed_block_size = 713; + let maximum_executed_block_size = 707; // Initialize the chain. let mut config = make_open_chain_config();