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

server/eth: Allow geth connections using http and ws #2047

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

martonp
Copy link
Contributor

@martonp martonp commented Jan 12, 2023

In order to test the connection using ws, in the eth backend's
rpc_harness_test, the delta node (the only one that has enabled
http and ws) is used to send funds instead of the alpha node.

The rpc_harness_test had pre-existing issues:

  • panicing due to registering the test token twice
  • incorrectly checking the difference in token balance

These issues are now fixed.

Closes #2026

server/asset/eth/rpcclient.go Outdated Show resolved Hide resolved
server/asset/eth/rpcclient_harness_test.go Show resolved Hide resolved
@@ -55,7 +55,7 @@ func CheckAPIModules(c *rpc.Client, endpoint string, log dex.Logger, reqModules
for v := range reqModulesMap {
reqs = append(reqs, v)
}
return fmt.Errorf("needed apis not present: %v", strings.Join(reqs, " "))
return fmt.Errorf("needed apis not present: %v. some APIs may only be available over websocket and not http.", strings.Join(reqs, " "))
Copy link
Member

@chappjc chappjc Jan 12, 2023

Choose a reason for hiding this comment

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

I'm curious if there was a specific case where you found ws had it but not http. I assume that's solvable with the --http.api= flag, unless you were referring to a third-party RPC provider.

I'm afraid we may have to go with the "dumbed down" balance check #2020 because I haven't seen any RPC providers (other than geth itself) that provide txpool. e.g. https://docs.alchemy.com/reference/ethereum-api-faq#what-methods-does-alchemy-support-for-the-ethereum-api, https://docs.blastapi.io/blast-documentation/apis-documentation/ethereum
Or we could at least fall back to that method when txpool is not available. Not needed for this PR, but have been thinking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right, I just had to add -http.api.

@chappjc
Copy link
Member

chappjc commented Jan 12, 2023

Good stuff. dex-test:

[INF] DEX: Starting asset backend "eth"...
[DBG] ASSET[eth][ETH]: dialing endpoint: ws://127.0.0.1:8546
[DBG] ASSET[eth][ETH]: API endpoints supported by ws://127.0.0.1:8546: admin:1.0 eth:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0

In order to test the connection using ws, in the eth backend's
rpc_harness_test, the delta node (the only one that has enabled
http and ws) is used to send funds instead of the alpha node.

The rpc_harness_test had pre-existing issues:
- panicing due to registering the test token twice
- incorrectly checking the difference in token balance.
These issues are now fixed.
@chappjc chappjc merged commit cc224f8 into decred:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth: add plain http/ws support
2 participants