fn detect_cbor_metadata(
        bytecode_marker: BytecodeMarker,
        bytecode: &[u8],
    ) -> Option<(usize, H256, CborMetadata)> {
        let length = bytecode.len();

        // Last two bytes is the length of the metadata in big endian.
        if length < 2 {
            return None;
        }
        let metadata_length =
            u16::from_be_bytes([bytecode[length - 2], bytecode[length - 1]]) as usize;
        // Including size
        let full_metadata_length = metadata_length + 2;

        // Get slice for the metadata.
        if length < full_metadata_length {
            return None;
        }
        let raw_metadata = &bytecode[length - full_metadata_length..length - 2];
        // Try decoding. We are not interested in the actual value.
        let metadata: CborMetadata = match ciborium::from_reader(raw_metadata) {
            Ok(metadata) => metadata,
            Err(_) => return None,
        };

        // Strip metadata and calculate hash.
        let bytecode_without_metadata = match bytecode_marker {
            BytecodeMarker::Evm => {
                // On EVM, there is no padding.
                &bytecode[..length - full_metadata_length]
            }
            BytecodeMarker::EraVm => {
                // On EraVM, there is padding:
                // 1. We must align the metadata length to 32 bytes.
                // 2. We may need to add 32 bytes of padding.
                let aligned_metadata_length = metadata_length.div_ceil(32) * 32;
                Self::strip_padding(bytecode, aligned_metadata_length)?
            }
        };
        let hash = H256(keccak256(bytecode_without_metadata));
        Some((full_metadata_length, hash, metadata))
    }
Will try to detect CBOR metadata.
core/lib/types/src/contract_verification/contract_identifier.rs