smartcontractkit / functions-hardhat-starter-kit

MIT License
146 stars 103 forks source link

never ending listen for fulfillment in functions-request #214

Closed pedrohba1 closed 1 month ago

pedrohba1 commented 4 months ago

I'm using netowrk localFunctionsTestnet and when trying to run a local functions-request the following is happening:

➜  npx hardhat functions-request --network localFunctionsTestnet --contract 0xef9fDC41236486FD497b0811FA197F8195bb1cB4 --subid 1 --simulate true

secp256k1 unavailable, reverting to browser version

Response returned by script during local simulation: 3

Local simulation of source code completed...
If the request's callback uses all 100,000 gas, this request will charge the subscription an estimated 0.37846 LINK

Continue? Enter (y) Yes / (n) No
y
⣾ Functions request has been initiated in transaction 0xc46e62b3018891d6e9ac902be6b079c54cd24b246bf35526011a3b06b5a42eb4 with request ID 0x80bd3df61d97ffc35adf369dce738a86027f69df4ef61b1bcca8c042247f4698. Note the request ID may change if a re-org occurs, but the transaction hash will remain constant.
Waiting for fulfillment from the Decentralized Oracle Network...
^C⏎                                                                                                                                                            

That keeps waiting, but never finishes. Although, when I check the on-chain resposne, it did happen and update the value in the contract:

➜  npx hardhat functions-read --network localFunctionsTestnet --contract 0xef9fDC41236486FD497b0811FA197F8195bb1cB4                           05/24/24 - 10:11 
secp256k1 unavailable, reverting to browser version
Reading data from Functions consumer contract 0xef9fDC41236486FD497b0811FA197F8195bb1cB4 on network localFunctionsTestnet

On-chain response represented as a hex string: 0x0000000000000000000000000000000000000000000000000000000000000003
3

It is possible to reproduce this problem with the steps in the readme In this folder repo's "fork" of this starter kit: https://github.com/propytech-dao/chainlink-hackaton/tree/main/functions-hardhat-starter-kit#readme

imadarchid commented 4 months ago

Facing the same issue.

imadarchid commented 4 months ago

@pedrohba1 I was able to make it work by explicitly specifying the number of confirmations required, the timeout, as well as the checkInterval.

await responseListener.listenForResponseFromTransaction(requestTx.hash, 12000, 1, 1) # explicitly mention parameters

https://github.com/smartcontractkit/functions-hardhat-starter-kit/blob/dbea19fdf3ab85c792f34ef95c85edb8669cd15f/tasks/Functions-consumer/request.js#L218-L220

pedrohba1 commented 4 months ago

Worked for me, thanks!

zeuslawyer commented 1 month ago

THis is https://github.com/smartcontractkit/functions-toolkit/issues/56

thanks for reporting your workaround @pedrohba1 - will take a look!

zeuslawyer commented 1 month ago

Confirmed this appears to work. I will also look at this bug in the imported functions-toolkit package. Thanks for the workaround @pedrohba1 .

I will patch this repo with the fix.

I will close this issue out and if there are new developments I'll reopen it and provide you all with updates.