-
Notifications
You must be signed in to change notification settings - Fork 768
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
rpc: bump jsonrpsee v0.22 and fix race in rpc v2 chain_head
#3230
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewrite rpc metrics as JSON-RPC middleware
|
||
//! JSON-RPC specific middleware. | ||
|
||
pub mod metrics; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to add rate-limit middleware here as well but I'll do it in another PR and that's why I introduced a module for it
/// Number of Websocket sessions closed. | ||
ws_sessions_closed: Option<Counter<U64>>, | ||
/// Histogram over RPC websocket sessions. | ||
ws_sessions_time: HistogramVec, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this because I think it's useful to know the connection duration.
.enable_ws_ping( | ||
PingConfig::new() | ||
.ping_interval(Duration::from_secs(30)) | ||
.inactive_limit(Duration::from_secs(50)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior before this release was: the server sends ping frames every 30 seconds and doesn't care about pong frames.
Now the behavior is: the server sends ping frames every 30 seconds and expects at least one pong frame (or event message -- correctly me if i'm wrong here) in at most 50 seconds.
Should we bump this to 60 seconds just to be sure? Not entirely convinced myself, since most RPC apis provide a response almost immediately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add an API for folks to configure it themselves it in a follow-up PR but I added also that
the ping/pong must be missed three times.
I think that's a reasonable limit but better to write some breaking stuff in the CHANGELOG/prdoc for it
}; | ||
|
||
let make_service = make_service_fn(move |_conn: &AddrStream| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, this will go away in the next release (when bringing hyper up to date); we could then think about how to tackle this best; just to simplify a bit this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not a big deal, it's just the we have launch the event loop and handle socket.accept() ourselves then upgrade it to a towerService
} | ||
} | ||
|
||
/// Response future for metrics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom future to avoid boxing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The CI pipeline was cancelled due to failure one of the required jobs. |
…tech#3230) Close paritytech#2992 Breaking changes: - rpc server grafana metric `substrate_rpc_requests_started` is removed (not possible to implement anymore) - rpc server grafana metric `substrate_rpc_requests_finished` is removed (not possible to implement anymore) - rpc server ws ping/pong not ACK:ed within 30 seconds more than three times then the connection will be closed Added - rpc server grafana metric `substrate_rpc_sessions_time` is added to get the duration for each websocket session
Close #2992
Breaking changes:
substrate_rpc_requests_started
is removed (not possible to implement anymore)substrate_rpc_requests_finished
is removed (not possible to implement anymore)Added
substrate_rpc_sessions_time
is added to get the duration for each websocket session