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

Decrease request_timeout in builders to avoid panics #4267

Merged
merged 5 commits into from
Apr 24, 2024

Conversation

elmattic
Copy link
Contributor

@elmattic elmattic commented Apr 24, 2024

Summary of changes

Changes introduced in this pull request:

  • Decrease request_timeout value in WsClientBuilder and HttpClientBuilder to avoid panics (see logs below)

Rational:

We don't need to handle timeouts at the jsonrpsee client level since we shim our own timeouts during the call, but setting it to some max value seems unsafe.

Setting a 10s timeout and simulating a slow endpoint in forest daemon:

$ FOREST_RPC_DEFAULT_TIMEOUT=10 ./forest-tool api compare --lotus /ip4/127.0.0.1/tcp/1234/ws --forest /ip4/127.0.0.1/tcp/2345/ws forest_snapshot_calibnet_2024-04-19_height_1539740.forest.car.zst --filter EthChainId
Request dump: RpcRequest { method_name: "Filecoin.EthChainId", params: Null, result_type: PhantomData<serde_json::value::Value>, api_version: V1, timeout: 10s }
Request params JSON: null
Lotus response: "0x4cb2f"

| RPC Method          | Forest              | Lotus |
|---------------------|---------------------|-------|
| Filecoin.EthChainId | InternalServerError | Valid |
Error: Some tests failed

Reference issue to close (if applicable)

Closes

Other information and links

$ RUST_BACKTRACE=1 ./forest-tool api compare --lotus /ip4/127.0.0.1/tcp/1234/ws --forest /ip4/127.0.0.1/tcp/2345/ws forest_snapshot_calibnet_2024-04-19_height_1539740.forest.car.zst --filter EthChainId
thread 'tokio-runtime-worker' panicked at library/std/src/time.rs:417:33:
overflow when adding duration to instant

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

@elmattic elmattic changed the title Remove request_timeout in builders Decrease request_timeout in builders to avoid panics Apr 24, 2024
@elmattic elmattic marked this pull request as ready for review April 24, 2024 12:25
@elmattic elmattic requested a review from a team as a code owner April 24, 2024 12:25
@elmattic elmattic requested review from ruseinov and LesnyRumcajs and removed request for a team April 24, 2024 12:25
Copy link
Contributor

@ruseinov ruseinov left a comment

Choose a reason for hiding this comment

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

looks good.

nit: I'm still unsure what does // we handle timeouts ourselves comment mean, but it's perhaps out of scope anyway.

@elmattic
Copy link
Contributor Author

looks good.

nit: I'm still unsure what does // we handle timeouts ourselves comment mean, but it's perhaps out of scope anyway.

Check this code: https://github.com/ChainSafe/forest/blob/main/src/rpc/client.rs#L65-L97

@hanabi1224
Copy link
Contributor

overflow when adding duration to instant

This seems like a bug in upstream lib, should we PR a fix as well?

@elmattic elmattic added this pull request to the merge queue Apr 24, 2024
Merged via the queue into main with commit 805a921 Apr 24, 2024
27 checks passed
@elmattic elmattic deleted the elmattic/fix-url-client-timeout branch April 24, 2024 13:58
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

4 participants