Conversation
Deploying happychain with
|
| Latest commit: |
de3af6c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d2fae4a2.happychain.pages.dev |
| Branch Preview URL: | https://gabriel-fix-randomnness.happychain.pages.dev |
1727040 to
4303d66
Compare
aa82f76 to
5b83c84
Compare
1beb802 to
3bfc7d8
Compare
| }) | ||
|
|
||
| this.maxExecutedNonce = blockchainNonce | ||
| this.maxExecutedNonce = blockchainNonce - 1 |
There was a problem hiding this comment.
probably need to clamp this to not go below zero?
There was a problem hiding this comment.
agree, edge case for when nonce is 0 is unlikely but technically possible for a new txm instance
There was a problem hiding this comment.
It’s actually the expected behavior for it to be -1. If the user has an account that has never been used, the blockchain nonce will be 0, and therefore the max executed nonce will become -1. We use the max executed nonce to check if there is any pending transaction with a nonce lower than the maximum executed nonce, and if so, we move it to Interrupted.
if (nonce <= this.transactionManager.nonceManager.maxExecutedNonce) {
transaction.changeStatus(TransactionStatus.Interrupted)
return
}
So I think it’s fine for it to remain at -1 because it serves our purpose.
If we change it to undefined, I think the code is going to get messier, because we would have to handle the undefined case in several places, whereas -1 is fully functional
4365362 to
e783a93
Compare
3bfc7d8 to
5692dc3
Compare
5692dc3 to
9846057
Compare
9846057 to
de1c63f
Compare
f9da5c8 to
16ff508
Compare
840cd07 to
51d9734
Compare
51d9734 to
8b1311a
Compare
There was a problem hiding this comment.
This needs to revert — if it causes an issue for you, you'll need to foundryup to get the 1.0.0 release.
There was a problem hiding this comment.
done
ce73860 to
0c6f204
Compare
bb3d2ab to
d03ec85
Compare

Description
The randomness service got stuck due to a nonce gap. This happened because, in the case where the server crashes for some reason, we might leave a transaction unsaved, while at the same time saving another transaction with a higher nonce. When the nonce manager starts and calculates the nonce gaps, we were incorrectly assuming that the nonce obtained from the blockchain's transaction count represents the last executed transaction for that account. However, that value actually represents the next available nonce.
For example, suppose we are processing two new transactions with nonces 9 and 10. If the server crashes and only the transaction with nonce 10 is saved, when the service restarts, it will calculate the nonce gaps assuming that nonce 9 was already used—because the transaction count returned from the blockchain indicates the next available nonce, not the last one executed. This leads to the gap and causes the service to get stuck
Toggle Checklist
Checklist
Basics
norswap/build-system-caching).Reminder: PR review guidelines
Correctness
testnet, mainnet, standalone wallet, ...).
< INDICATE BROWSER, DEMO APP & OTHER ENV DETAILS USED FOR TESTING HERE >
< INDICATE TESTED SCENARIOS (USER INTERFACE INTERACTION, CODE FLOWS) HERE >
and have updated the code & comments accordingly.
Architecture & Documentation
(2) commenting these boundaries correctly, (3) adding inline comments for context when needed.
comments.
in a Markdown document.
packages/coreandpackages/react), see here for more info.