consensus_encoding: fix wrong default limit in CompactSizeDecoder docs
What changed, and why it matters
This commit only corrects a comment in the source code. The documentation for CompactSizeDecoder incorrectly stated that the default decoded-value limit was 4,000,000, when the actual default is 33,554,432 bytes (32 MB). No program logic, limits, or behavior were changed.
No action required; this is a non-functional documentation correction.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is a documentation-only fix in consensus_encoding/src/compact_size.rs. It updates the doc comment for CompactSizeDecoder to accurately reflect the default limit enforced by the code (MAX_COMPACT_SIZE = 0x0200_0000 = 32 MiB). The 4,000,000 figure applies to vector decoders (MAX_VEC_SIZE), not compact-size decoding. The actual limit constant and decoder implementation are untouched.
Changed components
consensus_encoding/src/compact_size.rs documentationInspect captured patch +4 / −4
### consensus_encoding/src/compact_size.rs
@@ -129,10 +129,10 @@ impl ExactSizeEncoder for CompactSizeEncoder {
/// Decodes a compact size encoded integer as a length prefix.
///
/// The decoded value is returned as a `usize` and is bounded by a configurable limit (default:
-/// 4,000,000). This limit is a denial-of-service protection: a malicious peer can send a compact
-/// size value up to 2^64-1, and without a limit check the caller might attempt to allocate an
-/// enormous buffer based on that value. [`CompactSizeDecoder`] prevents this by rejecting values
-/// that exceed the limit before returning them to the caller.
+/// 32 MB, or 33,554,432 bytes). This limit is a denial-of-service protection: a malicious peer can
+/// send a compact size value up to 2^64-1, and without a limit check the caller might attempt to
+/// allocate an enormous buffer based on that value. [`CompactSizeDecoder`] prevents this by
+/// rejecting values that exceed the limit before returning them to the caller.
///
/// If you are decoding an arbitrary `u64` integer that is genuinely not a length prefix, use
/// [`CompactSizeU64Decoder`] instead.Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.