-
Notifications
You must be signed in to change notification settings - Fork 1.2k
CheckOnlySudoAccount: Provide some tags
#7838
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
Changes from 5 commits
dccf002
1904e0b
4d63c36
8688eb2
87043d7
58de5fc
91fecc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: '`CheckOnlySudoAccount`: Provide some tags' | ||
| doc: | ||
| - audience: Runtime User | ||
| description: Let `CheckOnlySudoAccount` provide some tags to make the tx pool happy. | ||
| crates: | ||
| - name: pallet-sudo | ||
| bump: patch |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||
| // limitations under the License. | ||||||
|
|
||||||
| use crate::{Config, Key}; | ||||||
| use alloc::vec; | ||||||
| use codec::{Decode, DecodeWithMemTracking, Encode}; | ||||||
| use core::{fmt, marker::PhantomData}; | ||||||
| use frame_support::{dispatch::DispatchInfo, ensure, pallet_prelude::TransactionSource}; | ||||||
|
|
@@ -31,7 +32,7 @@ use sp_runtime::{ | |||||
|
|
||||||
| /// Ensure that signed transactions are only valid if they are signed by sudo account. | ||||||
| /// | ||||||
| /// In the initial phase of a chain without any tokens you can not prevent accounts from sending | ||||||
| /// In the initial phase of a chain without any tokens you cannot prevent accounts from sending | ||||||
| /// transactions. | ||||||
| /// These transactions would enter the transaction pool as the succeed the validation, but would | ||||||
| /// fail on applying them as they are not allowed/disabled/whatever. This would be some huge dos | ||||||
|
|
@@ -89,7 +90,7 @@ where | |||||
| fn validate( | ||||||
| &self, | ||||||
| origin: <<T as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin, | ||||||
| _call: &<T as frame_system::Config>::RuntimeCall, | ||||||
| call: &<T as frame_system::Config>::RuntimeCall, | ||||||
| info: &DispatchInfoOf<<T as frame_system::Config>::RuntimeCall>, | ||||||
| _len: usize, | ||||||
| _self_implicit: Self::Implicit, | ||||||
|
|
@@ -110,6 +111,7 @@ where | |||||
| Ok(( | ||||||
| ValidTransaction { | ||||||
| priority: info.total_weight().ref_time() as TransactionPriority, | ||||||
| provides: vec![(who, call).encode()], | ||||||
|
Contributor
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. Sometimes tag are prefixed to avoid collision, but here it is not necessary.
Suggested change
Contributor
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. dq: is call guaranteed to be unique here?
Contributor
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. AFAIU it is not, but for chains that also have the
Contributor
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.
Fair enough. Does it help, say, to add the block number here?
Contributor
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. Hmm, not really I suppose, as it is going to be the identical too for the duration of one block. If the inherents are available, we could add the timestamp though.
Contributor
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.
True, but being able to make the same sudo calls once per block is better than not being able to do them at all 🤔
Contributor
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.
So I assume that chains w/o We could use hash of
Member
Author
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.
Always to the same address?
Member
Author
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. Someone would need to send the exact same call multiple times. Just sending multiple
Contributor
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. Yes, I meant exactly the same call - for transfer that would be same amount, same address.
Member
Author
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. I see this happening quite unlikely. |
||||||
| ..Default::default() | ||||||
| }, | ||||||
| (), | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
We could also add a sufficient reference to the signer here automatically. Sounds cleaner than removing
CheckNonce.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.
What you mean by this?
Uh oh!
There was an error while loading. Please reload this page.
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.
We remove
CheckNoncebecauseCheckNoncerequires the account to exist.But if we put
CheckOnlySudoAccountbeforeCheckNonceandCheckOnlySudoAccountcreates the account withinc_sufficient(if it doesn't exist yet):polkadot-sdk/substrate/frame/system/src/lib.rs
Line 1656 in 007565a
Then the account exists and the nonce is checked.
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.
And when is
dec_sufficientscalled? :DThere 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.
yes true forget it :-), he could live forever