def extract_chain_id(raw_v):
above_id_offset = raw_v - CHAIN_ID_OFFSET<EOL>if above_id_offset < <NUM_LIT:0>:<EOL><INDENT>if raw_v in {<NUM_LIT:0>, <NUM_LIT:1>}:<EOL><INDENT>return (None, raw_v + V_OFFSET)<EOL><DEDENT>elif raw_v in {<NUM_LIT>, <NUM_LIT>}:<EOL><INDENT>return (None, raw_v)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>(chain_id, v_bit) = divmod(above_id_offset, <NUM_LIT:2>)<EOL>return (chain_id, v_bit + V_OFFSET)<EOL><DEDENT>
Extracts chain ID, according to EIP-155
@return (chain_id, v)