It can be useful in some situations to check if one specific Gutenberg block has been used on current page, for example to check if author has set hero block with image to set transparent navigation over that image. Luckily there is a simple function which checks exactly that:

has_block('group/block-name')

In our situation we would use this function to set body class if hero block exists.

...
</head>

<?php 
$classes = [];
if (is_singular()) {
    if (has_block('acf/hero')) {
        $classes[] = 'hero-block';
    }
}
?>

<body <?php body_class($classes); ?>>
...