-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Ensures the tx controller + state-manager orders transactions as received #7484
Conversation
…he order they are received
Builds ready [36ade8b]
|
@@ -193,12 +193,12 @@ class TransactionController extends EventEmitter { | |||
} | |||
txUtils.validateTxParams(normalizedTxParams) | |||
// construct txMeta |
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.
Nit: maybe a comment here would be useful, to explain that this step must happen synchronously, before anything else, because it assigns the tx id? It's really not obvious what's going on here at first glance.
This is a follow up from this discussion: #7473 (comment)
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.
…n 1 in tx-state-manager
…TransactionCategory after generateTxMeta
Builds ready [47bd579]
|
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.
Looks good to me!
I think adding transactions according to id
order is harmless. I know of no cases where it would be harmful at least.
does this mean the history is reversed in the ui? |
|
||
newTxIndex === -1 | ||
? transactions.push(txMeta) | ||
: transactions.splice(newTxIndex, 0, txMeta) |
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 this is a new tx why the splice?
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.
this inserts the transaction in the list according to its id
, before the first transaction with a greater id
@@ -167,7 +167,12 @@ class TransactionStateManager extends EventEmitter { | |||
transactions.splice(index, 1) | |||
} | |||
} | |||
transactions.push(txMeta) | |||
const newTxIndex = transactions | |||
.findIndex((currentTxMeta) => currentTxMeta.id > txMeta.id) |
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.
ids should be random?
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.
oh really?
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.
so im not sure this works
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.
we could use timestamp instead
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.
timestamp could work
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.
id's are random so this will be replacing other txmeta's
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.
Great thank you!
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.
🤙 great thanks!
Builds ready [81f0afe]
|
…ived (#7484) * Ensures the tx controller + tx-state-manager orders transactions in the order they are received * Handle transaction ordering in cases where tx ids are off by more than 1 in tx-state-manager * Add comment to addUnapprovedTransaction explaining calling _determineTransactionCategory after generateTxMeta * Sort txes by timestamp of creation instead of id
These changes are needed to ensure consistency of transaction order. This was an issue for batch transactions and the same change is included in #7473 It was also needed to get my local e2e tests passing.
The strategy here is to ensure that the tx-state-manager orders transactions by id, and to ensure that ids are applied in the order they are received by the transaction controller (and not after an indeterminate async operation).
Although this commit is currently also part of #7473 and #7368, I believe it should be made directly to develop and then those can be rebased accordingly.