Skip to content

Conversation

@bernard-wagner
Copy link
Contributor

@bernard-wagner bernard-wagner commented Aug 9, 2023

Super early attempt at supporting websockets and IPC for cast. (See #5022 )

Needs a lot more work and the DynamicProvider logic might be more suited to ethers-rs.

Would appreciate any general approach feedback. Happy to continue the development, but anyone else is welcome to take it further (hopefully this gives a starting point).

Tested with Alchemy websocket endpoint.

Main hurdles are that the Provider type is not known at compile time and that build() is synchronous, so need to connect if no client has been established. Using a RwLock, not sure if it absolutely necessary.

@Evalir
Copy link
Member

Evalir commented Aug 15, 2023

hey @bernard-wagner will we get this over the line? happy to review—just need to rebase

@bernard-wagner
Copy link
Contributor Author

bernard-wagner commented Aug 16, 2023

@Evalir reworked it a bit and rebased. Depends on the following change for the moment:

gakonst/ethers-rs@master...bernard-wagner:ethers-rs:retry-pubsub

Seemed like the cleanest way to add a layer to the onion. Also allows the creation of a RetryPolicy for Websockets and IPC.

Also testing it with bernard-wagner/foundry@websocket...subscribe, which is why the PubsubClient is needed.

Happy to remove the PubsubClient requirement for now, but want to validate that this is the correct approach going forward. Will then follow up with the changes to ether-rs and PubsubClient in a subsequent PR.

@bernard-wagner bernard-wagner force-pushed the websocket branch 7 times, most recently from 587cc4a to be348b7 Compare August 19, 2023 08:29
@bernard-wagner bernard-wagner marked this pull request as ready for review August 19, 2023 08:30
@bernard-wagner
Copy link
Contributor Author

@Evalir reworked it to enable PubSub and not need any changes to ether-rs for now.

Happy to start on the work for ether-rs if it is required to have retries for websockets.

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly lgtm, albeit i need to test this and would love @mattsse 's eyes as this is an arch change. just a comment on the ipc handling

do we need anything on ethers so this work properly? if this works self contained, it's great


Ok(InnerClient::Ws(client))
}
"file" => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure this is a infallible way to detect ipc? i'm unsure—couldn't it be just a path?

Copy link
Contributor Author

@bernard-wagner bernard-wagner Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can definitely change it to just be a path, but will need some modification in ProviderBuilder as plain path is not supported by intoUrl.

Copy link
Contributor Author

@bernard-wagner bernard-wagner Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Evalir rebased on master, which added HTTP auth to the provider. So needed to make a few other changes.

Supports ETH_RPC_URL=../../some/path/test.ipc URL format now.

Also made anvil reuse the provider for tests to increase test coverage. Added a few tests that explicitly test the websocket provider against Alchemy as well.

@Evalir Evalir requested a review from mattsse August 21, 2023 18:30
@bernard-wagner bernard-wagner force-pushed the websocket branch 2 times, most recently from fb7656a to b1c968a Compare August 29, 2023 08:54
Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aight, lgtm albeit need to do manual QA on this to ensure things like scripts and etc still work correctly. @mattsse deferring to you here for a second pair of eyes

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome let's get this in.

@Evalir Evalir merged commit 0f530f2 into foundry-rs:master Sep 4, 2023
mikelodder7 pushed a commit to LIT-Protocol/foundry that referenced this pull request Sep 12, 2023
* feat(cast): support websockets

* add tests and rework ipc path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants