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

Improve nonce handling #1027

Open
echevrier opened this issue Sep 29, 2022 · 6 comments · Fixed by #1054
Open

Improve nonce handling #1027

echevrier opened this issue Sep 29, 2022 · 6 comments · Fixed by #1054
Assignees
Labels
A0-core Affects a core part F2-bug Something isn't working

Comments

@echevrier
Copy link
Contributor

echevrier commented Sep 29, 2022

Currently when we use the extrinsic factory to create extrinsics we use a cached nonce value. As we do not always know when an extrinsic has not been executed successfully, all subsequent extrinsics will have a wrong nonce. (See issue).

Furthermore, what happens when the extrinsics are sent in parallel? Can we ensure that the nonce is unique?

Answer @haerdib : Yes, because each enclave has its own, unique signer and the nonce cache is behind a lock. So if the ExtrinsicFactory is accessed for each extrinsic creation, the nonce is unique.

How do we handle extrinsics that have already been sent with the wrong nonce?

What other issues should be considered?

@echevrier
Copy link
Contributor Author

Currently, the cached nonce is not systematically updated. See #1007 (comment)

@murerfel
Copy link
Contributor

murerfel commented Oct 3, 2022

One step towards solving this, as discussed in #1033, is to ensure that we use the ExtrinsicsFactory whenever we want to compose extrinsics. We still have a couple of places (e.g. attestation), where we duplicate the extrinsics factory code (and sometime forget to increment nonce, which is handled consistently by the factory)

@haerdib
Copy link
Contributor

haerdib commented Oct 6, 2022

I will try to solve this while doing #1049

@ziming-zung
Copy link

After merging #1054 , i tested the issue and found that the issue has not been resolved. Can you help to double check?

@haerdib
Copy link
Contributor

haerdib commented Nov 29, 2022

Hm.. you're right, I guess. While hopefully all extrinsic offline creations now use the ExtrinsicFactory, in case of a nonce mismatch ( a call lost somewhere or invalid) the nonce will not be correct anymore in the local storage.

@clangenb please correct me if I'm wrong.

However, there's already a similar issue: #231 which I just updated accordingly.

Edit:
Sorry my bad, #231 is actually unrelated, as it affects the cli, not the nonce storage of the enclave. I guess this issue might need to be reopened, or is there a similar issue already?

@Kailai-Wang
Copy link
Contributor

@haerdib maybe this one: #970

@haerdib haerdib reopened this Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0-core Affects a core part F2-bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants