Repository: MystenLabs/sui
File: crates/sui-core/src/consensus_types/consensus_output_api.rs (Rust)

Code before:
            .collect()
    }

    fn rejected_transactions_digest(&self) -> Digest {
        let bytes = bcs::to_bytes(&self.rejected_transactions_by_block).unwrap();
        let mut hasher = sui_types::crypto::DefaultHash::new();
        hasher.update(bytes);
        hasher.finalize().digest.into()
    }

    fn rejected_transactions_debug_string(&self) -> String {
        let str = self
            .rejected_transactions_by_block
            .iter()
            .map(|(block_ref, rejected_transactions)| {
                format!(
                    "{block_ref}: [{}]",
                    rejected_transactions
                        .iter()
                        .map(|tx| tx.to_string())
                        .join(",")
                )
            })
            .join(", ");
        let digest = self.rejected_transactions_digest();
        format!("{str}; digest: {digest}")
    }
}

pub(crate) fn parse_block_transactions(
    block: &VerifiedBlock,
    rejected_transactions: &[TransactionIndex],
) -> Vec<ParsedTransaction> {
    let round = block.round();
    let authority = block.author().value() as AuthorityIndex;

    let mut rejected_idx = 0;
    block
        .transactions()
        .iter().enumerate()
        .map(|(index, tx)| {
            let transaction = match bcs::from_bytes::<ConsensusTransaction>(tx.data()) {
                Ok(transaction) => transaction,
                Err(err) => {
                    panic!("Failed to deserialize sequenced consensus transaction(this should not happen) {err} from {authority} at {round}");
                },
            };
            let rejected = if rejected_idx < rejected_transactions.len() {
                match (index as TransactionIndex).cmp(&rejected_transactions[rejected_idx]) {
                    Ordering::Less => {
                        false

Review comment (bug):
what is the purpose of the rejected transactions digest? Is it just to provide an identifier for the set of rejected transactions in a committed subdag? If so should the identifier be first in the debug statement?

Code after:
            .collect()
    }

    fn rejected_transactions_digest(&self) -> Digest {
        let bytes = bcs::to_bytes(&self.rejected_transactions_by_block).unwrap();
        let mut hasher = sui_types::crypto::DefaultHash::new();
        hasher.update(bytes);
        hasher.finalize().digest.into()
    }

    fn rejected_transactions_debug_string(&self) -> String {
        let str = self
            .rejected_transactions_by_block
            .iter()
            .map(|(block_ref, rejected_transactions)| {
                format!(
                    "{block_ref}: [{}]",
                    rejected_transactions
                        .iter()
                        .map(|tx| tx.to_string())
                        .join(",")
                )
            })
            .join(", ");
        let digest = self.rejected_transactions_digest();
        format!("digest: {digest}; {str}")
    }
}

pub(crate) fn parse_block_transactions(
    block: &VerifiedBlock,
    rejected_transactions: &[TransactionIndex],
) -> Vec<ParsedTransaction> {
    let round = block.round();
    let authority = block.author().value() as AuthorityIndex;

    let mut rejected_idx = 0;
    block
        .transactions()
        .iter().enumerate()
        .map(|(index, tx)| {
            let transaction = match bcs::from_bytes::<ConsensusTransaction>(tx.data()) {
                Ok(transaction) => transaction,
                Err(err) => {
                    panic!("Failed to deserialize sequenced consensus transaction(this should not happen) {err} from {authority} at {round}");
                },
            };
            let rejected = if rejected_idx < rejected_transactions.len() {
                match (index as TransactionIndex).cmp(&rejected_transactions[rejected_idx]) {
                    Ordering::Less => {
                        false