-
Notifications
You must be signed in to change notification settings - Fork 781
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
bkchr
merged 17 commits into
paritytech:master
from
dharjeezy:dami/mq-transactional-processing
Sep 2, 2024
+126
−22
Merged
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
fdaf250
make process_message transactional
dharjeezy f2bffb7
fmt
dharjeezy 825c8e9
pr doc
dharjeezy 970253f
unreachable match case
dharjeezy ca4ae3d
nit
dharjeezy e846db5
Merge branch 'master' into dami/mq-transactional-processing
dharjeezy 74f82f7
nit
dharjeezy cabe8d6
Merge remote-tracking branch 'origin/dami/mq-transactional-processing…
dharjeezy c692298
include test
dharjeezy 8b21cca
fmt
dharjeezy 53a579e
Merge branch 'master' into dami/mq-transactional-processing
dharjeezy d8201b1
Fix test
ggwpez 851c534
feedback on pr, more tests, and return an error instead of panicking
dharjeezy f60ac77
pr doc change
dharjeezy c9e259e
update doc
dharjeezy 8589b76
further updates
dharjeezy dee7b95
Merge branch 'master' into dami/mq-transactional-processing
bkchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,10 @@ | ||||||||||||
title: "MQ processor should be transactional" | ||||||||||||
|
||||||||||||
doc: | ||||||||||||
- audience: Runtime User | ||||||||||||
description: | | ||||||||||||
Enforce transactional processing on pallet Message Queue Processor | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
crates: | ||||||||||||
- name: pallet-message-queue | ||||||||||||
bump: major |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -225,7 +225,7 @@ use sp_arithmetic::traits::{BaseArithmetic, Unsigned}; | |||||
use sp_core::{defer, H256}; | ||||||
use sp_runtime::{ | ||||||
traits::{One, Zero}, | ||||||
SaturatedConversion, Saturating, | ||||||
SaturatedConversion, Saturating, TransactionOutcome, | ||||||
}; | ||||||
use sp_weights::WeightMeter; | ||||||
pub use weights::WeightInfo; | ||||||
|
@@ -1435,6 +1435,8 @@ impl<T: Config> Pallet<T> { | |||||
/// The base weight of this function needs to be accounted for by the caller. `weight` is the | ||||||
/// remaining weight to process the message. `overweight_limit` is the maximum weight that a | ||||||
/// message can ever consume. Messages above this limit are marked as permanently overweight. | ||||||
/// This process is also transactional, any form of error that occurs in processing a message | ||||||
/// causes storage changes to be rolled back. | ||||||
fn process_message_payload( | ||||||
origin: MessageOriginOf<T>, | ||||||
page_index: PageIndex, | ||||||
|
@@ -1447,7 +1449,22 @@ impl<T: Config> Pallet<T> { | |||||
use ProcessMessageError::*; | ||||||
let prev_consumed = meter.consumed(); | ||||||
|
||||||
match T::MessageProcessor::process_message(message, origin.clone(), meter, &mut id) { | ||||||
let transaction = | ||||||
storage::with_transaction(|| -> TransactionOutcome<Result<_, DispatchError>> { | ||||||
let res = | ||||||
T::MessageProcessor::process_message(message, origin.clone(), meter, &mut id); | ||||||
match &res { | ||||||
Ok(_) => TransactionOutcome::Commit(Ok(res)), | ||||||
Err(_) => TransactionOutcome::Rollback(Ok(res)), | ||||||
} | ||||||
}); | ||||||
|
||||||
let transaction = match transaction { | ||||||
Ok(result) => result, | ||||||
_ => return MessageExecutionStatus::Unprocessable { permanent: false }, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This should also use the |
||||||
}; | ||||||
|
||||||
match transaction { | ||||||
Err(Overweight(w)) if w.any_gt(overweight_limit) => { | ||||||
// Permanently overweight. | ||||||
Self::deposit_event(Event::<T>::OverweightEnqueued { | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.