code: def extract_chain_id(raw_v):
      '''
      Extracts chain ID, according to EIP-155
      @return (chain_id, v)
      '''
      above_id_offset = raw_v - CHAIN_ID_OFFSET
      if above_id_offset < 0:
          if raw_v in {0, 1}:
              return (None, raw_v + V_OFFSET)
          elif raw_v in {27, 28}:
              return (None, raw_v)
          else:
              raise ValueError("v %r is invalid, must be one of: 0, 1, 27, 28, 35+")
      else:
          (chain_id, v_bit) = divmod(above_id_offset, 2)
          return (chain_id, v_bit + V_OFFSETf extract_chain_id(raw_v):
      '''
      Extracts chain ID, according to EIP-155
      @return (chain_id, v)
      '''
      above_id_offset = raw_v - CHAIN_ID_OFFSET
      if above_id_offset < 0:
          if raw_v in {0, 1}:
              return (None, raw_v + V_OFFSET)
          elif raw_v in {27, 28}:
              return (None, raw_v)
          else:
              raise ValueError("v %r is invalid, must be one of: 0, 1, 27, 28, 35+")
      else:
          (chain_id, v_bit) = divmod(above_id_offset, 2)
          return (chain_id, v_bit + V_OFFSET)
docs: Extracts chain ID, according to EIP-155
      @return (chain_id, v)