Skip to content

Commit

Permalink
Merge branch 'master' into runtime-macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ggwpez authored Sep 21, 2024
2 parents 1bae546 + 6ff41dc commit c62289a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/paritytec
* [Introduction](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/index.html)
to each component of the Polkadot SDK: Substrate, FRAME, Cumulus, and XCM
* [Guides](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/index.html),
namely how to build your first FRAME pallet.
namely how to build your first FRAME pallet
* [Templates](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/templates/index.html)
for starting a new project.
* Other Resources:
for starting a new project
* Other resources:
* [Polkadot Wiki -> Build](https://wiki.polkadot.network/docs/build-guide)

## 🚀 Releases

<!-- markdownlint-disable-next-line MD013 -->
![Current Stable Release](https://raw.githubusercontent.com/paritytech/release-registry/main/badges/polkadot-sdk-latest.svg)&nbsp;&nbsp;![Next Stable Release](https://raw.githubusercontent.com/paritytech/release-registry/main/badges/polkadot-sdk-next.svg)

The Polkadot-SDK is released every three months as a `stableYYMMDD` release. They are supported for
The Polkadot SDK is released every three months as a `stableYYMMDD` release. They are supported for
one year with patches. See the next upcoming versions in the [Release
Registry](https://github.com/paritytech/release-registry/).

Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_5774.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
title: Avoid unnecessary state reset of allowed_requests when no block requests are sent

doc:
- audience: Node Dev
description: |
Previously, the state of `allowed_requests` was always reset to the default
even if there were no new block requests. This could cause an edge case
because `peer_block_request()` will return early next time when there are no ongoing block requests.
This patch fixes it by checking whether block requests are empty before updating the state.

crates:
- name: sc-network-sync
bump: patch
16 changes: 13 additions & 3 deletions substrate/client/network/sync/src/strategy/chain_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl Metrics {
}
}

#[derive(Debug, Clone)]
enum AllowedRequests {
Some(HashSet<PeerId>),
All,
Expand Down Expand Up @@ -1714,13 +1715,14 @@ where
let best_queued = self.best_queued_number;
let client = &self.client;
let queue_blocks = &self.queue_blocks;
let allowed_requests = self.allowed_requests.take();
let allowed_requests = self.allowed_requests.clone();
let max_parallel = if is_major_syncing { 1 } else { self.max_parallel_downloads };
let max_blocks_per_request = self.max_blocks_per_request;
let gap_sync = &mut self.gap_sync;
let disconnected_peers = &mut self.disconnected_peers;
let metrics = self.metrics.as_ref();
self.peers
let requests = self
.peers
.iter_mut()
.filter_map(move |(&id, peer)| {
if !peer.state.is_available() ||
Expand Down Expand Up @@ -1819,7 +1821,15 @@ where
None
}
})
.collect()
.collect::<Vec<_>>();

// Clear the allowed_requests state when sending new block requests
// to prevent multiple inflight block requests from being issued.
if !requests.is_empty() {
self.allowed_requests.take();
}

requests
}

/// Get a state request scheduled by sync to be sent out (if any).
Expand Down

0 comments on commit c62289a

Please sign in to comment.