golemfactory / concent

Repository for Concent Service sources
8 stars 7 forks source link

Concent rejects a valid signature in the report use case #455

Closed cameel closed 6 years ago

cameel commented 6 years ago

@shadeofblue reports that on staging the gets the following response to his ForceReportComputedTask:

Concent request failed with status 400 and response: '{"error": "There was an exception when validating if golem_message 2002 is signed with public key b\'|\\\\xcc\\\\xfa\\\\x1d<\\\\xa1\\\\x9b{\\\\xc4\\\\xedp\\\\xcb\\\\xfb\\\\x0b\\\\x89$~\\\\x05\\\\xae\\\\x06c3\\\\xe6\\\\x9az\\\\xf3\\\\x95\\\\xe3\\\\x83\\\\xbc\\\\x16\\\\xe1,m0\\\\x1ah5\\\\xae\\\\x14,\\\\x17Op\\\\x82\\\\x9a\\\\xd9\\\\xd4\\\\xaex3hc;\\\\xe0@\\\\xee\\\\xad\\\\xe5\\\\x92\\\\xca\\\\xee\\\\xd3\\\\x8c\'", "error_code": "message.signature.wrong"}'

This happens when running the new full-node tests (https://github.com/golemfactory/golem/tree/concent-fullnode-tests).

It's not clear whether the problem is in Concent, Golem or in tests but the signature can be successfully verified on Golem side with rct.task_to_compute.verify_signature(decode_hex(rct.task_to_compute.requestor_public_key)) so it seems very likely that it's a bug in Concent.

Jakub89 commented 6 years ago

Message that cause error:

TaskToCompute(
    header=MessageHeader(type_=2002, timestamp=1528447534, encrypted=False), 
    sig=b'\xcaw\x9d\xdf@Q\xf5_\x8a\x9bW\xef\r\xd1\x963OQ@\x95\x0b\x0c\x8c\xa2\xdf\\\x02)f\xf3\xb7\xcedHH\x7f!`\xe6\xf0{\xfa\xa7jk\x943\xf6i\xee\xb1\xc9\x92w\x82\xb5\x90\xc1Y\xf2M\x14n\x04\x00', 
    slots=[
        ['requestor_id', 'bba629964edce3c6beac2f2235c3703f1b0fa0440b08c0edcd6372eb822bcc99cf59f42b8838a4201ad758b6dd51383427cc2cba5614237873d1a265c58b594d'], 
        ['requestor_public_key', 'bba629964edce3c6beac2f2235c3703f1b0fa0440b08c0edcd6372eb822bcc99cf59f42b8838a4201ad758b6dd51383427cc2cba5614237873d1a265c58b594d'], 
        ['requestor_ethereum_public_key', 'bba629964edce3c6beac2f2235c3703f1b0fa0440b08c0edcd6372eb822bcc99cf59f42b8838a4201ad758b6dd51383427cc2cba5614237873d1a265c58b594d'], 
        ['provider_id', '0d8e8acd1abf4f96a8ed185a57cd19541c5cf34ca7ed88d26ae592e3d96f7a5a2dbd2a66406af5472e965dde18298802fc92542c1fff86cfc7b40e0cc0aa91c3'], 
        ['provider_public_key', '0d8e8acd1abf4f96a8ed185a57cd19541c5cf34ca7ed88d26ae592e3d96f7a5a2dbd2a66406af5472e965dde18298802fc92542c1fff86cfc7b40e0cc0aa91c3'], 
        ['provider_ethereum_public_key', '0d8e8acd1abf4f96a8ed185a57cd19541c5cf34ca7ed88d26ae592e3d96f7a5a2dbd2a66406af5472e965dde18298802fc92542c1fff86cfc7b40e0cc0aa91c3'], 
        ['compute_task_def', {
            'deadline': 1528448106.143041, 
            'docker_images': [{'image_id': None, 'repository': 'golemfactory/blender', 'tag': '1.4'}], 
            'extra_data': {
                'end_task': 1, 
                'frames': [1], 
                'outfilebasename': 'test task', 
                'output_format': 'PNG', 
                'path_root': '/home/jakub/Documents/work/projects/golem/scripts/concent_node_tests/tasks/test_task_1', 
                'scene_file': '/golem/resources/wlochaty3.blend', 
                'script_src': '# This template is rendered by\n# apps.blender.resources.scenefileeditor.generate_blender_crop_file(),\n# written to tempfile and passed as arg to blender.\nimport bpy\n\nclass EngineWarning(bpy.types.Operator):\n    bl_idname = "wm.engine_warning"\n    bl_label = "Inform about not supported rendering engine"\n\n    def execute(self, context):\n        self.report({"ERROR"}, "Engine " + bpy.context.scene.render.engine + \\\n                               " not supported by Golem")\n        return {"FINISHED"}\n\nclass ShowInformation(bpy.types.Operator):\n    bl_idname = "wm.scene_information"\n    bl_label = "Inform user about scene settings"\n\n\n    def execute(self, context):\n        self.report({"INFO"}, "Engine: " +\n                              str(bpy.context.scene.render.engine))\n        if bpy.context.scene.render.engine == "CYCLES":\n            self.report({"INFO"}, "Samples: " + str(bpy.context.scene.cycles.samples))\n        self.report({"INFO"}, "Resolution: " +\n                              str(bpy.context.scene.render.resolution_x) +\n                               " x " +\n                               str(bpy.context.scene.render.resolution_y))\n        self.report({"INFO"}, "File format: " +\n                               str(bpy.context.scene.render.file_extension))\n        self.report({"INFO"}, "Filepath: " +\n                              str(bpy.context.scene.render.filepath))\n        self.report({"INFO"}, "Frames: " +\n                              str(bpy.context.scene.frame_start) + "-" +\n                              str(bpy.context.scene.frame_end) + ";" +\n                              str(bpy.context.scene.frame_step))\n\n        return {"FINISHED"}\n\n\nbpy.utils.register_class(EngineWarning)\nengine = bpy.context.scene.render.engine\nif engine not in ("BLENDER_RENDER", "CYCLES"):\n    bpy.ops.wm.engine_warning()\n\nbpy.utils.register_class(ShowInformation)\nbpy.ops.wm.scene_information()\n\nbpy.context.scene.render.tile_x = 0\nbpy.context.scene.render.tile_y = 0\nbpy.context.scene.render.resolution_x = 320\nbpy.context.scene.render.resolution_y = 240\nbpy.context.scene.render.resolution_percentage = 100\nbpy.context.scene.render.use_border = True\nbpy.context.scene.render.use_crop_to_border = True\nbpy.context.scene.render.border_max_x = 1.0\nbpy.context.scene.render.border_min_x = 0.0\nbpy.context.scene.render.border_min_y = 0.0\nbpy.context.scene.render.border_max_y = 1.0\nbpy.context.scene.render.use_compositing = bool(False)\nif engine == "CYCLES":\n    samples = 0\n    if samples != 0:\n        bpy.context.scene.cycles.samples = samples\n\n#and check if additional files aren\'t missing\nbpy.ops.file.report_missing_files()\n', 'start_task': 1, 'total_tasks': 1}, 'performance': 131.36946112698013, 'short_description': 'path_root: /home/jakub/Documents/work/projects/golem/scripts/concent_node_tests/tasks/test_task_1, start_task: 1, end_task: 1, total_tasks: 1, outfilebasename: test task, scene_file: /golem/resources/wlochaty3.blend', 'src_code': 'from __future__ import print_function\n\nimport os\nimport subprocess\nimport sys\nfrom multiprocessing import cpu_count\n\nimport params  # This module is generated before this script is run\n\nBLENDER_COMMAND = "blender"\nWORK_DIR = "/golem/work"\nOUTPUT_DIR = "/golem/output"\n\n\ndef exec_cmd(cmd):\n    pc = subprocess.Popen(cmd)\n    return pc.wait()\n\n\ndef format_blender_render_cmd(outfilebasename, scene_file, script_file,\n                              start_task, frame, output_format):\n    cmd = [\n        "{}".format(BLENDER_COMMAND),\n        "-b", "{}".format(scene_file),\n        "-y",  # enable scripting by default\n        "-P", "{}".format(script_file),\n        "-o", "{}/{}_{}".format(OUTPUT_DIR, outfilebasename, start_task),\n        "-noaudio",\n        "-F", "{}".format(output_format.upper()),\n        "-t", "{}".format(cpu_count()),\n        "-f", "{}".format(frame)\n    ]\n    return cmd\n\n\ndef run_blender_task(outfilebasename, scene_file, script_src, start_task,\n                     frames, output_format):\n    scene_file = os.path.normpath(scene_file)\n    if not os.path.exists(scene_file):\n        print("Scene file \'{}\' does not exist".format(scene_file),\n              file=sys.stderr)\n        sys.exit(1)\n\n    blender_script_path = WORK_DIR + "/blenderscript.py"\n    with open(blender_script_path, "w") as script_file:\n        script_file.write(script_src)\n\n    for frame in frames:\n        cmd = format_blender_render_cmd(outfilebasename, scene_file,\n                                        script_file.name, start_task, frame, output_format)\n        print(cmd, file=sys.stderr)\n        exit_code = exec_cmd(cmd)\n        if exit_code is not 0:\n            sys.exit(exit_code)\n\n\nrun_blender_task(params.outfilebasename, params.scene_file, params.script_src, params.start_task, params.frames,\n                 params.output_format)\n\n', 
                'subtask_id': '4ef36448-6af8-11e8-8ab2-bba629964edc', 
                'task_id': '3e1e319e-6af8-11e8-b02c-bba629964edc', 
                'working_directory': '.'
            }
        ], 
        ['package_hash', 'sha1:ff5dd6163168b1832ac3bf5f0171ad527f092969'], 
        ['size', 0], 
        ['concent_enabled', True], 
        ['price', 163888888888888889]
    ]
)

Provider key 0d8e8acd1abf4f96a8ed185a57cd19541c5cf34ca7ed88d26ae592e3d96f7a5a2dbd2a66406af5472e965dde18298802fc92542c1fff86cfc7b40e0cc0aa91c3 Requestor key bba629964edce3c6beac2f2235c3703f1b0fa0440b08c0edcd6372eb822bcc99cf59f42b8838a4201ad758b6dd51383427cc2cba5614237873d1a265c58b594d

requestor_public_key = hex_to_bytes_convert(bba629964edce3c6beac2f2235c3703f1b0fa0440b08c0edcd6372eb822bcc99cf59f42b8838a4201ad758b6dd51383427cc2cba5614237873d1a265c58b594d) =

b'\xbb\xa6)\x96N\xdc\xe3\xc6\xbe\xac/"5\xc3p?\x1b\x0f\xa0D\x0b\x08\xc0\xed\xcdcr\xeb\x82+\xcc\x99\xcfY\xf4+\x888\xa4 \x1a\xd7X\xb6\xddQ84\'\xcc,\xbaV\x14#xs\xd1\xa2e\xc5\x8bYM'