-
Notifications
You must be signed in to change notification settings - Fork 710
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
CheckNonce
: Provide a way to pass an optional default nonce
#4044
Conversation
let mut account = crate::Account::<T>::try_get(who) | ||
.unwrap_or_else(|_| AccountInfo { nonce: DefaultNonce::get(), ..Default::default() }); | ||
if account.providers.is_zero() && account.sufficients.is_zero() { | ||
// Nonce storage not paid for | ||
return Err(InvalidTransaction::Payment.into()) | ||
} |
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.
If the account doesn't exist and Account::<T>::try_get(who)
returns None
, the DefaultNonce
will be used but the next check of providers and sufficients is basically guaranteed to fail because the default account data for these is 0
.
If the account exists, a nonce also must exist (most likely created here through an ED funding or in some other place providing providers
or sufficients
refs), so the DefaultNonce
introduced here has no effect.
It feels like the place to put this default nonce logic would be in the AccountData
default impl. Am I missing anything? I encountered this issue while trying to write a test for this.
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.
That is a really good point.
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.
Yes then this solution here is actually not that great.
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.
Nice catch! Seems like #4034 is better then?
Doesn't work. This time for 100% :D |
No description provided.