-
Notifications
You must be signed in to change notification settings - Fork 680
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
Adds ability to configure default nonce #1557
Conversation
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Why using the block number as the start point of the nonce? If it's used to prevent nonce reset after the account is reaped, then it makes more sense to use the timestample or some larger number. After all, the nonce can be higher than the block number theoretically. |
Oh and make sure you still have tests to ensure the original behaivour is not impacted. Again, not everyone are going to use this and it is essential to the old functionality remains the same and working. |
Sure it could in theory, but this is a best effort approach that should prevent the most likely occurrences. |
@ggwpez @kianenigma Can we proceed with this? Haven't heard from @xlc yet on why someone would opt not to use this. Unless we see a clear benefit, I don't think it's worth maintaining this optionality. |
Please. I don't know why I even need to give you a reason to ask you to not force a breaking change to EVERYONE. Ok, here is one: EVM compatibility. |
This is helpful. Thanks! |
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.
Let's make this configurable through frame_system
so you can express how you wish new account nonces to be created.
The CI pipeline was cancelled due to failure one of the required jobs. |
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.
I just now realize that we can already do this: type Nonce: Default
allows us to already set a non-zero nonce upon creation - entirely without this merge request 🙈
But i guess since we often use types like u32
, it would not be possible to implement another Default
for it, so it should be fine.
@@ -570,6 +575,9 @@ pub mod pallet { | |||
|
|||
/// The maximum number of consumers allowed on a single account. | |||
type MaxConsumers: ConsumerLimits; | |||
|
|||
/// The default nonce when an account is created. | |||
type DefaultNonce: Get<Self::Nonce>; |
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.
Is this intentionally not a #[pallet::constant]
?
type AccountDataOf<T> = <T as Config>::AccountData; | ||
type AccountInfoOf<T> = AccountInfo<NonceOf<T>, AccountDataOf<T>>; | ||
|
||
pub struct GetDefaultAccountInfo<T>(PhantomData<T>); |
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.
pub struct GetDefaultAccountInfo<T>(PhantomData<T>); | |
/// Provides the `Default` for value an account that does not yet exist. | |
pub struct GetDefaultAccountInfo<T>(PhantomData<T>); |
@@ -463,6 +467,7 @@ pub mod pallet { | |||
type RuntimeTask: Task; | |||
|
|||
/// This stores the number of previous transactions associated with a sender account. | |||
#[pallet::no_default_bounds] |
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.
Now there are two notations of default, once from the Default
bound here, and one from the DefaultNonce
.
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
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.
As @ggwpez said the Default
is already pretty flexible, with a newtype that implements Deref { Target = u32 }
it might be possibly without any breaking changes? If it works it seems much superior in terms of code design to me.
If not it looks good, but I expect to see system+relay chains to start using this. It is a good idea to expose a standard SetDefaultNonceToBlockNumber
for them all to use.
will re-approve once alternative approach is explored.
@gupnik can we revive this one? 🙈 💀 |
Thanks for the reminder. It's in my backlog but unable to get to it yet. Will revive this soon. |
We dont actually need this, see polkadot-fellows/runtimes#248 |
Thanks. Closing this one. |
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
* Unnecessary clone * Removed unused Enum value * Client - ConnectionParams wrapped with Arc + removed unnecessery clone * Client - ConnectionParams wrapped with Arc + removed unnecessery clone
Fixes https://github.com/paritytech-secops/srlabs_findings/issues/35, closes #326
This PR introduces the ability to configure the default nonce. This will also be used if the account is reaped.
By default, the current behaviour is maintained and nonce starts from 0.