MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.87k stars 4.85k forks source link

[Bug]: Can not connect to the network #19151

Closed payvint closed 1 year ago

payvint commented 1 year ago

Describe the bug

Hello guys, After updating to the latest version(10.30.2) of Metamask, we can not connect to the SKALE network.

Metamask is continue loading and then show a message "Oops! Something went wrong. (Switch networks) (Try again)"

And in a console it shows these type of errors: "Unknown Infura provider type: LINK_TO_THE_RPC" Or "MetaMask is having trouble connecting to the network { "originalError": {} }"

But RPC link is working properly in other wallets(Enkrypt for example) and when you are opening the ppc in get attach console.

Steps to reproduce

  1. Go to https://mainnet.skalenodes.com/#/chains/elated-tan-skat
  2. Press Add Network (It will add Europa chain to the Metamask)
  3. Open Metamask it will show loading

Error messages or log output

"Unknown Infura provider type: LINK_TO_THE_RPC"
Or
"MetaMask is having trouble connecting to the network { "originalError": {} }"

Version

10.30.2

Build type

None

Browser

Chrome

Operating system

MacOS

Hardware wallet

No response

Additional context

So basically we can not connect to any SKALE chains with Metamask, because it is trying to validate the endpoint as Infura.

dmytrotkk commented 1 year ago

had the same problem, manual rollback to Version 10.29.0 resolves the issue

TheGreatAxios commented 1 year ago

Update on this:

In the uploaded image it is clear that the last request made manually in the console is a very large chain id equivalent to the connected chain. This means in the background the proper chain is connected and it has been confirmed that requests are being made. It is possible this is an issue related to some selection in the UI

image
TheGreatAxios commented 1 year ago

Update #2 when switching from a infinitley loading chain to another chain it will sometimes result in infinite load on other chains in this case Fantom Testnet.

image
JamesHinshelwood commented 1 year ago

I think I've spotted the problem. In the background view console logs, when connecting to our chain, it says:

NetworkController - could not determine network status
l.AssertionError {name: 'AssertionError', actual: false, expected: true, operator: '==', message: 'value is not a number', …}

which I think comes from https://github.com/MetaMask/metamask-extension/blob/5135b80de7fb274c86aae94430a86ac8c5391e6a/app/scripts/controllers/network/network-controller.ts#L310

Between versions v10.29.0 and v10.30.0, I think some extra validation was added to the response of net_version. From a brief look at git blame, my best guess is #18358.

Specifically, I think this is caused when the response of net_version is returned as a hexadecimal string, rather than a decimal string. Strictly speaking, the JSON-RPC documentation does give an example with a decimal string, so maybe its reasonable to only accept a decimal. However, we may want to relax the validation to avoid breaking Metamask for networks that previously worked?

payvint commented 1 year ago

Hey @JamesHinshelwood thanks for pointing to a problem! We took a look and noticed that we forked aleth client at that point when it was returning a hex instead of a decimal!

adiled commented 1 year ago

Can confirm it's a UI hang where the network does switch, but breaks somewhere in the flow before reaching network change event. If it is indeed from a net_version assertion mid-way, better failover handling is needed.

Gudahtt commented 1 year ago

Thanks for the report everyone, and especially thanks to @JamesHinshelwood for the detailed investigation, that was extremely helpful. We believe we have a solution, and we're preparing a v10.30.3 release that will include a that fix.

payvint commented 1 year ago

@Gudahtt Thank you very much for a quick resolving!