Skip to content

Commit

Permalink
view: set MAX_CB_SIZE_BYTES to 12MB (#4694)
Browse files Browse the repository at this point in the history
## 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:
  • Loading branch information
erwanor committed Jul 3, 2024
1 parent ba42416 commit 1dd6bf2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions crates/misc/measure/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 };
Expand Down
6 changes: 5 additions & 1 deletion crates/view/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RwLock<penumbra_tct::Tree>>,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1dd6bf2

Please sign in to comment.