trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.6k stars 676 forks source link

Request hangs on Optimism Forked chains #4529

Closed vasapower closed 8 months ago

vasapower commented 9 months ago

If you try this simple code, you will notice that the call hangs on eth_chainId and the code couldn't run. Also tried with several URLs like Alchemy.

It used to work perfectly in older versions.

Any clue about this?

TKS

    var Ganache = require("ganache");

    async function main() {

        var options = {
            fork : {
                url : "https://mainnet.optimism.io"
            }
        };
        var provider = Ganache.provider(options);

        //Hangs here
        console.log(parseInt(await provider.request({
            method : 'eth_chainId'
        })));

        //Never arrives here
        var accounts = await provider.request({
            method : 'eth_accounts'
        });
        console.log(accounts);
    }

    main().catch(console.error);
davidmurdoch commented 9 months ago

Hm, weird. Do you know what versions it worked in?

vasapower commented 9 months ago

Going back in my commits, it worked with 7.4.1 and 7.4.4

vasapower commented 9 months ago

Going back in my commits, it worked with 7.4.1 and 7.4.4

Trying to test it with v7.4.4 through yarn, but the downloaded version in node_modules is always the latest (actually, 7.9.1), even after yarn cache clean. Would it be helpful to open a new issue also for this?

davidmurdoch commented 9 months ago

No, that's not a ganache issue, it's likely just yarn trying to resolve some complex dependency version matching. You probably have another dependency that pulls in v7.9.1 (maybe truffle?). Try adding "ganache": "7.4.4" to your package.json directly, delete your node_modules folder (and maybe yarn.lock, too), and then run yarn install again.

vasapower commented 9 months ago

No, that's not a ganache issue, it's likely just yarn trying to resolve some complex dependency version matching. You probably have another dependency that pulls in v7.9.1 (maybe truffle?). Try adding "ganache": "7.4.4" to your package.json directly, delete your node_modules folder (and maybe yarn.lock, too), and then run yarn install again.

You're right. It worked without "^", afraid for the false alarm.

Anyway, I tried v7.3.0, v7.4.1 and v7.4.4 and for all these versions it doesn't hang anymore but it launches this exception:

Error: Invalid transaction type: 126
    at Function.typeOf (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:187723)
    at Function.typeOfRPC (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:187949)
    at Function.fromRpc (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:186641)
    at c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:59746
    at Array.forEach (<anonymous>)
    at Function.rawFromJSON (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:59547)
    at Fork.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:77413)
    at processTicksAndRejections (c:\Users\marco\Desktop\gan\lib\internal\process\task_queues.js:96:5)
    at async Blockchain.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:43949)
    at async EthereumProvider.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:130121) {stack: 'Error: Invalid transaction type: 126
    at F…node_modules\ganache\dist\node\1.js:2:130121)', message: 'Invalid transaction type: 126'}

I've also introduced the await provider.initialize(); line just after the Provider creation and it launches the same exception.

Maybe Ganache has a sort of SYN-ACK mechanism with the forked node that stopped working for Optimism after their Bedrock update?

vasapower commented 8 months ago

No, that's not a ganache issue, it's likely just yarn trying to resolve some complex dependency version matching. You probably have another dependency that pulls in v7.9.1 (maybe truffle?). Try adding "ganache": "7.4.4" to your package.json directly, delete your node_modules folder (and maybe yarn.lock, too), and then run yarn install again.

You're right. It worked without "^", afraid for the false alarm.

Anyway, I tried v7.3.0, v7.4.1 and v7.4.4 and for all these versions it doesn't hang anymore but it launches this exception:

Error: Invalid transaction type: 126
    at Function.typeOf (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:187723)
    at Function.typeOfRPC (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:187949)
    at Function.fromRpc (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:186641)
    at c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:59746
    at Array.forEach (<anonymous>)
    at Function.rawFromJSON (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:59547)
    at Fork.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:77413)
    at processTicksAndRejections (c:\Users\marco\Desktop\gan\lib\internal\process\task_queues.js:96:5)
    at async Blockchain.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:43949)
    at async EthereumProvider.initialize (c:\Users\marco\Desktop\gan\node_modules\ganache\dist\node\1.js:2:130121) {stack: 'Error: Invalid transaction type: 126
    at F…node_modules\ganache\dist\node\1.js:2:130121)', message: 'Invalid transaction type: 126'}

I've also introduced the await provider.initialize(); line just after the Provider creation and it launches the same exception.

Maybe Ganache has a sort of SYN-ACK mechanism with the forked node that stopped working for Optimism after their Bedrock update?

@davidmurdoch Sorry for pinging you. Did u have any clue about this? Even in order to create a temporary workaround? Thanks

davidmurdoch commented 8 months ago

The script above works for me on ganache@7.9.1

vasapower commented 8 months ago

The script above works for me on ganache@7.9.1

It came back to work on me too. Really strange O.o

davidmurdoch commented 8 months ago

Very strange. Please close if this is resolved for you.