Skip to content

Commit 6b39516

Browse files
Merge branch 'master' into refactor-get_account_id_from_seed
2 parents c7b31af + d5b96e9 commit 6b39516

File tree

13 files changed

+104
-59
lines changed

13 files changed

+104
-59
lines changed

.github/workflows/check-cargo-check-runtimes.yml

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ jobs:
110110
- check-runtime-coretime
111111
- check-runtime-bridge-hubs
112112
- check-runtime-contracts
113-
- check-runtime-starters
114113
- check-runtime-testing
115114
if: always() && !cancelled()
116115
steps:

.github/workflows/check-labels.yml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
jobs:
1313
check-labels:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 10
1516
steps:
1617
- name: Check labels
1718
env:

.github/workflows/check-links.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ permissions:
2020
jobs:
2121
link-checker:
2222
runs-on: ubuntu-latest
23+
timeout-minutes: 10
2324
steps:
2425
- name: Restore lychee cache
2526
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v3.3.2 (7. Sep 2023)

.github/workflows/check-prdoc.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ env:
2121
jobs:
2222
check-prdoc:
2323
runs-on: ubuntu-latest
24+
timeout-minutes: 10
2425
if: github.event.pull_request.number != ''
2526
steps:
2627
- name: Checkout repo

.github/workflows/check-semver.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: ./.github/workflows/reusable-preflight.yml
1818
check-semver:
1919
runs-on: ubuntu-latest
20+
timeout-minutes: 90
2021
needs: [preflight]
2122
container:
2223
image: ${{ needs.preflight.outputs.IMAGE }}

.github/workflows/command-backport.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
# This trigger can be problematic, see: https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
55
# In our case it is fine since we only run it on merged Pull Requests and do not execute any of the repo code itself.
66
pull_request_target:
7-
types: [ closed, labeled ]
7+
types: [closed, labeled]
88

99
permissions:
1010
contents: write # so it can comment
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
script: |
6868
const pullNumbers = '${{ steps.backport.outputs.created_pull_numbers }}'.split(' ');
69-
69+
7070
for (const pullNumber of pullNumbers) {
7171
await github.rest.issues.addLabels({
7272
issue_number: parseInt(pullNumber),
@@ -84,7 +84,7 @@ jobs:
8484
script: |
8585
const pullNumbers = '${{ steps.backport.outputs.created_pull_numbers }}'.split(' ');
8686
const reviewer = '${{ github.event.pull_request.user.login }}';
87-
87+
8888
for (const pullNumber of pullNumbers) {
8989
await github.pulls.createReviewRequest({
9090
owner: context.repo.owner,

.github/workflows/docs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818

1919
test-doc:
2020
runs-on: ${{ needs.preflight.outputs.RUNNER }}
21+
timeout-minutes: 60
2122
needs: [preflight]
2223
container:
2324
image: ${{ needs.preflight.outputs.IMAGE }}
@@ -29,6 +30,7 @@ jobs:
2930

3031
build-rustdoc:
3132
runs-on: ${{ needs.preflight.outputs.RUNNER }}
33+
timeout-minutes: 40
3234
if: ${{ needs.preflight.outputs.changes_rust }}
3335
needs: [preflight]
3436
container:
+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This Workflow is not supposed to run in the paritytech/polkadot-sdk repo.
2-
# This Workflow is supposed to run only in the forks of the repo,
2+
# This Workflow is supposed to run only in the forks of the repo,
33
# paritytech-release/polkadot-sdk specifically,
44
# to automatically maintain the critical fork synced with the upstream.
55
# This Workflow should be always disabled in the paritytech/polkadot-sdk repo.
@@ -11,10 +11,10 @@ on:
1111
workflow_dispatch:
1212

1313
jobs:
14-
job_sync_branches:
15-
uses: paritytech-release/sync-workflows/.github/workflows/sync-with-upstream.yml@latest
16-
with:
17-
fork_writer_app_id: ${{ vars.UPSTREAM_CONTENT_SYNC_APP_ID}}
18-
fork_owner: ${{ vars.RELEASE_ORG}}
19-
secrets:
20-
fork_writer_app_key: ${{ secrets.UPSTREAM_CONTENT_SYNC_APP_KEY }}
14+
job_sync_branches:
15+
uses: paritytech-release/sync-workflows/.github/workflows/sync-with-upstream.yml@latest
16+
with:
17+
fork_writer_app_id: ${{ vars.UPSTREAM_CONTENT_SYNC_APP_ID}}
18+
fork_owner: ${{ vars.RELEASE_ORG}}
19+
secrets:
20+
fork_writer_app_key: ${{ secrets.UPSTREAM_CONTENT_SYNC_APP_KEY }}

.github/workflows/tests-misc.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ jobs:
178178
- name: script
179179
id: compare
180180
run: |
181+
if [ "${{ github.ref_name }}" = "master" ]; then
182+
echo -e "Exiting on master branch"
183+
exit 0
184+
fi
185+
181186
docker run --rm \
182187
-v $PWD/artifacts/master:/artifacts/master \
183188
-v $PWD/artifacts/current:/artifacts/current \
@@ -299,7 +304,7 @@ jobs:
299304
# name: hfuzz-${{ github.sha }}
300305

301306
cargo-check-each-crate:
302-
timeout-minutes: 140
307+
timeout-minutes: 70
303308
needs: [preflight]
304309
runs-on: ${{ needs.preflight.outputs.RUNNER }}
305310
if: ${{ needs.preflight.outputs.changes_rust }}

.gitlab/pipeline/zombienet.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
RUST_LOG: "info,zombienet_orchestrator=debug"
99
RUN_IN_CI: "1"
1010
KUBERNETES_CPU_REQUEST: "512m"
11-
KUBERNETES_MEMORY_REQUEST: "512M"
11+
KUBERNETES_MEMORY_REQUEST: "1Gi"
1212
timeout: 60m
1313

1414
include:

prdoc/pr_4803.prdoc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: Fix for issue #4762
5+
6+
doc:
7+
- audience: Runtime Dev
8+
description: |
9+
When the status of the queue is on_initialize, throw a defensive message and return weight of 0,
10+
however when status is on_idle, do not throw a defensive message, only return weight of 0
11+
12+
crates:
13+
- name: pallet-message-queue
14+
bump: patch

substrate/frame/message-queue/src/lib.rs

+65-44
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ pub mod pallet {
649649
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
650650
fn on_initialize(_n: BlockNumberFor<T>) -> Weight {
651651
if let Some(weight_limit) = T::ServiceWeight::get() {
652-
Self::service_queues(weight_limit)
652+
Self::service_queues_impl(weight_limit, ServiceQueuesContext::OnInitialize)
653653
} else {
654654
Weight::zero()
655655
}
@@ -658,7 +658,10 @@ pub mod pallet {
658658
fn on_idle(_n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight {
659659
if let Some(weight_limit) = T::IdleMaxServiceWeight::get() {
660660
// Make use of the remaining weight to process enqueued messages.
661-
Self::service_queues(weight_limit.min(remaining_weight))
661+
Self::service_queues_impl(
662+
weight_limit.min(remaining_weight),
663+
ServiceQueuesContext::OnIdle,
664+
)
662665
} else {
663666
Weight::zero()
664667
}
@@ -777,6 +780,18 @@ enum MessageExecutionStatus {
777780
StackLimitReached,
778781
}
779782

783+
/// The context to pass to [`Pallet::service_queues_impl`] through on_idle and on_initialize hooks
784+
/// We don't want to throw the defensive message if called from on_idle hook
785+
#[derive(PartialEq)]
786+
enum ServiceQueuesContext {
787+
/// Context of on_idle hook.
788+
OnIdle,
789+
/// Context of on_initialize hook.
790+
OnInitialize,
791+
/// Context `service_queues` trait function.
792+
ServiceQueues,
793+
}
794+
780795
impl<T: Config> Pallet<T> {
781796
/// Knit `origin` into the ready ring right at the end.
782797
///
@@ -1511,6 +1526,53 @@ impl<T: Config> Pallet<T> {
15111526
},
15121527
}
15131528
}
1529+
1530+
fn service_queues_impl(weight_limit: Weight, context: ServiceQueuesContext) -> Weight {
1531+
let mut weight = WeightMeter::with_limit(weight_limit);
1532+
1533+
// Get the maximum weight that processing a single message may take:
1534+
let max_weight = Self::max_message_weight(weight_limit).unwrap_or_else(|| {
1535+
if matches!(context, ServiceQueuesContext::OnInitialize) {
1536+
defensive!("Not enough weight to service a single message.");
1537+
}
1538+
Weight::zero()
1539+
});
1540+
1541+
match with_service_mutex(|| {
1542+
let mut next = match Self::bump_service_head(&mut weight) {
1543+
Some(h) => h,
1544+
None => return weight.consumed(),
1545+
};
1546+
// The last queue that did not make any progress.
1547+
// The loop aborts as soon as it arrives at this queue again without making any progress
1548+
// on other queues in between.
1549+
let mut last_no_progress = None;
1550+
1551+
loop {
1552+
let (progressed, n) = Self::service_queue(next.clone(), &mut weight, max_weight);
1553+
next = match n {
1554+
Some(n) =>
1555+
if !progressed {
1556+
if last_no_progress == Some(n.clone()) {
1557+
break
1558+
}
1559+
if last_no_progress.is_none() {
1560+
last_no_progress = Some(next.clone())
1561+
}
1562+
n
1563+
} else {
1564+
last_no_progress = None;
1565+
n
1566+
},
1567+
None => break,
1568+
}
1569+
}
1570+
weight.consumed()
1571+
}) {
1572+
Err(()) => weight.consumed(),
1573+
Ok(w) => w,
1574+
}
1575+
}
15141576
}
15151577

15161578
/// Run a closure that errors on re-entrance. Meant to be used by anything that services queues.
@@ -1580,48 +1642,7 @@ impl<T: Config> ServiceQueues for Pallet<T> {
15801642
type OverweightMessageAddress = (MessageOriginOf<T>, PageIndex, T::Size);
15811643

15821644
fn service_queues(weight_limit: Weight) -> Weight {
1583-
let mut weight = WeightMeter::with_limit(weight_limit);
1584-
1585-
// Get the maximum weight that processing a single message may take:
1586-
let max_weight = Self::max_message_weight(weight_limit).unwrap_or_else(|| {
1587-
defensive!("Not enough weight to service a single message.");
1588-
Weight::zero()
1589-
});
1590-
1591-
match with_service_mutex(|| {
1592-
let mut next = match Self::bump_service_head(&mut weight) {
1593-
Some(h) => h,
1594-
None => return weight.consumed(),
1595-
};
1596-
// The last queue that did not make any progress.
1597-
// The loop aborts as soon as it arrives at this queue again without making any progress
1598-
// on other queues in between.
1599-
let mut last_no_progress = None;
1600-
1601-
loop {
1602-
let (progressed, n) = Self::service_queue(next.clone(), &mut weight, max_weight);
1603-
next = match n {
1604-
Some(n) =>
1605-
if !progressed {
1606-
if last_no_progress == Some(n.clone()) {
1607-
break
1608-
}
1609-
if last_no_progress.is_none() {
1610-
last_no_progress = Some(next.clone())
1611-
}
1612-
n
1613-
} else {
1614-
last_no_progress = None;
1615-
n
1616-
},
1617-
None => break,
1618-
}
1619-
}
1620-
weight.consumed()
1621-
}) {
1622-
Err(()) => weight.consumed(),
1623-
Ok(w) => w,
1624-
}
1645+
Self::service_queues_impl(weight_limit, ServiceQueuesContext::ServiceQueues)
16251646
}
16261647

16271648
/// Execute a single overweight message.

substrate/frame/message-queue/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ fn service_queues_low_weight_defensive() {
279279
assert!(MessageQueue::do_integrity_test().is_err());
280280

281281
MessageQueue::enqueue_message(msg("weight=0"), Here);
282-
MessageQueue::service_queues(104.into_weight());
282+
MessageQueue::service_queues_impl(104.into_weight(), ServiceQueuesContext::OnInitialize);
283283
});
284284
}
285285

0 commit comments

Comments
 (0)