【问题标题】:How CBOR Parse Task in Standard mode works?标准模式下的 CBOR Parse Task 是如何工作的?
【发布时间】:2022-10-24 12:43:03
【问题描述】:

我想知道mode="standard" 中的cborparse 是如何工作的,因为我无法让它工作。

资源

Chainlink CBOR Parse Task - docs

Chainlink CBOR Prase Task - implementation

Chainlink CBOR Parse Task - implementation tests

Online CBOR encoder Online uft8 to bytes converter

环境

Chainlink 节点 v1.7.0

案例 OK:cborparse in mode="diet"(默认)

测试用例

输入

{"path":["recent","usd"],"url":"https://etherprice.com/api"}

输入 CBOR 编码

A264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069

Webhook TOML 规范

type = "webhook"
schemaVersion = 1
name = "Test decode CBOR diet"
observationSource = """
    merge               [type="merge" left=<{"input": "0x"}> right=<{"input": "0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"}>]
    decode_cbor         [type="cborparse" data="$(merge.input)"]
"""

JSON 作业运行

{
  "__typename": "JobRun",
  "id": "240",
  "allErrors": [
  ],
  "createdAt": "2022-10-14T12:06:56.646544Z",
  "fatalErrors": [
  ],
  "finishedAt": "2022-10-14T12:06:56.64718Z",
  "job": {
    "__typename": "Job",
    "id": "225",
    "name": "Test decode CBOR diet",
    "observationSource": " merge [type="merge" left=<{"input": "0x"}> right=<{"input": "0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"}>] decode_cbor [type="cborparse" data="$(merge.input)"] "
  },
  "status": "COMPLETED",
  "inputs": {
    "decode_cbor": {
      "path": [
        "recent",
        "usd"
      ],
      "url": "https://etherprice.com/api"
    },
    "jobRun": {
      "meta": null
    },
    "merge": {
      "input": "0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"
    }
  },
  "outputs": [
    "{"path":["recent","usd"],"url":"https://etherprice.com/api"}"
  ],
  "taskRuns": [
  ]
}

案例 KO:模式 =“标准”中的 cborparse

测试用例

输入

{"path":["recent","usd"],"url":"https://etherprice.com/api"}

输入 CBOR 编码

A264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069

输入 CBOR 编码为字节数组

[41, 32, 36, 34, 37, 30, 36, 31, 37, 34, 36, 38, 38, 32, 36, 36, 37, 32, 36, 35, 36, 33, 36, 35, 36, 45, 37, 34, 36, 33, 37, 35, 37, 33, 36, 34, 36, 33, 37, 35, 37, 32, 36, 43, 37, 38, 31, 41, 36, 38, 37, 34, 37, 34, 37, 30, 37, 33, 33, 41, 32, 46, 32, 46, 36, 35, 37, 34, 36, 38, 36, 35, 37, 32, 37, 30, 37, 32, 36, 39, 36, 33, 36, 35, 32, 45, 36, 33, 36, 46, 36, 44, 32, 46, 36, 31, 37, 30, 36, 39]

尝试了以下几个 TOML 规范,但没有一个有效。他们总是以data: parameter is empty 失败(JSON 作业运行的常见部分在下面共享):

{
  "__typename": "JobRun",
  "id": "246",
  "allErrors": [
    "data: parameter is empty"
  ],
  "createdAt": "2022-10-14T12:31:42.234027Z",
  "fatalErrors": [
    "data: parameter is empty"
  ],
  "finishedAt": "2022-10-14T12:31:42.236091Z",
  "job": {
    "__typename": "Job",
    "id": "232",
    "name": "Test decode CBOR standard",
    "observationSource": " decode_cbor [type="cborparse" mode="standard" data=<it_does_not_matter>] "
  },
  "status": "ERRORED",
  "inputs": {
    "decode_cbor": {
    },
    "jobRun": {
      "meta": null
    }
  },
  "outputs": [
    null
  ],
  "taskRuns": [
    {
      "__typename": "TaskRun",
      "id": "9c374ffb-cf80-41c9-a3b7-08391abd48fa",
      "createdAt": "2022-10-14T12:31:42.234993Z",
      "dotID": "decode_cbor",
      "error": "data: parameter is empty",
      "finishedAt": "2022-10-14T12:31:42.236021Z",
      "output": "null",
      "type": "cborparse"
    }
  ]
}

测试 1:webhook TOML 规范

注意:数据为&lt;{ ... }&gt;。我也试过用转义引号(旧语法)

type = "webhook"
schemaVersion = 1
name = "Test decode CBOR standard 1"
observationSource = """
    decode_cbor         [type="cborparse" mode="standard" data=<{41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 34, 36, 33, 36, 31, 36, 43, 36, 43, 36, 36, 36, 39, 36, 45, 37, 30, 37, 35, 37, 34, 37, 33, 38, 32, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 39, 37, 32, 36, 35, 37, 31, 37, 35, 36, 35, 37, 33, 37, 34, 34, 39, 36, 34, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 37, 36, 32, 37, 39, 37, 34, 36, 35, 37, 33, 33, 33, 33, 32, 41, 34, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 37, 37, 32, 36, 35, 37, 33, 37, 35, 36, 43, 37, 34, 37, 33, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 37, 36, 32, 37, 39, 37, 34, 36, 35, 37, 33, 35, 42, 35, 44, 36, 36, 36, 35, 36, 45, 36, 33, 36, 46, 36, 34, 36, 35, 41, 32, 36, 36, 36, 44, 36, 35, 37, 34, 36, 38, 36, 46, 36, 34, 36, 36, 37, 30, 36, 31, 36, 33, 36, 42, 36, 35, 36, 34, 36, 34, 36, 34, 36, 31, 37, 34, 36, 31, 36, 41, 37, 32, 36, 35, 37, 33, 37, 35, 36, 43, 37, 34, 37, 33, 35, 32, 36, 31, 37, 37, 36, 41, 36, 33, 36, 46, 36, 44, 37, 30, 36, 46, 36, 45, 36, 35, 36, 45, 37, 34, 37, 33, 38, 35, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 36, 36, 37, 36, 31, 36, 44, 36, 35, 34, 39, 36, 34, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 35, 36, 39, 36, 45, 37, 34, 33, 33, 33, 32, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 39, 37, 33, 37, 34, 36, 31, 37, 32, 37, 34, 35, 34, 36, 39, 36, 44, 36, 35, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 35, 36, 39, 36, 45, 37, 34, 33, 34, 33, 30, 41, 34, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 45, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 34, 43, 36, 35, 36, 45, 36, 37, 37, 34, 36, 38, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 35, 37, 35, 36, 39, 36, 45, 37, 34, 33, 38, 36, 36, 36, 44, 36, 35, 37, 34, 36, 38, 36, 46, 36, 34, 36, 36, 36, 43, 36, 35, 36, 45, 36, 37, 37, 34, 36, 38, 36, 34, 36, 34, 36, 31, 37, 34, 36, 31, 36, 38, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 38, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 33, 37, 34, 37, 32, 36, 39, 36}>]
"""

测试 2:webhook TOML 规范

注意:数据为&lt;{[ ... ]}&gt;。我也试过用转义引号(旧语法)

type = "webhook"
schemaVersion = 1
name = "Test decode CBOR standard 2"
observationSource = """
    decode_cbor         [type="cborparse" mode="standard" data=<{[41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 34, 36, 33, 36, 31, 36, 43, 36, 43, 36, 36, 36, 39, 36, 45, 37, 30, 37, 35, 37, 34, 37, 33, 38, 32, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 39, 37, 32, 36, 35, 37, 31, 37, 35, 36, 35, 37, 33, 37, 34, 34, 39, 36, 34, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 37, 36, 32, 37, 39, 37, 34, 36, 35, 37, 33, 33, 33, 33, 32, 41, 34, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 37, 37, 32, 36, 35, 37, 33, 37, 35, 36, 43, 37, 34, 37, 33, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 37, 36, 32, 37, 39, 37, 34, 36, 35, 37, 33, 35, 42, 35, 44, 36, 36, 36, 35, 36, 45, 36, 33, 36, 46, 36, 34, 36, 35, 41, 32, 36, 36, 36, 44, 36, 35, 37, 34, 36, 38, 36, 46, 36, 34, 36, 36, 37, 30, 36, 31, 36, 33, 36, 42, 36, 35, 36, 34, 36, 34, 36, 34, 36, 31, 37, 34, 36, 31, 36, 41, 37, 32, 36, 35, 37, 33, 37, 35, 36, 43, 37, 34, 37, 33, 35, 32, 36, 31, 37, 37, 36, 41, 36, 33, 36, 46, 36, 44, 37, 30, 36, 46, 36, 45, 36, 35, 36, 45, 37, 34, 37, 33, 38, 35, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 36, 36, 37, 36, 31, 36, 44, 36, 35, 34, 39, 36, 34, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 35, 36, 39, 36, 45, 37, 34, 33, 33, 33, 32, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 39, 37, 33, 37, 34, 36, 31, 37, 32, 37, 34, 35, 34, 36, 39, 36, 44, 36, 35, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 35, 36, 39, 36, 45, 37, 34, 33, 34, 33, 30, 41, 34, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 45, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 34, 43, 36, 35, 36, 45, 36, 37, 37, 34, 36, 38, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 35, 37, 35, 36, 39, 36, 45, 37, 34, 33, 38, 36, 36, 36, 44, 36, 35, 37, 34, 36, 38, 36, 46, 36, 34, 36, 36, 36, 43, 36, 35, 36, 45, 36, 37, 37, 34, 36, 38, 36, 34, 36, 34, 36, 31, 37, 34, 36, 31, 36, 38, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 41, 32, 36, 34, 36, 45, 36, 31, 36, 44, 36, 35, 36, 38, 36, 38, 36, 46, 36, 44, 36, 35, 35, 34, 36, 35, 36, 31, 36, 44, 36, 34, 37, 34, 37, 39, 37, 30, 36, 35, 36, 36, 37, 33, 37, 34, 37, 32, 36, 39, 36]}>]
""

测试 3:webhook TOML 规范

注意:数据为 hexStr,以防万一。我也尝试了多种语法组合,添加和删除[ ]0x""

type = "webhook"
schemaVersion = 1
name = "Test decode CBOR standard 3"
observationSource = """
    decode_cbor         [type="cborparse" mode="standard" data=<{["0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"]}>]
"""

概括

我是否弄错了如何使用此任务及其目的? 可能是standard 模式just return straight data?,但为什么我总是得到data parameters is empty

让我更好地理解正在发生的事情的另一种方法是在task.cborparse_test.go 中实施单元测试,但可能有人有答案!

谢谢!

【问题讨论】:

    标签: chainlink cbor


    【解决方案1】:

    使用mode=standard时,实际上可以跳过字符&lt;{[

    所以可以将TOML中data的值指定为十六进制字符串

    decode_cbor [type="cborparse" mode="standard" data="0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"]

    或者

    从像$(foo) 这样的变量中引用它。

    试一试,让我知道你是否遇到了麻烦。

    另外,不确定您是否需要合并任务:

    merge [ type="merge" left=&lt;{"input": "0x"}&gt; right=&lt;{"input": "0xA264706174688266726563656E74637573646375726C781A68747470733A2F2F657468657270726963652E636F6D2F617069"}&gt;]

    希望这可以帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 1970-01-01
      • 2011-05-06
      相关资源
      最近更新 更多