pub(crate) fn derive_overhead(
    gas_limit: u64,
    gas_price_per_pubdata: u32,
    encoded_len: usize,
    coefficients: OverheadCoefficients,
) -> u32 {
    // Even if the gas limit is greater than the `MAX_TX_ERGS_LIMIT`, we assume that everything beyond `MAX_TX_ERGS_LIMIT`
    // will be spent entirely on publishing bytecodes and so we derive the overhead solely based on the capped value
    let gas_limit = std::cmp::min(MAX_TX_ERGS_LIMIT as u64, gas_limit);

    // Using large U256 type to avoid overflow
    let max_block_overhead = U256::from(block_overhead_gas(gas_price_per_pubdata));
    let gas_limit = U256::from(gas_limit);
    let encoded_len = U256::from(encoded_len);

    // The `MAX_TX_ERGS_LIMIT` is formed in a way that may fulfills a single-instance circuits
    // if used in full. That is, within `MAX_TX_ERGS_LIMIT` it is possible to fully saturate all the single-instance
    // circuits.
    let overhead_for_single_instance_circuits =
        ceil_div_u256(gas_limit * max_block_overhead, MAX_TX_ERGS_LIMIT.into());

    // The overhead for occupying the bootloader memory
    let overhead_for_length = ceil_div_u256(
        encoded_len * max_block_overhead,
        BOOTLOADER_TX_ENCODING_SPACE.into(),
    );

    // The overhead for occupying a single tx slot
    let tx_slot_overhead = ceil_div_u256(max_block_overhead, MAX_TXS_IN_BLOCK.into());

    // We use `ceil` here for formal reasons to allow easier approach for calculating the overhead in O(1)
    // `let max_pubdata_in_tx = ceil_div_u256(gas_limit, gas_price_per_pubdata);`

    // The maximal potential overhead from pubdata
    // TODO (EVM-67): possibly use overhead for pubdata
    // ```
    // let pubdata_overhead = ceil_div_u256(
    //     max_pubdata_in_tx * max_block_overhead,
    //     MAX_PUBDATA_PER_BLOCK.into(),
    // );
    // ```

    vec![
        (coefficients.ergs_limit_overhead_coeficient
            * overhead_for_single_instance_circuits.as_u32() as f64)
            .floor() as u32,
        (coefficients.bootloader_memory_overhead_coeficient * overhead_for_length.as_u32() as f64)
            .floor() as u32,
        (coefficients.slot_overhead_coeficient * tx_slot_overhead.as_u32() as f64) as u32,
    ]
    .into_iter()
    .max()
    .unwrap()
}
Derives the overhead for processing transactions in a block.
core/lib/multivm/src/versions/vm_virtual_blocks/utils/overhead.rs