def METHOD_NAME(self, key: KT, tx: Optional[BaseTransaction] = None) -> bytes:
    import struct
    rocksdb_key = self._serialize_key(key)
    assert len(rocksdb_key) == self._KEY_SIZE
    if tx:
        assert tx.hash is not None
        assert len(tx.hash) == 32
        rocksdb_key += struct.pack('>I', tx.timestamp) + tx.hash
        assert len(rocksdb_key) == self._KEY_SIZE + 4 + 32
    return rocksdb_key