smartcontractkit / chainlink-local

The Chainlink CCIP Local Simulator, visit documentation by clicking the link below:
https://docs.chain.link/chainlink-local
MIT License
47 stars 15 forks source link

Errors on the ccipRecieve side are ambiguous #15

Open Andriy-Kulak opened 2 months ago

Andriy-Kulak commented 2 months ago

First off, thanks for the hard work on this repo!

I got the local testing to work, but it took a little bit of effort (& a ton of console.logging 😅 ) to get it to work.

The main reason is that once the receiving contract was able to get the message, there were a few bugs on my code (i.e I wasn't decoding properly, set gas limit too small, etc.) For any error on Receiver contract, no matter, what it was, I got the same exact error below.

Not sure the best way to have the error pinpoint exact culprit, but in the meantime maybe the error can at least be more descriptive. I.e. Something along the lines. There is likely a code error somewhere on receiver side, also check the gasLimit, etc. this would save people a little bit of time in future.

     Error: VM Exception while processing transaction: reverted with custom error 'ReceiverError("0x")'
    at MockCCIPRouter.ccipSend (@chainlink/contracts-ccip/src/v0.8/ccip/test/mocks/MockRouter.sol:75)
    at MyContractStorage._sendMessagePayNative (contracts/MyContractStorage.sol:420)
    at MyContractStorage.createCampaign (contracts/MyContractStorage.sol:227)
    at EdrProviderWrapper.request (node_modules/hardhat/src/internal/hardhat-network/provider/provider.ts:429:41)
    at async HardhatEthersSigner.sendTransaction (node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:125:18)
    at async send (node_modules/ethers/src.ts/contract/contract.ts:313:20)
    at async Proxy.createCampaign (node_modules/ethers/src.ts/contract/contract.ts:352:16)
    at async Context.<anonymous> (test/dummy.test.ts:51:17) 
andrejrakic commented 2 months ago

Thank you for the nice words, @Andriy-Kulak, we appreciate that! If possible, I would also like to hear later why the initial setup wasn't a smooth experience for you and how we can improve the Chainlink Local docs

But now let's solve this issue first :)

You are right, this is a generic error returned from the CCIP contracts when they call the ccipReceive() function on your receiver contract. The reason why it is custom is because when calling an arbitrary contract, one can't easily decode why it failed. This error message means either you set up the gasLimit value too low or there is some kind of issue or a flaw in your receiver contract.

Can you please paste me here the piece of code where you send the CCIP message from the Sender contract and the ccipReceive function of the Receiver contract? Thank you

VishnuramRajkumarSecurrency commented 2 months ago

Hi @andrejrakic !

I'm facing the same error in MockRouter's 75th line. When I traced back in my hardhat test I found out error was with EvmError(reason: "OUT_OF_GAS"). I have also included the gasLimit with the function call.

VishnuramRajkumarSecurrency commented 2 months ago

Issue is resolved for me after following this - https://docs.chain.link/ccip/tutorials/ccipreceive-gaslimit. Increased the gasLimit.

Andriy-Kulak commented 1 month ago

Quote reply

Thank you for the nice words, @Andriy-Kulak, we appreciate that! If possible, I would also like to hear later why the initial setup wasn't a smooth experience for you and how we can improve the Chainlink Local docs

But now let's solve this issue first :)

You are right, this is a generic error returned from the CCIP contracts when they call the ccipReceive() function on your receiver contract. The reason why it is custom is because when calling an arbitrary contract, one can't easily decode why it failed. This error message means either you set up the gasLimit value too low or there is some kind of issue or a flaw in your receiver contract.

Can you please paste me here the piece of code where you send the CCIP message from the Sender contract and the ccipReceive function of the Receiver contract? Thank you

Yeah I was able to resolve the issue. I was just saying that the error is ambiguous & can have some additional clues to pinpoint potential culprits (i.e., check gas limit, check the receiver code, etc.)