Skip to content

Commit 19307dd

Browse files
Fix runtime migrations check (#10570)
- On the scheduled run only download the snapshot and not try to run the migration checks - The job should fail when one of the migration checks was cancelled (because of timeout for example) - Increase the timeout to 120 min, because sometimes it is slower to download the snapshot Should be merged after: #10566 --------- Co-authored-by: Evgeny Snitko <[email protected]>
1 parent 23cac32 commit 19307dd

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.github/workflows/check-runtime-migration.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
if: ${{ needs.preflight.outputs.changes_rust }}
3232
# We need to set this to rather long to allow the snapshot to be created, but the average time
3333
# should be much lower.
34-
timeout-minutes: 60
34+
timeout-minutes: 120
3535
needs: [preflight]
3636
container:
3737
image: ${{ needs.preflight.outputs.IMAGE }}
@@ -106,12 +106,14 @@ jobs:
106106
./try-runtime create-snapshot --uri ${{ matrix.uri }} snapshot.raw
107107
108108
- name: Build Runtime
109+
if: ${{ github.event_name != 'schedule' }}
109110
id: required1
110111
run: |
111112
echo "---------- Building ${{ matrix.package }} runtime ----------"
112113
forklift cargo build --release --locked -p ${{ matrix.package }} --features try-runtime -q
113114
114115
- name: Run Check
116+
if: ${{ github.event_name != 'schedule' }}
115117
id: required2
116118
run: |
117119
echo "Running ${{ matrix.network }} runtime migration check"
@@ -124,7 +126,7 @@ jobs:
124126
sleep 5
125127
126128
- name: Stop all workflows if failed
127-
if: ${{ failure() && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
129+
if: ${{ failure() && github.event_name != 'schedule' && (steps.required1.conclusion == 'failure' || steps.required2.conclusion == 'failure') }}
128130
uses: ./.github/actions/workflow-stopper
129131
with:
130132
app-id: ${{ secrets.WORKFLOW_STOPPER_RUNNER_APP_ID }}
@@ -137,7 +139,7 @@ jobs:
137139
name: All runtime migrations passed
138140
# If any new job gets added, be sure to add it to this array
139141
needs: [check-runtime-migration]
140-
if: always() && !cancelled()
142+
if: always() && !cancelled() && github.event_name != 'schedule'
141143
steps:
142144
- run: |
143145
tee resultfile <<< '${{ toJSON(needs) }}'

substrate/frame/assets/src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
20282028
);
20292029

20302030
let calculated_approvals = Approvals::<T, I>::iter_prefix((&asset_id,)).count() as u32;
2031-
ensure!(details.approvals == calculated_approvals, "Asset approvals count mismatch");
2031+
2032+
if details.approvals != calculated_approvals {
2033+
log::error!(
2034+
"Asset {asset_id:?} approvals count mismatch: calculated {calculated_approvals} vs expected {}",
2035+
details.approvals,
2036+
);
2037+
2038+
return Err("Asset approvals count mismatch".into())
2039+
}
20322040
}
20332041
Ok(())
20342042
}

substrate/frame/assets/src/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,13 @@ fn transfer_approved_all_funds() {
355355
Balances::make_free_balance_be(&1, 2);
356356
assert_ok!(Assets::approve_transfer(RuntimeOrigin::signed(1), 0, 2, 50));
357357
assert_eq!(Asset::<Test>::get(0).unwrap().approvals, 1);
358+
assert!(Approvals::<Test>::contains_key((0, 1, 2)));
358359
assert_eq!(Balances::reserved_balance(&1), 1);
359360

360361
// transfer the full amount, which should trigger auto-cleanup
361362
assert_ok!(Assets::transfer_approved(RuntimeOrigin::signed(2), 0, 1, 3, 50));
362363
assert_eq!(Asset::<Test>::get(0).unwrap().approvals, 0);
364+
assert!(!Approvals::<Test>::contains_key((0, 1, 2)));
363365
assert_eq!(Assets::balance(0, 1), 50);
364366
assert_eq!(Assets::balance(0, 3), 50);
365367
assert_eq!(Balances::reserved_balance(&1), 0);

0 commit comments

Comments
 (0)