-
Notifications
You must be signed in to change notification settings - Fork 2
Added Interrupted status to transaction entity #434
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
Changes from all commits
730219a
114dc0f
ad05688
c9bd2fb
eb95604
540856d
caa054f
157297f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||
| import { LogTag, Logger } from "@happy.tech/common" | ||||||||
| import type { LatestBlock } from "./BlockMonitor.js" | ||||||||
| import { Topics, eventBus } from "./EventBus.js" | ||||||||
| import { AttemptType } from "./Transaction.js" | ||||||||
| import { AttemptType, TransactionStatus } from "./Transaction.js" | ||||||||
| import type { TransactionManager } from "./TransactionManager.js" | ||||||||
|
|
||||||||
| /** | ||||||||
|
|
@@ -45,6 +45,10 @@ export class TransactionCollector { | |||||||
| transactionsBatch.map(async (transaction) => { | ||||||||
| const nonce = this.txmgr.nonceManager.requestNonce() | ||||||||
|
|
||||||||
| if (transaction.status === TransactionStatus.Interrupted) { | ||||||||
| transaction.changeStatus(TransactionStatus.Pending) | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think that's the point right? Also, is there any chance the transction is NOT pending at this point? (I think not, but making sure). Should this be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is possible. I changed this to allow resubmitting an interrupted transaction, but I had a bug in the if statement—the operation was actually the opposite. Anyway, I'm going to update the code so that the status change only happens when the status is |
||||||||
| } | ||||||||
|
|
||||||||
| const submissionResult = await this.txmgr.transactionSubmitter.attemptSubmission(transaction, { | ||||||||
| type: AttemptType.Original, | ||||||||
| nonce, | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.
Big question about this: if an external account writes something with the current nonce, and we have no pending txs, we'll need to wait to get two txs from an originator, the first will be blocked indefinitely until the second one comes along.
But we could have detected and fixed the issue before.
It might be be better to have a mechanism that resync the nonce directly with the chain.
In theory, we should have a nonce related error on the submit right? We could parse that and issue a
resync()call on a new function of this name in theNonceManager. We could also have a good oldsetInterval, but it does seem less elegant...If we do that there is also no need to add the new
successfulAttemptIndexDB field, unless there is another use case for that?Btw, do we ever return a tx hash to the user of the library for the included tx? If not, lets create an issue.
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, you are right. I implemented the resync mechanism and, in addition, I removed the
successfulAttemptIndex.I also created the issue to notify the user with the successful transaction hash
https://linear.app/happychain/issue/HAPPY-379/hook-for-notifying-the-user-with-the-transaction-hash-of-the-included