From b02ac7aaf63489a86b0de82d323b4f691487f02b Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul <8294320+gligneul@users.noreply.github.com> Date: Tue, 12 Sep 2023 08:07:38 -0300 Subject: [PATCH] feat(advance-runner): add max_decoding_message_size config --- CHANGELOG.md | 1 + offchain/advance-runner/src/server_manager/config.rs | 6 ++++++ offchain/advance-runner/src/server_manager/facade.rs | 3 ++- offchain/advance-runner/tests/fixtures/mod.rs | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7cfcc7f..5da08d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated state-fold libraries to version 0.8 - Added `SS_MAX_DECODING_MESSAGE_SIZE` to state-server and dispatcher with 100MB default +- Added `MAX_DECODING_MESSAGE_SIZE` to advance runner with 100MB default ### Fixed diff --git a/offchain/advance-runner/src/server_manager/config.rs b/offchain/advance-runner/src/server_manager/config.rs index 74ff4441..5c98d958 100644 --- a/offchain/advance-runner/src/server_manager/config.rs +++ b/offchain/advance-runner/src/server_manager/config.rs @@ -11,6 +11,7 @@ use grpc_interfaces::cartesi_server_manager::{CyclesConfig, DeadlineConfig}; #[derive(Debug, Clone)] pub struct ServerManagerConfig { pub server_manager_endpoint: String, + pub max_decoding_message_size: usize, pub session_id: String, pub pending_inputs_sleep_duration: u64, pub pending_inputs_max_retries: u64, @@ -52,6 +53,7 @@ impl ServerManagerConfig { Self { server_manager_endpoint: cli_config.server_manager_endpoint, + max_decoding_message_size: cli_config.max_decoding_message_size, session_id: cli_config.session_id, pending_inputs_sleep_duration: cli_config .sm_pending_inputs_sleep_duration, @@ -71,6 +73,10 @@ pub struct ServerManagerCLIConfig { #[arg(long, env, default_value = "http://127.0.0.1:5001")] pub server_manager_endpoint: String, + /// Maximum size of a decoded message + #[arg(long, env, default_value_t = 100 * 1024 * 1024)] + pub max_decoding_message_size: usize, + /// Server-manager session id #[arg(long, env, default_value = "default_rollups_id")] pub session_id: String, diff --git a/offchain/advance-runner/src/server_manager/facade.rs b/offchain/advance-runner/src/server_manager/facade.rs index a066edad..7e8fd5b9 100644 --- a/offchain/advance-runner/src/server_manager/facade.rs +++ b/offchain/advance-runner/src/server_manager/facade.rs @@ -102,7 +102,8 @@ impl ServerManagerFacade { .map_err(Error::transient) }) .await - .context(ConnectionSnafu)?; + .context(ConnectionSnafu)? + .max_decoding_message_size(config.max_decoding_message_size); Ok(Self { client, diff --git a/offchain/advance-runner/tests/fixtures/mod.rs b/offchain/advance-runner/tests/fixtures/mod.rs index f36d6f18..891a19dd 100644 --- a/offchain/advance-runner/tests/fixtures/mod.rs +++ b/offchain/advance-runner/tests/fixtures/mod.rs @@ -56,6 +56,7 @@ impl AdvanceRunnerFixture { let server_manager_config = ServerManagerConfig { server_manager_endpoint, + max_decoding_message_size: 100 * 1024 * 1024, session_id, pending_inputs_sleep_duration: 1000, pending_inputs_max_retries: 10,