pub async fn get_traces_for_l2_block(
        &mut self,
        block_number: L2BlockNumber,
    ) -> DalResult<Vec<(Call, CallTraceMeta)>> {
        let row = sqlx::query!(
            r#"
            SELECT
                protocol_version,
                hash
            FROM
                miniblocks
            WHERE
                number = $1
            "#,
            i64::from(block_number.0)
        )
        .try_map(|row| {
            row.protocol_version
                .map(parse_protocol_version)
                .transpose()
                .map(|val| (val, H256::from_slice(&row.hash)))
        })
        .instrument("get_traces_for_l2_block#get_l2_block_protocol_version_id")
        .with_arg("l2_block_number", &block_number)
        .fetch_optional(self.storage)
        .await?;
        let Some((protocol_version, block_hash)) = row else {
            return Ok(Vec::new());
        };

        let protocol_version =
            protocol_version.unwrap_or_else(ProtocolVersionId::last_potentially_undefined);

        Ok(sqlx::query_as!(
            CallTrace,
            r#"
            SELECT
                transactions.hash AS tx_hash,
                transactions.index_in_block AS tx_index_in_block,
                call_trace,
                transactions.error AS tx_error
            FROM
                call_traces
            INNER JOIN transactions ON tx_hash = transactions.hash
            WHERE
                transactions.miniblock_number = $1
            ORDER BY
                transactions.index_in_block
            "#,
            i64::from(block_number.0)
        )
        .instrument("get_traces_for_l2_block")
        .with_arg("block_number", &block_number)
        .fetch_all(self.storage)
        .await?
        .into_iter()
        .map(|mut call_trace| {
            let tx_hash = H256::from_slice(&call_trace.tx_hash);
            let index = call_trace.tx_index_in_block.unwrap_or_default() as usize;
            let meta = CallTraceMeta {
                index_in_block: index,
                tx_hash,
                block_number: block_number.0,
                block_hash,
                internal_error: call_trace.tx_error.take(),
            };
            (call_trace.into_call(protocol_version), meta)
        })
        .collect())
    }
Returns call traces for all transactions in the specified L2 block in the order of their execution.
core/lib/dal/src/blocks_web3_dal.rs