【问题标题】:Reverted transaction on Chainlink Node while fulfilling request完成请求时在 Chainlink 节点上恢复交易
【发布时间】:2021-11-18 09:39:07
【问题描述】:

我在我的 Chainlink 节点上收到了还原的交易,我正在寻找一些关于如何调试它的提示。节点接收到 Oracle 请求,作业成功运行。我的完成功能是最小的:

function checkConditions(address _oracle, string memory _jobId) external {
    setPublicChainlinkToken();
    Chainlink.Request memory request = buildChainlinkRequest(
        stringToBytes32(_jobId),
        address(this),
        this.fulfill.selector
    );

    request.add("ytChannelId", "UCfpnY5NnBl-8L7SvICuYkYQ");
    sendChainlinkRequestTo(
        _oracle,
        request,
        1 * LINK_DIVISIBILITY
    );
}

event OnFulfill(uint256 _ytViews, uint256 _ytSubs);

function fulfill(
    bytes32 _requestId,
    uint256 _ytViews,
    uint256 _ytSubs
) public recordChainlinkFulfillment(_requestId) {
    emit OnFulfill(_ytViews, _ytSubs);
}

我从 github blob 改编了作业规范,因为它是一个带有桥的多变量作业,这正是我的用例。我的 .toml 文件:

type = "directrequest"
schemaVersion = 1
name = "mysocialcontract-ea-job"
contractAddress = "0x2Db11F9E1d0a1cDc4e3F4C75B4c14f4a4a1a3518"
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)"]
    decodecbor  [type="cborparse" data="$(decode_log.data)"]
    fetch  [type="bridge" name="mysocialcontract" requestData="{\\"id\\": \\"0\\", \\"data\\": {\\"ytChannelId\\": $(decodecbor.ytChannelId)}}"]
    decode_log -> decodecbor -> fetch
    ytSubs    [type=jsonparse path="result,ytSubs"]
    ytViews    [type=jsonparse path="result,ytViews"]
    fetch -> ytSubs 
    fetch -> ytViews
    ytSubs -> encode_mwr
    ytViews -> encode_mwr
    encode_mwr [type=ethabiencode abi="(bytes32 _requestId, uint256 _ytViews, uint256 _ytSubs)"
            data="{\\"_requestId\\": $(decode_log.requestId),\\"_ytViews\\": $(ytViews),\\"_ytSubs\\": $(ytSubs)}"]
    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_mwr)}"]
    submit [type=ethtx to="0x2Db11F9E1d0a1cDc4e3F4C75B4c14f4a4a1a3518" data="$(encode_tx)" gasLimit="5000000"]
    encode_mwr -> encode_tx -> submit
"""

来自我最后一次尝试的交易:https://kovan.etherscan.io/tx/0x2b58d0b9c6a6718817acbfb4cfb1bdcc893b28cedf111a8b5293473842a9a9c3

这是我的设置:

  • 在 AWS 上部署的 Chainlink 节点。
  • 我自己的网桥 + 外部适配器。
  • 使用硬编码值在 Remix IDE 上测试 Oracle 的小功能。

【问题讨论】:

    标签: solidity chainlink


    【解决方案1】:

    感谢 Chainlink discord 上的用户,我设法让多字请求正常工作。正如他所说,问题是我使用的是 Oracle.sol 合约而不是 Operator.sol 合约,然后在节点作业上调用“fulfillOracleRequest2”。问题出在合同上,而不是 .toml 工作上。事实上,我最终从节点作业中改变的唯一东西就是预言机地址。

    为了让合同生效,我刚刚从 chainlink 文档中改编了 MultiWordConsumer.sol 合同。我在 Chainlink 文档中找不到有关 Operator.sol 合约的太多信息,所以希望这能帮助遇到我遇到的同样问题的人:

    • 您已经部署了自己的 Operator.sol 合约实例。您可以通过创建仅导入 Operator.sol 合约的合约在 Remix 中执行此操作: 导入“@chainlink/contracts/src/v0.7/Operator.sol”;

    • 部署 Operator 合约后,您必须将您的节点设置为授权发送者。您可以通过使用您的节点地址调用“setAuthorizedSenders”来做到这一点,即 ["0xb7..."]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-09
      • 2017-02-09
      • 2019-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多