async def request_recent_beacon_blocks(self, peer_id: ID, block_roots: Sequence[HashTreeRoot]) -> Tuple[(BaseBeaconBlock, ...)]:
    if (peer_id not in self.handshaked_peers):
        error_msg = f'not handshaked with peer={peer_id} yet'
        self.logger.info('Request recent beacon block failed: %s', error_msg)
        raise RequestFailure(error_msg)
    recent_beacon_blocks_request = RecentBeaconBlocksRequest(block_roots=block_roots)
    self.logger.debug('Opening new stream to peer=%s with protocols=%s', peer_id, [REQ_RESP_RECENT_BEACON_BLOCKS_SSZ])
    stream = (await self.host.new_stream(peer_id, [REQ_RESP_RECENT_BEACON_BLOCKS_SSZ]))
    self.logger.debug('Sending recent beacon blocks request %s', recent_beacon_blocks_request)
    try:
        (await write_req(stream, recent_beacon_blocks_request))
        has_error = False
    except (WriteMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, WriteMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    finally:
        if has_error:
            error_msg = f'fail to write request={recent_beacon_blocks_request}'
            self.logger.info('Request recent beacon blocks failed: %s', error_msg)
            raise RequestFailure(error_msg)
    self.logger.debug('Waiting for recent beacon blocks response')
    try:
        (resp_code, recent_beacon_blocks_response) = (await read_resp(stream, RecentBeaconBlocksResponse))
        has_error = False
    except (ReadMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, ReadMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    finally:
        if has_error:
            self.logger.info('Request recent beacon blocks failed: fail to read the response')
            raise RequestFailure('fail to read the response')
    self.logger.debug('Received recent beacon blocks response %s, resp_code=%s', recent_beacon_blocks_response, resp_code)
    if (resp_code != ResponseCode.SUCCESS):
        error_msg = f'resp_code != ResponseCode.SUCCESS, resp_code={resp_code}, error_msg={recent_beacon_blocks_response}'
        self.logger.info('Request recent beacon blocks failed: %s', error_msg)
        (await stream.reset())
        raise RequestFailure(error_msg)
    (await stream.close())
    recent_beacon_blocks_response = cast(RecentBeaconBlocksResponse, recent_beacon_blocks_response)
    return recent_beacon_blocks_response.blocks
async def request_recent_beacon_blocks(self, peer_id: ID, block_roots: Sequence[HashTreeRoot]) -> Tuple[(BaseBeaconBlock, ...)]:
    if (peer_id not in self.handshaked_peers):
        error_msg = f'not handshaked with peer={peer_id} yet'
        self.logger.info('Request recent beacon block failed: %s', error_msg)
        raise RequestFailure(error_msg)
    recent_beacon_blocks_request = RecentBeaconBlocksRequest(block_roots=block_roots)
    self.logger.debug('Opening new stream to peer=%s with protocols=%s', peer_id, [REQ_RESP_RECENT_BEACON_BLOCKS_SSZ])
    stream = (await self.host.new_stream(peer_id, [REQ_RESP_RECENT_BEACON_BLOCKS_SSZ]))
    self.logger.debug('Sending recent beacon blocks request %s', recent_beacon_blocks_request)
    try:
        (await write_req(stream, recent_beacon_blocks_request))
        has_error = False
    except (WriteMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, WriteMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    finally:
        if has_error:
            error_msg = f'fail to write request={recent_beacon_blocks_request}'
            self.logger.info('Request recent beacon blocks failed: %s', error_msg)
            raise RequestFailure(error_msg)
    self.logger.debug('Waiting for recent beacon blocks response')
    try:
        (resp_code, recent_beacon_blocks_response) = (await read_resp(stream, RecentBeaconBlocksResponse))
        has_error = False
    except (ReadMessageFailure, MplexStreamEOF, MplexStreamReset) as error:
        has_error = True
        if isinstance(error, ReadMessageFailure):
            (await stream.reset())
        elif isinstance(error, MplexStreamEOF):
            (await stream.close())
    finally:
        if has_error:
            self.logger.info('Request recent beacon blocks failed: fail to read the response')
            raise RequestFailure('fail to read the response')
    self.logger.debug('Received recent beacon blocks response %s, resp_code=%s', recent_beacon_blocks_response, resp_code)
    if (resp_code != ResponseCode.SUCCESS):
        error_msg = f'resp_code != ResponseCode.SUCCESS, resp_code={resp_code}, error_msg={recent_beacon_blocks_response}'
        self.logger.info('Request recent beacon blocks failed: %s', error_msg)
        (await stream.reset())
        raise RequestFailure(error_msg)
    (await stream.close())
    recent_beacon_blocks_response = cast(RecentBeaconBlocksResponse, recent_beacon_blocks_response)
    return recent_beacon_blocks_response.blocks