Skip to content

Conversation

insumity
Copy link
Collaborator

@insumity insumity commented Sep 8, 2025

Closes: #5

Description
This PR introduces a way to utilize the extensions field of Value so that we can have blocks of roughly block_size in the tests.
Note that the size of blocks will not be exactly block_size because a block besides the Value contains the commit certificate that adds a few tens of bytes to the total block size. Additionally, the actual block sent over the wire might be slightly more bytes due to encoding. This PR also brings ProtobufCodec instead of JsonCodec when encoding values in order to be able to be "closer" to the block_size, otherwise, 1 KiB of extensions, might lead to having 10 more KiB in the block_size due to the way extensions would JSON encoded.
Finally, note that this PR, besides a nit change in code/examples/channel/src/state.rs, did not modify the channel example and left it as is.

Testing
To see that it works, you can try the following 2 tests in code/crates/test/tests/it/value_sync.rs:

#[tokio::test]
pub async fn test_block_size_more_than_rpc_size_times_out() {
    let params = TestParams {
        rpc_max_size: ByteSize::kib(10),
        block_size: ByteSize::kib(15),
        ..Default::default()
    };

    crash_restart_from_start(params).await
}

#[tokio::test]
pub async fn test_block_size_more_than_rpc_size_succeeds() {
    let params = TestParams {
        rpc_max_size: ByteSize::kib(15),
        block_size: ByteSize::kib(10),
        ..Default::default()
    };

    crash_restart_from_start(params).await
}

Ideally, we should be able to include test_block_size_more_than_rpc_size_times_out in the codebase and have it verify that it times out. However, the way the testing framework is currently written, run_with_params does not return a result and exits internally, so we cannot do this without quite some refactoring.


PR author checklist

For all contributors

For external contributors

protocol: PubSubProtocol::default(),
block_size: ByteSize::mib(1),
tx_size: ByteSize::kib(1),
rpc_max_size: ByteSize::kib(25),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's set to 25 KiB because there are syncing tests that have batch_size of 2 and hence rpc_max_size needs to be greater than 20 KiB. Note that the max_response_size PR is not in yet.

@insumity insumity marked this pull request as ready for review September 8, 2025 14:11
@insumity insumity force-pushed the insumity/fix-test-extensions branch 2 times, most recently from 86206fd to 0063083 Compare September 8, 2025 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: block_size is not respected in tests
1 participant