Chainlink request not fulfilling

68 views Asked by At

I'm trying to setup a local Chainlink node to perform a task. The request is being performed correctly, but it seems like the fulfill function is not being called as the obtained data is not saved.

task list

Even though the last step is marked as suspended (I don't know if this could be the cause of my problem). It becomes completed after the next execution of the code. I tried setting minIncomingConfirmations to 0, but it keeps getting overridden to 1:

last task

This is the part of the smart contract that performs the request:

    function reEncryptData(
        string memory reEncryptionKey,
        string memory _encryptedData
    ) public returns (bytes32) {
        Chainlink.Request memory request = buildOperatorRequest(
            jobId,
            this.fulfillReEncryption.selector
        );
        request.add("reEncryptionKey", reEncryptionKey);
        request.add("encryptedData", _encryptedData);
        return sendOperatorRequest(request, fee);
    }

    function fulfillReEncryption(
        bytes32 requestId,
        bytes memory _data
    ) public recordChainlinkFulfillment(requestId) {
        reEncryptedData = string(_data);
    }

This is the .toml of my job:

type = "directrequest"
schemaVersion = 1
name = "Re-Encrypt Data"
contractAddress = "0xC1CD77E8cd5FB78898815952117Aca334fe573cd"
maxTaskDuration = "0s"
minIncomingConfirmations = "0"
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="re-encrypt" requestData="{\\"id\\": $(jobSpec.externalJobID), \\"data\\": { \\"encryptedData\\": $(decode_cbor.encryptedData), \\"reEncryptionKey\\": $(decode_cbor.reEncryptionKey)}}"]
    parse        [type=jsonparse path="data,reEncryptedData" data="$(fetch)"]
    encode_large [type=ethabiencode abi="(bytes32 requestId, bytes _data)" data="{\\"requestId\\": $(decode_log.requestId), \\"_data\\": $(parse) }"]
    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_large)}"
                 ]
    submit_tx    [type=ethtx to="0xC1CD77E8cd5FB78898815952117Aca334fe573cd" data="$(encode_tx)"]

    decode_log -> decode_cbor -> fetch -> parse -> encode_large -> encode_tx -> submit_tx
"""

And this is the code invoking the smart contract function:

  await (
    await reEncryption
      .connect(dataSubject)
      .reEncryptData(
        "d48065aceb01496e1e4f8f74c7b68422ba16e1de7c80a9e927683f30c42b150804d505e4835912f719e96fd27f8e42345aa757070f5fa083974f5fb82fd384b4bdc74dbd75b6a60c68108d97e4c8dcd02c12a7d5552e28df3a7af366bb05b86ace",
        "eyJrZXkiOiIwNGU5MjcwMzhiMjFjMDJhZDI2MmUxZmMwNmY4YmU0NTFiYmUyODU0Y2FmZGNmMDg4YzY5NDBjNTUzMjI4M2E3OTE5NTY1NDU0N2ZjZmQ2Yzg1OWJiZWQ2NmNlZmNlN2FkOTUyMDhkNmI5MjNkNjVkYjRmNTQyYWEwYTI3M2VmY2U1MDRmMTE4NmRkYzMxMjZhYWMwNGJhZWNlN2I5NDA4YzkwMDVkY2Q2MjJhYTlkY2E4YjU4NDg1MmI0NjU0MzAyNzMwM2U4NjA2MWRlNTNmYjcxNzk1NTAzZjNiYzRiNDMyNTJhNWFiODRiZDE2YmZkN2M4ZjYzZWRmMWM1ODIzZjVlZDNlYzg3OGJmNGY0ZTAzMmYxN2NiNWI5Y2RlOWU1YzMwN2U5NzI4ZjJmYzBhMWUwNGM2NzA2MDRjM2MyM2Q1NWIiLCJjaXBoZXIiOiJlcGtLVU1abEU1Q29Ucm1RbUUydkFRPT0ifQ=="
      )
  ).wait();

I don't understand what am I doing wrong, but I hope you could help me. Thanks!

I have:

  • Used Operator.sol
  • Funded both this smart contract and the operator smart contract with LINK
  • Funded oracle node with ETH and LINK
  • Added oracle node address to setAuthorizedSenders
1

There are 1 answers

0
Derek On

Have you checked for the related transaction within your oracle (operator) contract, using a block explorer? Since you didn't post a link to your transaction, we'll have to do some guessing here:

  • If the transaction does not exist (ie, no fulfill transaction generated by the Chainlink node), you have an issue with your Chainlink node, and will need to use the node GUI or filesystem logs to debug your job run.

  • If the transaction does exist, check for any error codes. A common one here is out of gas, which means that the returned oracle value and/or contract logic within your fulfillReEncryption function exceeded the amount of gas that your node is allowed to spend per request (usually defaults to 500,000). To solve this, you'll need to adjust this value at either the node (global) or job level, reduce the amount data being sent in your response, or simplify your fulfillReEncryption logic. If you don't see an out of gas error but do see a generic failure on the transaction, you likely have a coding error within your fulfillReEncryption function logic. Double-check your logic and try again.

I hope that helps!