-
Notifications
You must be signed in to change notification settings - Fork 710
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
network/sync: Panic on unexpected generic response protocol #6581
Comments
Warp request protocols and state requests protocols are initializing their handler supporting 2 protocol names:
They are supporting both We are only checking the new genesis-based format in chain sync |
This is fine, as the main protocol name is always used by substrate to refer to the protocol. Legacy protocol name is only used on the wire. |
Oki doki, thanks for the info 🙏 I believe in that case this is the proper fix: Looking over the litep2p code, we always provide the negotiated protocol (regardless if it is fallback or main): let handle1 = ConfigBuilder::new(ProtocolName::from("/protocol/1/improved"))
.with_max_size(1024usize)
.with_fallback_names(vec![ProtocolName::from("/protocol/1")])
.build();
let handle2 = handle2) = RequestResponseConfig::new(
ProtocolName::from("/protocol/1") ...;
handle1
.send_request(peer2, vec![1, 3, 3, 7], DialOptions::Reject);
handle2.next().await.unwrap(),
RequestResponseEvent::RequestReceived {
peer: peer1,
fallback: None, ...):
handle2.send_response(request_id, vec![1, 3, 3, 8]);
assert_eq!(
handle1.next().await.unwrap(),
RequestResponseEvent::ResponseReceived {
peer: peer2,
request_id,
response: vec![1, 3, 3, 8],
fallback: Some(ProtocolName::from("/protocol/1")),
}
); Step 1: Initialization
Step 2: handle 1 -> handle 2 request
Step3: handle 1 receives message for fallback
Then into substrate, we parse the received requests as follows: polkadot-sdk/substrate/client/network/src/litep2p/shim/request_response/mod.rs Lines 528 to 530 in 7c5224c
And we forward the protocol fallback if any:
|
It turned out this is only the case for libp2p network backend. The state of things in libp2p/litep2p network backends is explained in detail in this comment: #6603 (comment) |
Request responses are initialized with a main protocol name, and optional protocol names as a fallback. Running litep2p in kusama as a validator has surfaced a `debug_asserts` coming from the sync component: https://github.com/paritytech/polkadot-sdk/blob/3906c578c96d97a8a099a4bdac4685acbe375a7c/substrate/client/network/sync/src/strategy/chain_sync.rs#L640-L646 The issue is that we initiate a request-response over the main protocol name `/genesis/sync/2` but receive a response over the legacy procotol `ksm/sync/2`. This behavior is correct because litep2p propagates to the higher levels the protocol that responded. In contrast, libp2p provides the main protocol name regardless of negotiating a legacy protocol. Because of this, higher level components assume that only the main protocol name will respond. To not break this assumption, this PR alings litep2p shim layer with the libp2p behavior. Closes: #6581 --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Dmitry Markin <[email protected]>
Request responses are initialized with a main protocol name, and optional protocol names as a fallback. Running litep2p in kusama as a validator has surfaced a `debug_asserts` coming from the sync component: https://github.com/paritytech/polkadot-sdk/blob/3906c578c96d97a8a099a4bdac4685acbe375a7c/substrate/client/network/sync/src/strategy/chain_sync.rs#L640-L646 The issue is that we initiate a request-response over the main protocol name `/genesis/sync/2` but receive a response over the legacy procotol `ksm/sync/2`. This behavior is correct because litep2p propagates to the higher levels the protocol that responded. In contrast, libp2p provides the main protocol name regardless of negotiating a legacy protocol. Because of this, higher level components assume that only the main protocol name will respond. To not break this assumption, this PR alings litep2p shim layer with the libp2p behavior. Closes: #6581 --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Dmitry Markin <[email protected]> (cherry picked from commit 2a0b268)
Request responses are initialized with a main protocol name, and optional protocol names as a fallback. Running litep2p in kusama as a validator has surfaced a `debug_asserts` coming from the sync component: https://github.com/paritytech/polkadot-sdk/blob/3906c578c96d97a8a099a4bdac4685acbe375a7c/substrate/client/network/sync/src/strategy/chain_sync.rs#L640-L646 The issue is that we initiate a request-response over the main protocol name `/genesis/sync/2` but receive a response over the legacy procotol `ksm/sync/2`. This behavior is correct because litep2p propagates to the higher levels the protocol that responded. In contrast, libp2p provides the main protocol name regardless of negotiating a legacy protocol. Because of this, higher level components assume that only the main protocol name will respond. To not break this assumption, this PR alings litep2p shim layer with the libp2p behavior. Closes: #6581 --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Dmitry Markin <[email protected]> (cherry picked from commit 2a0b268)
Request responses are initialized with a main protocol name, and optional protocol names as a fallback. Running litep2p in kusama as a validator has surfaced a `debug_asserts` coming from the sync component: https://github.com/paritytech/polkadot-sdk/blob/3906c578c96d97a8a099a4bdac4685acbe375a7c/substrate/client/network/sync/src/strategy/chain_sync.rs#L640-L646 The issue is that we initiate a request-response over the main protocol name `/genesis/sync/2` but receive a response over the legacy procotol `ksm/sync/2`. This behavior is correct because litep2p propagates to the higher levels the protocol that responded. In contrast, libp2p provides the main protocol name regardless of negotiating a legacy protocol. Because of this, higher level components assume that only the main protocol name will respond. To not break this assumption, this PR alings litep2p shim layer with the libp2p behavior. Closes: #6581 --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Dmitry Markin <[email protected]> (cherry picked from commit 2a0b268)
Kusama validator is panics on:
polkadot-sdk/substrate/client/network/sync/src/strategy/chain_sync.rs
Lines 640 to 646 in 3906c57
From the log line it looks like the sync engine no longer takes into account the legacy request-response protocol name.
Related PR:
Version deployed: version 1.16.1-ca8beaed148
Logs
Grafana link.
cc @paritytech/networking
The text was updated successfully, but these errors were encountered: