Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FRAME] MQ processor should be transactional #5198

Merged
merged 17 commits into from
Sep 2, 2024

Conversation

dharjeezy
Copy link
Contributor

@dharjeezy dharjeezy commented Jul 31, 2024

closes #2441

Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW

@dharjeezy dharjeezy requested a review from a team as a code owner July 31, 2024 11:42
@dharjeezy dharjeezy marked this pull request as draft July 31, 2024 11:42
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 2/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/6871889

@dharjeezy dharjeezy marked this pull request as ready for review August 4, 2024 06:49
@paritytech-review-bot paritytech-review-bot bot requested a review from a team August 4, 2024 06:50
@@ -164,6 +164,7 @@ impl ProcessMessage for RecordingMessageProcessor {
meter: &mut WeightMeter,
_id: &mut [u8; 32],
) -> Result<bool, ProcessMessageError> {
sp_io::storage::set(b"transactional_storage", &vec![1, 2, 3]);
Copy link
Member

@ggwpez ggwpez Aug 4, 2024

Choose a reason for hiding this comment

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

The mocked process supports callbacks - no need to hard code it here.

Check out the tests that use it:

Callback::set(Box::new(|_, _| {
	// whatever youwant
}));


crates:
- name: pallet-message-queue
bump: patch
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bump: patch
bump: major

Its a logical breaking change, better safe than sorry for these things.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@paritytech-review-bot paritytech-review-bot bot requested a review from a team August 26, 2024 10:14

let transaction = match transaction {
Ok(result) => result,
_ => unreachable!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

With current storage::with_transaction implementation, this is indeed unreachable, but if the internals of that function change, this will crash the runtime.

I know, highly unlikely, but still I would prefer to:

  • debug_assert!() to have it crash in tests if the invariant is ever broken,
  • return some error MessageExecutionStatus in prod without crashing.

Copy link
Member

Choose a reason for hiding this comment

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

Yea it should be defensive and then just return an error or so. Having panics in the runtime is never good.

Comment on lines 2003 to 2011
#[test]
fn process_message_ok_false_keeps_storage_changes() {
// FAIL-CI TODO
}

#[test]
fn process_message_ok_true_keeps_storage_changes() {
// FAIL-CI TODO
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like these are the only missing pieces to get this in?

@dharjeezy dharjeezy requested review from athei and a team as code owners August 28, 2024 10:54
@paritytech-review-bot paritytech-review-bot bot requested a review from a team August 28, 2024 10:55
@dharjeezy dharjeezy force-pushed the dami/mq-transactional-processing branch from 30ed233 to d8201b1 Compare August 28, 2024 11:00
@dharjeezy dharjeezy requested a review from ggwpez August 28, 2024 11:04
title: "MQ processor should be transactional"

doc:
- audience: Runtime User
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- audience: Runtime User
- audience: [Runtime User, Runtime Dev]

doc:
- audience: Runtime User
description: |
Enforce transactional processing on pallet Message Queue Processor
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Enforce transactional processing on pallet Message Queue Processor
Enforce transactional processing on pallet Message Queue Processor.
Storage changes that were done while processing a message will now be rolled back
when the processing returns an error. `Ok(false)` will not revert, only `Err(_)`.


let transaction = match transaction {
Ok(result) => result,
_ => return MessageExecutionStatus::Unprocessable { permanent: false },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_ => return MessageExecutionStatus::Unprocessable { permanent: false },
_ => return MessageExecutionStatus::Unprocessable { permanent: true },

This should also use the defensive! macro to log an error since it is very much unexpected.

@paritytech-review-bot paritytech-review-bot bot requested a review from a team August 29, 2024 10:41
@ggwpez
Copy link
Member

ggwpez commented Aug 29, 2024

/tip small

@bkchr bkchr added the T2-pallets This PR/Issue is related to a particular pallet. label Sep 2, 2024
@bkchr bkchr enabled auto-merge September 2, 2024 19:37
@bkchr
Copy link
Member

bkchr commented Sep 2, 2024

/tip small

Copy link

@bkchr A referendum for a small (20 DOT) tip was successfully submitted for @dharjeezy (12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW on polkadot).

Referendum number: 1134.
tip

Copy link

The referendum has appeared on Polkassembly.

@bkchr bkchr added this pull request to the merge queue Sep 2, 2024
Merged via the queue into paritytech:master with commit f6eeca9 Sep 2, 2024
212 of 216 checks passed
x3c41a pushed a commit that referenced this pull request Sep 4, 2024
closes #2441

Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FRAME] MQ processor should be transactional
5 participants