From 32397b975ae91775759defb1f7e64651d3dba927 Mon Sep 17 00:00:00 2001 From: Jan Ciolek <149345204+jancionear@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:50:00 +0200 Subject: [PATCH] Increase MAX_COMPRESSED_STATE_WITNESS_SIZE to 48 MiB (#11683) The `MAX_COMPRESSED_STATE_WITNESS_SIZE` has been set to 32 MiB in https://github.com/near/nearcore/pull/11511. Back then it was a reasonable choice, but since then we increased some of the runtime parameters, which increased the worst case witness size by ~17MiB. (https://github.com/near/nearcore/pull/11582, https://github.com/near/nearcore/pull/11629). I'd feel safer with a larger limit on the compressed witness size. --- .../partial_witness/partial_witness_tracker.rs | 2 +- core/primitives/src/stateless_validation.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs b/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs index ab5c9882847..bd131159ac1 100644 --- a/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs +++ b/chain/client/src/stateless_validation/partial_witness/partial_witness_tracker.rs @@ -21,7 +21,7 @@ use super::encoding::{WitnessEncoder, WitnessEncoderCache, WitnessPart}; /// Max number of chunks to keep in the witness tracker cache. We reach here only after validation /// of the partial_witness so the LRU cache size need not be too large. /// This effectively limits memory usage to the size of the cache multiplied by -/// MAX_COMPRESSED_STATE_WITNESS_SIZE, currently 40 * 32MiB = 1280MiB +/// MAX_COMPRESSED_STATE_WITNESS_SIZE, currently 40 * 48MiB = 1920MiB. const WITNESS_PARTS_CACHE_SIZE: usize = 40; /// Number of entries to keep in LRU cache of the processed state witnesses diff --git a/core/primitives/src/stateless_validation.rs b/core/primitives/src/stateless_validation.rs index fa57200773e..b0d861ffb91 100644 --- a/core/primitives/src/stateless_validation.rs +++ b/core/primitives/src/stateless_validation.rs @@ -18,7 +18,7 @@ use near_primitives_core::version::{ProtocolFeature, PROTOCOL_VERSION}; /// Represents max allowed size of the compressed state witness, /// corresponds to EncodedChunkStateWitness struct size. -pub const MAX_COMPRESSED_STATE_WITNESS_SIZE: ByteSize = ByteSize::mib(32); +pub const MAX_COMPRESSED_STATE_WITNESS_SIZE: ByteSize = ByteSize::mib(48); /// Represents max allowed size of the raw (not compressed) state witness, /// corresponds to the size of borsh-serialized ChunkStateWitness.