Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

fix: Enforce http2, fix dfx local server not supported by ic-rosetta-api #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TerrorJack
Copy link

When dfx starts a local replica, it automatically starts icx-proxy to reroute the incoming requests. It uses hyper for http logic, and hyper doesn't properly support http1/http2 dual stack. The main ic repo assumes http2 in a lot of places, one consequence of that is ic-rosetta-api being unable to connect to the local replica started by dfx. This patch fixes that problem.

See ticket https://dfinity.atlassian.net/browse/ROSETTA1-162 for more context.

@@ -555,7 +557,7 @@ fn main() -> Result<(), Box<dyn Error>> {
.enable_all()
.build()?;
runtime.block_on(async {
let server = Server::bind(&opts.address).serve(service);
let server = Server::bind(&opts.address).http2_only(true).serve(service);
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird, the doc claims that http2 is supported by default:

A listening HTTP server that accepts connections in both HTTP1 and HTTP2 by default.
-- https://docs.rs/hyper/0.14.13/hyper/server/struct.Server.html

I think strictly requiring HTTP2 here might break quite a few clients

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of directly setting this to true, can you add a new field to Opts, which defaults to false to keep the current default behavior?

Copy link
Author

Choose a reason for hiding this comment

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

The problem here is icx-proxy is often invoked indirectly by dfx, so we don't get to control the command line options passed to it. Would you accept an environment variable configuration to turn this on?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just change all the places where dfx runs icx-proxy (i.e. add the flag to those calls)?

Choose a reason for hiding this comment

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

Adding a command-line option to icx-proxy, and adding parameters to dfx start and dfx bootstrap to control it, sounds like a better option.

@roman-kashitsyn
Copy link
Contributor

roman-kashitsyn commented Jan 10, 2022

@TerrorJack, I believe you need to change the PR title to conform to the guideline (fix: ...).
I don't have the permissions to change it myself.
Please also add some maintainers as reviewers, e.g., @eric-swanson, I don't have permission to merge this PR.

@Daniel-Bloom-dfinity Daniel-Bloom-dfinity changed the title Enforce http2, fix dfx local server not supported by ic-rosetta-api fix: Enforce http2, fix dfx local server not supported by ic-rosetta-api Jan 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants