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

CheckNonce: Provide a way to pass an optional default nonce #4044

Closed
wants to merge 1 commit into from

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Apr 9, 2024

No description provided.

@bkchr bkchr added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Apr 9, 2024
@bkchr bkchr requested a review from a team as a code owner April 9, 2024 11:47
Comment on lines +102 to 107
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())
}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

@gupnik gupnik Apr 16, 2024

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?

@bkchr bkchr closed this Apr 16, 2024
@bkchr bkchr deleted the bkchr-default-nonce branch April 16, 2024 12:32
@bkchr bkchr restored the bkchr-default-nonce branch April 16, 2024 12:44
@bkchr bkchr reopened this Apr 16, 2024
@bkchr
Copy link
Member Author

bkchr commented Apr 18, 2024

Doesn't work. This time for 100% :D

@bkchr bkchr closed this Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants