You can access attributes directly with the variable $attributes which contains an array with all the attributes of the block.
In your example you have overwritten this variable with $block['attrs'] which it doesn’t exists and also you don’t need to put global $block.