hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
67 stars 42 forks source link

Convert EVM websocket endpoints to https #3811

Closed jnaviask closed 1 year ago

jnaviask commented 1 year ago

Description

Currently we depend on websockets for all of our EVM endpoints. This is not necessary, as most of our queries are "one and done", meaning we make a query and immediately disconnect. Also, not all EVM chains have public websocket endpoints available. We should rework the EVM-based code to rely on HTTP endpoints when possible, as this will improve efficiency (faster to fire off an HTTP request vs establish a websocket connection) and will make it easier to debug + maintain stable support for the various EVM chains we support.

Technically speaking, we will need to review the ChainNodes table, and audit how/where the url/alt_wallet_url/private_url fields are used, and then ensure that the main url is HTTP when possible. We will also need to correct uses of the URL so that it relies on HTTP endpoints rather than websockets.

Acceptance Criteria

jnaviask commented 1 year ago

Feel free to do discovery here + come up with a proposed plan @ianrowan

ianrowan commented 1 year ago

Change here should be a relatively simple addition to #3028 and are blocked/dependent on those changes being completed. Most likely will make sense to include the conversion to http in that PR

jnaviask commented 1 year ago

Note that there will be many Commonwealth-side changes involved, so ideally we can tackle both in parallel, as we should already have http URLs extant (although we may need to make some adjustments for private_url).

ianrowan commented 1 year ago

Code across the app has been modified to mainly use HTTP with the ability to fallback to wss for existing wss endpoint or those provided by new communities. The following are ETH based chains

Image

Currently for testing I'm migrating our alchemy record to https. I wanted to get some thoughts on which/how we should go about migrating(if we want to in general in this PR) some of these lesser used endpoints. From running some queries it looks like almost every EVM community is on the alchemy eth endpoint with the exception of communities like hmny or cleo which are more uncertain as to if they support https

So main question is which endpoints do we want to update in a migration here beyond alchemy eth?

@jnaviask

jnaviask commented 1 year ago

@ianrowan I see no reason why we can't migrate all of them -- why do you say hmny and cleo don't support https?

ianrowan commented 1 year ago

@jnaviask Upon more research it looks like we can migrate all of our evm endpoints. I just didnt want it to be a shot in the dark guessing that the a wss endpoint also served an https endpoint and as seen here we can typically use the alt_wallet_url but changes beyond just the protocol prefix are required(ie cleo needs the /ws route removed as well)

image

These are all eth rpcs used by CE

ianrowan commented 1 year ago

Migration to convert these here https://github.com/hicommonwealth/commonwealth/blob/cbc3950c3976372065290b22ebdeac59d974b512/packages/commonwealth/server/migrations/20230524184241-convert-wss-rpc-endpoints.js

jnaviask commented 1 year ago

We should make sure we DO update the private_urls that we can't reveal from wss to https, if possible.

& basically the list of nodes needing updates can be queried via SELECT * FROM "ChainNodes" WHERE balance_type = 'ethereum';.

ianrowan commented 1 year ago

We should make sure we DO update the private_urls that we can't reveal from wss to https, if possible.

& basically the list of nodes needing updates can be queried via SELECT * FROM "ChainNodes" WHERE balance_type = 'ethereum';.

@jnaviask got it will add any i missed. In this list so far there arent any with a private URL other than alchemy eth

ianrowan commented 1 year ago

Included in PR #3999