Skip to content

Node can send multiple same block requests while syncing from other nodes #531

@liuchengxu

Description

@liuchengxu

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

Let's say node A is trying to sync from B, the block requests from A are not protected from sending the same block request multiple times, which can cause the B to mark A as a bad node sending the same requests over and over again and then send back an error result which will be considered as Refused on the side A.

From node_A.log, you can see the same block request was sent dozens of times.

$ cat node_A.log | grep 'New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, .* BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }'
2022-06-22 16:36:32.202 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150023, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:36:42.787 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150024, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:36:54.317 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150026, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:37:04.543 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150030, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:37:15.808 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150030, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:37:28.596 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150032, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:37:40.292 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150034, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:37:50.816 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150035, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:38:02.211 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150036, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:38:14.312 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150041, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:38:26.220 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150044, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:38:36.866 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150046, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:38:48.553 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150046, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:39:00.230 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150046, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:39:11.379 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150048, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
2022-06-22 16:39:22.507 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150050, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }
.....

If I read it correctly, once the request was processed for the first time, with 2 more same requests, the reputation would change, Err(()) will be returned, on the side of node A, Err(()) will be converted as RequestFailure::Refused. Those two nodes will disconnect from each other afterwards.

https://github.com/paritytech/substrate/blob/3c99545cb062fbc56b84e2f3e44def3b933123cd/client/network/sync/src/block_request_handler.rs#L216

https://github.com/paritytech/substrate/blob/3c99545cb062fbc56b84e2f3e44def3b933123cd/client/network/src/request_responses.rs#L662

2022-06-22 16:39:46.896 TRACE tokio-runtime-worker sync: [PrimaryChain] New block request for 12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP, (best:150056, common:2918) BlockRequest { id: 0, fields: HEADER | BODY | JUSTIFICATION, from: Number(2982), to: None, direction: Descending, max: Some(64) }    
2022-06-22 16:39:47.438 DEBUG tokio-runtime-worker sync: [PrimaryChain] Request to peer PeerId("12D3KooWMkto1n3dJ7mu8zUiokrjkwcUzEveeyyrk9gJeLNQ5PWP") failed: Refused.

Steps to reproduce

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress 🛠

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions