Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help: My cross-chain contract failed when calling the quoteSend transaction. #80

Open
ytqaljn opened this issue Jun 11, 2024 · 9 comments

Comments

@ytqaljn
Copy link

ytqaljn commented Jun 11, 2024

Hi, I generated an OFT contract according to your Create LZ OApp Quickstart, and then modified the relevant configurations to successfully deploy them to two networks with LZ Endpoint.

Now I successfully called setPeer through my calling script, and isPeer also returned true.

But when I started calling my quoteSend, it returned an error.

Here are the parameters I sent when calling, I am not sure if they are correct:

image

Here is the error:

Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (data="0x", transaction={"from":"0xFd0Cc11A9ffbA29F7db7734b6dc39b1e5212Bb1c","to":"0x42358BE1Ff7964B1eD57897a82071AEE47E38693","data":"0x3b6f743b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000759e000000000000000000000000fd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","accessList":null}, error={"reason":"processing response error","code":"SERVER_ERROR","body":"{"jsonrpc":"2.0","error":{"code":-32603,"message":"VM Exception while processing transaction: revert","data":"0x6c1ccdb5"},"id":44}","error":{"code":-32603,"data":"0x6c1ccdb5"},"requestBody":"{"method":"eth_call","params":[{"from":"0xfd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c","to":"0x42358be1ff7964b1ed57897a82071aee47e38693","data":"0x3b6f743b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000759e000000000000000000000000fd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"latest"],"id":44,"jsonrpc":"2.0"}","requestMethod":"POST","url":"https://rpc.api.moonbase.moonbeam.network"}, code=CALL_EXCEPTION, version=providers/5.7.2)
at Logger.makeError (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/logger/lib/index.js:247:20)
at checkError (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:108:16)
at JsonRpcProvider. (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:751:47)
at step (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
at Object.throw (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
at rejected (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
reason: 'missing revert data in call exception; Transaction reverted without a reason string',
code: 'CALL_EXCEPTION',
data: '0x',
transaction: {
from: '0xFd0Cc11A9ffbA29F7db7734b6dc39b1e5212Bb1c',
to: '0x42358BE1Ff7964B1eD57897a82071AEE47E38693',
data: '0x3b6f743b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000759e000000000000000000000000fd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
accessList: null
},
error: Error: processing response error (body="{"jsonrpc":"2.0","error":{"code":-32603,"message":"VM Exception while processing transaction: revert","data":"0x6c1ccdb5"},"id":44}", error={"code":-32603,"data":"0x6c1ccdb5"}, requestBody="{"method":"eth_call","params":[{"from":"0xfd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c","to":"0x42358be1ff7964b1ed57897a82071aee47e38693","data":"0x3b6f743b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000759e000000000000000000000000fd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"latest"],"id":44,"jsonrpc":"2.0"}", requestMethod="POST", url="https://rpc.api.moonbase.moonbeam.network", code=SERVER_ERROR, version=web/5.7.1)
at Logger.makeError (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/logger/lib/index.js:238:21)
at Logger.throwError (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/logger/lib/index.js:247:20)
at /home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:313:32
at step (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
reason: 'processing response error',
code: 'SERVER_ERROR',
body: '{"jsonrpc":"2.0","error":{"code":-32603,"message":"VM Exception while processing transaction: revert","data":"0x6c1ccdb5"},"id":44}',
error: Error: VM Exception while processing transaction: revert
at getResult (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:191:21)
at processJsonFunc (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:356:22)
at /home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:288:46
at step (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:33:23)
at Object.next (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:14:53)
at fulfilled (/home/ytqaljn/Desktop/my-lz-oapp/node_modules/@ethersproject/web/lib/index.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: -32603,
data: '0x6c1ccdb5'
},
requestBody: '{"method":"eth_call","params":[{"from":"0xfd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c","to":"0x42358be1ff7964b1ed57897a82071aee47e38693","data":"0x3b6f743b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000759e000000000000000000000000fd0cc11a9ffba29f7db7734b6dc39b1e5212bb1c0000000000000000000000000000000000000000000000008ac7230489e800000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},"latest"],"id":44,"jsonrpc":"2.0"}',
requestMethod: 'POST',
url: 'https://rpc.api.moonbase.moonbeam.network'
}
}

Node.js v22.1.0

Can anyone help me solve my problem? Thank you.

@St0rmBr3w
Copy link
Contributor

Did you call setEnforcedOptions? You need to provide at least some execution options either as enforced or extra in order for the quote to succeed. https://docs.layerzero.network/v2/developers/evm/oft/quickstart#message-execution-options

@ytqaljn
Copy link
Author

ytqaljn commented Jun 20, 2024

Hmm, I didn't call it, I thought I didn't need to call it if I didn't force extra options. So what value do I need to pass it? If there are no extra options.

Do you mean I need to call setEnforcedOptions? Or do I need to pass a value to the _option field when I call quoteSend?

@ytqaljn
Copy link
Author

ytqaljn commented Jun 20, 2024

Hello, @St0rmBr3w

I have now successfully called setEnforcedOptions.

My call parameters are as follows:

image

But I still get an error when I call _quoteSend later. Below are my calling parameters and the error:

image
image

@St0rmBr3w
Copy link
Contributor

St0rmBr3w commented Jun 20, 2024

You don't need to setEnforcedOptions, but you will need to then pass a bytes array to extraOptions.

The way the OFT Standard works is it takes the _extraOptions, and combines them with the _enforcedOptions to determine the total amount of gas you are requesting on the destination chain.

Look at the line with combineOptions().

function _buildMsgAndOptions(
        SendParam calldata _sendParam,
        uint256 _amountLD
    ) internal view virtual returns (bytes memory message, bytes memory options) {
        bool hasCompose;
        // @dev This generated message has the msg.sender encoded into the payload so the remote knows who the caller is.
        (message, hasCompose) = OFTMsgCodec.encode(
            _sendParam.to,
            _toSD(_amountLD),
            // @dev Must be include a non empty bytes if you want to compose, EVEN if you dont need it on the remote.
            // EVEN if you dont require an arbitrary payload to be sent... eg. '0x01'
            _sendParam.composeMsg
        );
        // @dev Change the msg type depending if its composed or not.
        uint16 msgType = hasCompose ? SEND_AND_CALL : SEND;
        // @dev Combine the callers _extraOptions with the enforced options via the OAppOptionsType3.
        options = combineOptions(_sendParam.dstEid, msgType, _sendParam.extraOptions);

        // @dev Optionally inspect the message and options depending if the OApp owner has set a msg inspector.
        // @dev If it fails inspection, needs to revert in the implementation. ie. does not rely on return boolean
        if (msgInspector != address(0)) IOAppMsgInspector(msgInspector).inspect(message, options);
    }

This is the combineOptions function.

   function combineOptions(
       uint32 _eid,
       uint16 _msgType,
       bytes calldata _extraOptions
   ) public view virtual returns (bytes memory) {
       bytes memory enforced = enforcedOptions[_eid][_msgType];

       // No enforced options, pass whatever the caller supplied, even if it's empty or legacy type 1/2 options.
       if (enforced.length == 0) return _extraOptions;

       // No caller options, return enforced
       if (_extraOptions.length == 0) return enforced;

       // @dev If caller provided _extraOptions, must be type 3 as its the ONLY type that can be combined.
       if (_extraOptions.length >= 2) {
           _assertOptionsType3(_extraOptions);
           // @dev Remove the first 2 bytes containing the type from the _extraOptions and combine with enforced.
           return bytes.concat(enforced, _extraOptions[2:]);
       }

       // No valid set of options was found.
       revert InvalidOptions(_extraOptions);
   }

If you don't setEnforcedOptions AND don't provide an extraOption, you are not passing in any destination gas settings and the call will revert.

@ytqaljn
Copy link
Author

ytqaljn commented Jun 21, 2024

Thank you, I have two questions now:

  1. You said that you cannot provide a null value to extraOption without setting setEnforcedOptions. I have set setEnforcedOptions now, so I passed 0x to extraOption, but it still reports an error.

  2. If I don't set it, can my extraOption pass the sample value in the document: 0x00030100110100000000000000000000000000000000ea60

In addition, the error message I currently receive is not InvalidOptions(_extraOptions) , but Error: call revert exception

@St0rmBr3w Could you please tell me how to solve this error? Or is it a problem with extraOptions?

@St0rmBr3w
Copy link
Contributor

Is there a reason you're passing 0x1 as an input to quoteSend?

@ytqaljn
Copy link
Author

ytqaljn commented Jul 3, 2024

@St0rmBr3w There's no particular reason, in fact, I've tried all these different parameters and they all failed.

The value I passed at:
0x00030100110100000000000000000000000000000000ea60

After failing, I passed:
0x

image

And I have currently set up setEnforcedOptions

@ytqaljn
Copy link
Author

ytqaljn commented Jul 9, 2024

@St0rmBr3w
Could you please guide me? I really need your help.

@ilovestu
Copy link

Hello,did you solve this problem? I also encountered this problem when trying to send a message from arbitrum to manta. The following is my sender contract, which is almost the same as the sample contract in the document.
`
pragma solidity ^0.8.22;

import { OApp, Origin, MessagingFee } from "@layerzerolabs/oapp-evm/contracts/oapp/OApp.sol";
import { OptionsBuilder } from "@layerzerolabs/oapp-evm/contracts/oapp/libs/OptionsBuilder.sol";
import { OAppCore } from "@layerzerolabs/oapp-evm/contracts/oapp/OAppCore.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

contract MyOApp is OApp {
using OptionsBuilder for bytes;

string public data = "Nothing received yet";


event MessageSent(string message, uint32 dstEid);
event MessageReceived(string message, uint32 senderEid, bytes32 sender, uint64 nonce);

bytes _options = OptionsBuilder.newOptions().addExecutorLzReceiveOption(300000, 0);

constructor(address _endpoint) OApp(_endpoint, msg.sender) Ownable(msg.sender) {}

function addressToBytes32(address _addr) public pure returns (bytes32) {
    return bytes32(uint256(uint160(_addr)));
}

function quote(
    uint32 _dstEid,
    string memory _message,
    bool _payInLzToken
) public view returns (MessagingFee memory fee) {
    bytes memory payload = abi.encode(_message);
    fee = _quote(_dstEid, payload, _options, _payInLzToken);
}

function send(
    uint32 _dstEid,
    string memory _message
) external payable {
    // Encodes the message before invoking _lzSend.
    bytes memory _encodedMessage = abi.encode(_message);
    _lzSend(
        _dstEid,
        _encodedMessage,
        _options,
        // Fee in native gas and ZRO token.
        MessagingFee(msg.value, 0),
        // Refund address in case of failed source message.
        payable(msg.sender) 
    );

    emit MessageSent(_message, _dstEid);
}

function _lzReceive(
    Origin calldata _origin,
    bytes32 /*_guid*/,
    bytes calldata message,
    address /*executor*/,  // Executor address as specified by the OApp.
    bytes calldata /*_extraData*/  // Any extra data or options to trigger on receipt.
) internal override {
    // Decode the payload to get the message
    data = abi.decode(message, (string));
    // Emit the event with the decoded message and sender's EID
    emit MessageReceived(data, _origin.srcEid, _origin.sender, _origin.nonce);
}

}`

When I called quote after setPeer, I got the same error as yours.This is my script
const feeQuote = await oappContract.quote(toeid, message, false); const nativeFee = feeQuote.nativeFee; console.log("nativeFee is: ", nativeFee);
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants