Skip to content

pallet-migrations: fix index access for singluar migrations#5695

Merged
ggwpez merged 4 commits intomasterfrom
oty-pallet-migrations-fix
Sep 13, 2024
Merged

pallet-migrations: fix index access for singluar migrations#5695
ggwpez merged 4 commits intomasterfrom
oty-pallet-migrations-fix

Conversation

@ggwpez
Copy link
Copy Markdown
Member

@ggwpez ggwpez commented Sep 12, 2024

Discovered a bug in the migrations pallet while debugging paritytech/try-runtime-cli#90.
🚨 This can lead to your chain getting stuck. It happens when a single MBM is configured. Having no or more than one MBM will circumvent the issue.

Changes:

  • Check len of the tuple before accessing its nth_id
  • Make nth_id return None on unary tuples and n>0

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez ggwpez requested a review from a team as a code owner September 12, 2024 16:10
}

fn nth_id(_n: u32) -> Option<Vec<u8>> {
Some(T::id().encode())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the actual issue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and this was not overwritten for a single migration that's not part of a tuple, right?

@ggwpez
Copy link
Copy Markdown
Member Author

ggwpez commented Sep 12, 2024

/cmd prdoc --pr 5695 --bump patch --audience "Runtime Dev"

@ggwpez ggwpez added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Sep 12, 2024
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@paritytech paritytech deleted a comment from github-actions bot Sep 12, 2024
@paritytech paritytech deleted a comment from github-actions bot Sep 12, 2024
}

fn nth_id(_n: u32) -> Option<Vec<u8>> {
Some(T::id().encode())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and this was not overwritten for a single migration that's not part of a tuple, right?

@ggwpez ggwpez enabled auto-merge September 13, 2024 10:54
@ggwpez ggwpez added this pull request to the merge queue Sep 13, 2024
Merged via the queue into master with commit 0136463 Sep 13, 2024
@ggwpez ggwpez deleted the oty-pallet-migrations-fix branch September 13, 2024 12:17
github-actions bot pushed a commit that referenced this pull request Sep 13, 2024
Discovered a bug in the migrations pallet while debugging
paritytech/try-runtime-cli#90.
It only occurs when a single MBM is configured - hence it did not happen
when Ajuna Network tried it...

Changes:
- Check len of the tuple before accessing its nth_id
- Make nth_id return `None` on unary tuples and n>0

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
(cherry picked from commit 0136463)
github-actions bot pushed a commit that referenced this pull request Sep 13, 2024
Discovered a bug in the migrations pallet while debugging
paritytech/try-runtime-cli#90.
It only occurs when a single MBM is configured - hence it did not happen
when Ajuna Network tried it...

Changes:
- Check len of the tuple before accessing its nth_id
- Make nth_id return `None` on unary tuples and n>0

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
(cherry picked from commit 0136463)
github-actions bot pushed a commit that referenced this pull request Sep 16, 2024
Discovered a bug in the migrations pallet while debugging
paritytech/try-runtime-cli#90.
It only occurs when a single MBM is configured - hence it did not happen
when Ajuna Network tried it...

Changes:
- Check len of the tuple before accessing its nth_id
- Make nth_id return `None` on unary tuples and n>0

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
(cherry picked from commit 0136463)
@paritytech-cmd-bot-polkadot-sdk
Copy link
Copy Markdown
Contributor

Git push to origin failed for stable2407 with exitcode 1

github-actions bot pushed a commit that referenced this pull request Sep 16, 2024
Discovered a bug in the migrations pallet while debugging
paritytech/try-runtime-cli#90.
It only occurs when a single MBM is configured - hence it did not happen
when Ajuna Network tried it...

Changes:
- Check len of the tuple before accessing its nth_id
- Make nth_id return `None` on unary tuples and n>0

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
(cherry picked from commit 0136463)
@paritytech-cmd-bot-polkadot-sdk
Copy link
Copy Markdown
Contributor

Successfully created backport PR for stable2409:

github-actions bot pushed a commit that referenced this pull request Sep 16, 2024
Discovered a bug in the migrations pallet while debugging
paritytech/try-runtime-cli#90.
It only occurs when a single MBM is configured - hence it did not happen
when Ajuna Network tried it...

Changes:
- Check len of the tuple before accessing its nth_id
- Make nth_id return `None` on unary tuples and n>0

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: ggwpez <ggwpez@users.noreply.github.com>
(cherry picked from commit 0136463)
@paritytech-cmd-bot-polkadot-sdk
Copy link
Copy Markdown
Contributor

Successfully created backport PR for stable2407:

@paritytech-cmd-bot-polkadot-sdk
Copy link
Copy Markdown
Contributor

Git push to origin failed for stable2409 with exitcode 1

ggwpez added a commit that referenced this pull request Sep 16, 2024
Backport #5695 into `stable2409` from ggwpez.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
ggwpez added a commit that referenced this pull request Sep 17, 2024
Backport #5695 into `stable2407` from ggwpez.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T1-FRAME This PR/Issue is related to core FRAME, the framework.

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants