Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(providers): add connect_builtin example #34

Merged
merged 5 commits into from
Mar 29, 2024
Merged

Conversation

yash-atreya
Copy link
Member

  • Updates the dependencies in examples-providers.
  • Adds the connect_builtin examples for all three builtin transport type. HTTP, WS and IPC.

@yash-atreya
Copy link
Member Author

yash-atreya commented Mar 27, 2024

This would fail ci due to the IPC path not being present.

@mattsse
Copy link
Member

mattsse commented Mar 27, 2024

does this work locally?

it's possible that the file is created somewhere else, I think we want this as a getter on the anvil instance as well

@prestwich
Copy link
Member

think we want this as a getter on the anvil instance as well

prefer the opposite. ProviderBuilder::on_anvil(self, AnvilSettings)

reasoning: node-bindings is nearly dep-free. we want provider to depend on it, not vice versa

@yash-atreya
Copy link
Member Author

yash-atreya commented Mar 27, 2024

does this work locally?

it's possible that the file is created somewhere else, I think we want this as a getter on the anvil instance as well

It works if the file exists but would ultimately fail with Socket operation on non-socket (os error 38). Because after all, it's not a socket.

@zerosnacks
Copy link
Member

This would CI fail due to the IPC path not being present.

If you have an example that cannot be ran (see #31) you can update the filter applied in the CI here:

export examples="$(
cargo run --example 2>&1 \
| grep -E '^ ' \
| grep -v \
-e 'trezor_signer' \
-e 'ledger_signer' \
-e 'yubi_signer' \
-e 'ipc' \
-e 'ws' \
-e 'ws_auth' \
| xargs -n1 echo
)"
and here:
# Get the list of runable examples
export examples="$(
cargo run --example 2>&1 \
| grep -E '^ ' \
| grep -v \
-e 'trezor_signer' \
-e 'ledger_signer' \
-e 'yubi_signer' \
-e 'ipc' \
-e 'ws' \
-e 'ws_auth' \
| xargs -n1 echo
)"


// Instantiate a HTTP transport provider by passing the http endpoint url
let http_provider =
RootProvider::<Ethereum, BoxTransport>::connect_builtin(http.as_str()).await?;
Copy link
Member

Choose a reason for hiding this comment

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

More of a general comment and a personal opinion but I'm not a fan of the connect_builtin name. I don't think it is particularly clear to users and sounds like an internal method rather than the equivalent of a default.

Copy link
Member

Choose a reason for hiding this comment

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

Possibly beyond the scope of the intended PR but I would also prefer to see the parameter being strongly typed (Url-like) instead of a &str

Comment on lines 27 to 30
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "68952c0" }

alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "68952c0" }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "68952c0" }
Copy link
Member

Choose a reason for hiding this comment

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

Why are these required and not accessible on the alloy namespace?

Copy link
Member Author

@yash-atreya yash-atreya Mar 28, 2024

Choose a reason for hiding this comment

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

Compiler doesn't the recognize them as the same type when used with alloy-provider (w/o the namespace). Ref: #26

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see, then this should be resolved once that upstream PR has been merged

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, pending CI filter

@yash-atreya yash-atreya merged commit e87fcf5 into main Mar 29, 2024
4 checks passed
@zerosnacks zerosnacks deleted the connect_builtin branch March 29, 2024 13:06
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.

4 participants