Chainlink节点-encode_tx错误长度不正确



我正在开发一个外部适配器,当我向本地链接节点发出请求时,它不起作用。我在encode_tx步骤中出现此错误。

这是错误:ETHABIEncode: while converting argument 'data' from <nil> to bytes32: incorrect length: expected 32, got 32: bad input for task: bad input for task

这是作业规范:

type = "directrequest"
schemaVersion = 1
name = "eth-lottery-job-test4"
contractAddress = "0x1Cc100f9c198d9CD3410263D4Df7FA7C5C30E34F"
maxTaskDuration = "0s"
observationSource = """
decode_log   [type="ethabidecodelog"
abi="OracleRequest(bytes32 indexed specId, address requester, bytes32 requestId, uint256 payment, address callbackAddr, bytes4 callbackFunctionId, uint256 cancelExpiration, uint256 dataVersion, bytes data)"
data="$(jobRun.logData)"
topics="$(jobRun.logTopics)"]
decode_cbor  [type="cborparse" data="$(decode_log.data)"]
fetch        [type="bridge" name="eth-lottery-test" requestData="{\"id\":$(jobSpec.externalJobID), \"data\": {\"username\":$(decode_cbor.username), \"password\":$(decode_cbor.password), \"winner_ticket\":$(decode_cbor.winner_ticket), \"tickets\":$(decode_cbor.tickets)}}"]
parse        [type="jsonparse" path="data,winners" data="$(fetch)"]
encode_data  [type="ethabiencode" abi="(uint256[] winners)" data="{ \"winners\": $(parse) }"]
encode_tx    [type="ethabiencode"
abi="fulfillOracleRequest(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes32 data)"
data="{\"requestId\": $(decode_log.requestId), \"payment\": $(decode_log.payment), \"callbackAddress\": $(decode_log.callbackAddr), \"callbackFunctionId\": $(decode_log.callbackFunctionId), \"expiration\": $(decode_log.cancelExpiration), \"data\": $(encode_data)}"
]
submit_tx    [type="ethtx" to="0x1Cc100f9c198d9CD3410263D4Df7FA7C5C30E34F" data="$(encode_tx)"]
decode_log -> decode_cbor -> fetch -> parse -> encode_data -> encode_tx -> submit_tx
"""

我认为问题出在abi=(uint256[] winners)中的encode_data任务中。这是uint256数组的正确abi吗?

parse任务输出为[6,14,25]encode_data任务输出为:0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000019

我还认为编码任务的结果是不正确的。

我通过更改encode_tx任务中databytes32参数类型来解决此问题。

更改作业规范Toml文件中的这一行。在本文中,我使用了fulfillOracleRequest2()而不是fulfilloraclRequest(),该函数为数据变量提供字节数据类型,这样它就不会遇到长度错误。

encode_tx    [type="ethabiencode"
abi="fulfillOracleRequest2(bytes32 requestId, uint256 payment, address callbackAddress, bytes4 callbackFunctionId, uint256 expiration, bytes calldata data)"
data="{\"requestId\": $(decode_log.requestId), \"payment\": $(decode_log.payment), \"callbackAddress\": $(decode_log.callbackAddr), \"callbackFunctionId\": $(decode_log.callbackFunctionId), \"expiration\": $(decode_log.cancelExpiration), \"data\": $(encode_data)}"
]

相关内容

  • 没有找到相关文章

最新更新