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

[FEATURE] Use rpc proxy #747

Merged
merged 3 commits into from
Jul 7, 2021
Merged

[FEATURE] Use rpc proxy #747

merged 3 commits into from
Jul 7, 2021

Conversation

KonradStaniec
Copy link
Contributor

Proxy all rpc call to provided uri

@KonradStaniec KonradStaniec requested a review from kdeme July 6, 2021 10:38
fluffy/conf.nim Outdated
@@ -14,6 +14,7 @@ import
const
DefaultListenAddress* = (static ValidIpAddress.init("0.0.0.0"))
DefaultAdminListenAddress* = (static ValidIpAddress.init("127.0.0.1"))
DefaultProxyAddrss* = (static "http:https://127.0.0.1:8546")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
DefaultProxyAddrss* = (static "http:https://127.0.0.1:8546")
DefaultProxyAddress* = (static "http:https://127.0.0.1:8546")

@@ -92,6 +93,13 @@ type
desc: "if provided, enables getting data from bridge node"
name: "bridge-client-uri" .}: Option[string]

# it makes little sense to have default value here in final release, but until then
Copy link
Contributor

Choose a reason for hiding this comment

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

The http:https://127.0.0.1:8546 is fine I think for now. (Either that or 8545 but then we have to change our own local port).

Eventually the proxy should become optional (or might be removed completely), and should be default disabled, but only after we have implemented (most) rpc calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep that was my thinking about it, this is just like additional wheels in bike and ultimatly we may get rid of it

rpcHttpServer.installEthApiHandlers()
rpcHttpServer.start()
let ta = initTAddress(config.rpcAddress, config.rpcPort)
var rpcHttpServerWithProxy = newRpcHttpProxy([$ta])
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok for now, but we should get a newRpcHttpProxy which takes in the TransportAddress

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will make a quick pr in upstream repo to add additional constructor

rpcHttpServerWithProxy.installEthApiHandlers()
# TODO for now we can only proxy to local node (or remote one without ssl) to make it possible
# to call infura https://github.com/status-im/nim-json-rpc/pull/101 needs to get merged for http client to support https/
waitFor rpcHttpServerWithProxy.start(config.proxyUri)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could use some further error handling eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, for now as nothing is implemented it makes little sense to start without without working proxy, in the future when there will some working methods, it will be better to catch error here and log thats fluffy is starting without working proxy so some methods may not work as intended.

@KonradStaniec KonradStaniec merged commit 1c5c2cb into master Jul 7, 2021
@KonradStaniec KonradStaniec deleted the feature/use-rpc-proxy branch July 7, 2021 12:13
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.

None yet

2 participants