The by far easiest way to do this is to rely on the plugin/block context system.
See my answer for How do I make a block that pulls the current node content?
You just have to put a node context definition in your block annotation like this:
* contextcontext_definitions = { * "node" = @ContextDefinition("entity:node", label = @Translation("Node")) * } And then use it like this: $this->getContextValue('node')
The nice thing about this is that Drupal will then take care of caching for you. Automatically. Because it knows that the default (and as far as core goes only) node context is the current node. And that knows where it is coming from, so the cache context and cache tags are added automatically.
Through \Drupal\Core\Plugin\ContextAwarePluginBase::getCacheContexts() and the corresponding getCacheTags() methods, BlockBase/your block class extends from that and inherits those methods.