From 1dd6bf2868aa2257d628c5530a522eb597360d31 Mon Sep 17 00:00:00 2001 From: Erwan Or Date: Wed, 3 Jul 2024 10:56:53 -0400 Subject: [PATCH] view: set `MAX_CB_SIZE_BYTES` to 12MB (#4694) ## Describe your changes This PR sets the max decoding size of the compact block client to 12MB. ## Checklist before requesting a review - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: --- crates/misc/measure/src/main.rs | 11 ++++++++--- crates/view/src/worker.rs | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/misc/measure/src/main.rs b/crates/misc/measure/src/main.rs index 70dd03cd44..b64837d10b 100644 --- a/crates/misc/measure/src/main.rs +++ b/crates/misc/measure/src/main.rs @@ -20,6 +20,9 @@ use penumbra_proto::{ use tonic::transport::{Channel, ClientTlsConfig}; use url::Url; +// The expected maximum size of a compact block message. +const MAX_CB_SIZE_BYTES: usize = 12 * 1024 * 1024; + #[derive(Debug, Parser)] #[clap( name = "penumbra-measure", @@ -99,7 +102,7 @@ impl Opt { js.spawn( async move { let mut client = - CompactBlockQueryServiceClient::connect(node2).await.unwrap(); + CompactBlockQueryServiceClient::connect(node2).await.unwrap().max_decoding_message_size(MAX_CB_SIZE_BYTES); let mut stream = client .compact_block_range(tonic::Request::new( @@ -144,7 +147,8 @@ impl Opt { js.spawn(async move { let mut client = CompactBlockQueryServiceClient::connect(node2) .await - .unwrap(); + .unwrap() + .max_decoding_message_size(MAX_CB_SIZE_BYTES); let mut stream = client .compact_block_range(tonic::Request::new(CompactBlockRangeRequest { @@ -181,7 +185,8 @@ impl Opt { .connect() .await?; - let mut cb_client = CompactBlockQueryServiceClient::new(channel.clone()); + let mut cb_client = CompactBlockQueryServiceClient::new(channel.clone()) + .max_decoding_message_size(MAX_CB_SIZE_BYTES); let end_height = self.latest_known_block_height().await?.0; let start_height = if skip_genesis { 1 } else { 0 }; diff --git a/crates/view/src/worker.rs b/crates/view/src/worker.rs index ce5124dedf..ddc92bc8a8 100644 --- a/crates/view/src/worker.rs +++ b/crates/view/src/worker.rs @@ -37,6 +37,9 @@ use crate::{ Storage, }; +// The maximum size of a compact block, in bytes (12MB). +const MAX_CB_SIZE_BYTES: usize = 12 * 1024 * 1024; + pub struct Worker { storage: Storage, sct: Arc>, @@ -192,7 +195,8 @@ impl Worker { .map(|h| h + 1) .unwrap_or(0); - let mut client = CompactBlockQueryServiceClient::new(self.channel.clone()); + let mut client = CompactBlockQueryServiceClient::new(self.channel.clone()) + .max_decoding_message_size(MAX_CB_SIZE_BYTES); let mut stream = client .compact_block_range(tonic::Request::new(CompactBlockRangeRequest { start_height,