code: def block_specification_to_number(block: BlockSpecification, web3: Web3) -> BlockNumber:
      
      if isinstance(block, str):
          msg = f"string block specification can't contain {block}"
          assert block in ('latest', 'pending'), msg
          number = web3.eth.getBlock(block)['number']
      elif isinstance(block, T_BlockHash):
          number = web3.eth.getBlock(block)['number']
      elif isinstance(block, T_BlockNumber):
          number = block
      else:
          if __debug__:
              raise AssertionError(f'Unknown type {type(block)} given for block specification')
  
      return BlockNumber(number)
docs: Converts a block specification to an actual block number