bootstrap_batch_allocation_budget

Function bootstrap_batch_allocation_budget 

Source
pub const fn bootstrap_batch_allocation_budget(
    section_wire_size: usize,
) -> usize
Expand description

Budget for the in-memory footprint of one received bootstrap batch section, derived from the wire size that section is already bounded by.

Counting entries is not a sufficient bound on its own, and neither is the wire size: a batch is bounded in bytes on the wire, but an entry that costs two bytes there costs BOOTSTRAP_BATCH_ENTRY_OVERHEAD bytes once it is a map node, so a batch of tiny entries amplifies far beyond the size it announced. This budget charges each entry the bytes it carries plus that overhead, which bounds the amplification directly instead of bounding the wire and hoping. It is calibrated so that any batch a conforming peer can build fits comfortably — including one from a MAIN.5.0 server, which bounds a batch by size only.