fn execute_tx_in_vm_with_optional_compression(
        &self,
        tx: &Transaction,
        vm: &mut BatchVm<S, Tr>,
    ) -> anyhow::Result<BatchTransactionExecutionResult> {
        // Note, that the space where we can put the calldata for compressing transactions
        // is limited and the transactions do not pay for taking it.
        // In order to not let the accounts spam the space of compressed bytecodes with bytecodes
        // that will not be published (e.g. due to out of gas), we use the following scheme:
        // We try to execute the transaction with compressed bytecodes.
        // If it fails and the compressed bytecodes have not been published,
        // it means that there is no sense in polluting the space of compressed bytecodes,
        // and so we re-execute the transaction, but without compression.

        let res = vm.inspect_transaction(tx.clone(), true);
        if res.compression_result.is_ok() {
            return Ok(BatchTransactionExecutionResult {
                tx_result: res.tx_result,
                compression_result: Ok(()),
                call_traces: res.call_traces,
            });
        }

        // Roll back to the snapshot just before the transaction execution taken in `Self::execute_tx()`
        // and create a snapshot at the same VM state again.
        vm.rollback_to_the_latest_snapshot();
        vm.make_snapshot();

        let res = vm.inspect_transaction(tx.clone(), false);
        res.compression_result
            .context("compression failed when it wasn't applied")?;
        Ok(BatchTransactionExecutionResult {
            tx_result: res.tx_result,
            compression_result: Ok(()),
            call_traces: res.call_traces,
        })
    }
Attempts to execute transaction with or without bytecode compression.
If compression fails, the transaction will be re-executed without compression.
core/lib/vm_executor/src/batch/factory.rs