LayerZero-Labs / LayerZero-v2

Other
492 stars 312 forks source link

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

Open ytqaljn opened 2 weeks ago

ytqaljn commented 2 weeks ago

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 commented 6 days ago

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 commented 6 days ago

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 commented 6 days ago

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 commented 6 days ago

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 commented 5 days ago

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?