opengsn / workshop

About A sample project to how how to add GSN to a simple Web3 project. See the PRs to see the needed changes. NOTE: the video was created for a previous version
https://youtu.be/tb4hkbofmou
GNU General Public License v3.0
32 stars 24 forks source link

Failed to relay call #11

Open m-waqas88 opened 1 year ago

m-waqas88 commented 1 year ago

@drortirosh, after successfully running yarn gsn-with-ganache and yarn start

image

image

When I click on Capture the flag button, I receive errors in the browser console

Console output

calling sendAsync{"method":"eth_sendTransaction","params":[{"gas":"0xb1bb","gasPrice":"0x4a817c800","from":"0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1","to":"0xfc628dd79137395f3c9744e33b1c5de554d94882","data":"0x239e26f2"}],"id":66,"jsonrpc":"2.0"} bundle.js:61918 fetchRelaysAdded: found 1 relays bundle.js:47566 Sending in view mode: {"jsonrpc":"2.0","id":1,"method":"eth_call","params":[{"from":"0x0000000000000000000000000000000000000000","to":"0xC89Ce4735882C9F0f0FE26686c53074E09B0D550","gas":"0xb71b00","data":"0xb1a62e720000000000000000000000000000000000000000000000000000000000b71b000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000090f8bf6a479f320ead074411a4b0e7944ea8c9c1000000000000000000000000fc628dd79137395f3c9744e33b1c5de554d948820000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b1bb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000063e108dc0000000000000000000000000000000000000000000000000000000000000004239e26f20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004a817c80000000000000000000000000000000000000000000000000000000004a817c800000000000000000000000000000000000000000000000000000000000000176c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d833215cbcc3f914bd1c9ece3ee7bf8b14f841bb000000000000000000000000254dffcd3277c0b1660f6d42efbb754edababc2b00000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","gasPrice":"0x4a817c800"},"latest"]} encoded data: {"relayRequest":{"request":{"to":"0xfc628dd79137395f3c9744e33b1c5de554d94882","data":"0x239e26f2","from":"0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1","value":"0","nonce":"0","gas":"45499","validUntilTime":"1675692252"},"relayData":{"relayWorker":"0x0000000000000000000000000000000000000000","transactionCalldataGasUsed":"0x176c","paymasterData":"0x","maxFeePerGas":"20000000000","maxPriorityFeePerGas":"20000000000","paymaster":"0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb","clientId":"1","forwarder":"0x254dffcd3277C0b1660F6d42EFbB754edaBAbC2B"}},"signature":"0x","approvalData":"0x","maxAcceptanceBudget":"12000000"} bundle.js:47584 relayCall res=0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000f142fc1e9c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000 bundle.js:63097 nextRelay: find fastest relay from: [{"relayManager":"0xc6232031bF6C4858e7BC9eb3e253dBB45C58ef7D","relayUrl":"http://127.0.0.1:36869"}] bundle.js:63153 getRelayAddressPing URL: http://127.0.0.1:36869 bundle.js:63099 race finished with a result: {"errors":{"dataType":"Map","value":[["http://127.0.0.1:36869",{"message":"Network Error","name":"Error","stack":"Error: Network Error\n at createError (http://localhost:3000/bundle.js:68018:15)\n at XMLHttpRequest.handleError (http://localhost:3000/bundle.js:67537:14)","config":{"url":"http://127.0.0.1:36869/getaddr?paymaster=0xD833215cBcc3f914bD1C9ece3EE7BF8B14f841bb","method":"get","headers":{"Accept":"application/json, text/plain, */*"},"transformRequest":[null],"transformResponse":[null],"timeout":15000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false}}}]]},"results":[]}

Error

image

Prevsiously when running yarn start command I was facing below error Public state variable has override specified but does not override anything. solidity

Becauase in line# 18 string public override versionRecipient = "3.0.0"; the override specifier is used.

To eliminate this error I removed the override specifier because compiler says that I am not overriding anything

So now line# 18 is: string public versionRecipient = "3.0.0";

Than yarn start worked fine.

Below is CaptureTheFlag.sol


/**
 * SPDX-License-Identifier:MIT
 */
pragma solidity ^0.8.7;

import "@opengsn/contracts/src/ERC2771Recipient.sol";

contract CaptureTheFlag is ERC2771Recipient {

    event FlagCaptured(address previousHolder, address currentHolder);

    address public currentHolder = address(0);

    constructor(address forwarder) {
        _setTrustedForwarder(forwarder);
    }

    string public versionRecipient = "3.0.0";

    function captureTheFlag() external {
        address previousHolder = currentHolder;

        currentHolder = _msgSender();

        emit FlagCaptured(previousHolder, currentHolder);
    }
}
m-waqas88 commented 1 year ago

@drortirosh can you please look into this? I need to use GSN in one of my projects.

m-waqas88 commented 1 year ago

@forshtat @drortirosh The above error is produced when I am executing the code in WSL2 (windows subsystem for linux). When I tried to run the same on my MacBook then it ran successfully.

How do we plan to resolve this issue in WSL2?

forshtat commented 1 year ago

@forshtat @drortirosh The above error is produced when I am executing the code in WSL2 (windows subsystem for linux). When I tried to run the same on my MacBook then it ran successfully.

How do we plan to resolve this issue in WSL2?

Hi @m-waqas88 As the issue you are experiencing is not related to the GSN project but appears to be caused by your operating system, I don't think we can solve it right now. I will be grateful if you could post the steps to resolve the issue of running GSN on Windows with WSL here for other users who may have encountered the same issue. Thank you!

m-waqas88 commented 1 year ago

@forshtat It will actually not work with WSL because the relay is activated on http://127.0.0.1/ in the Linux environment and not in the context of Windows. My suggestion is to simply mention this in the Readme.md as a note.

forshtat commented 1 year ago

@forshtat It will actually not work with WSL because the relay is activated on http://127.0.0.1/ in the Linux environment and not in the context of Windows. My suggestion is to simply mention this in the Readme.md as a note.

So there is no solution or a workaround to this issue? I don't have a Windows device to test this repo.

m-waqas88 commented 1 year ago

@forshtat I am able to access the port when using "localhost" instead of "127.0.0.1", so in test environment, the relay call should be invoked on localhost: not on 127.0.0.1:

In "/packages/cli/src/GsnTestEnvironment.ts" we need to change the below line#103:

const relayUrl = 'http://127.0.0.1:' + port.toString()

we need to make it as:

const relayUrl = 'http:localhost:' + port.toString()