Skip to content

Refactor Tx State Manager#10672

Merged
brad-decker merged 2 commits intodevelopfrom
refactor-tx-state-manager
Mar 30, 2021
Merged

Refactor Tx State Manager#10672
brad-decker merged 2 commits intodevelopfrom
refactor-tx-state-manager

Conversation

@brad-decker
Copy link
Contributor

No description provided.


// Combine sortBy and pickBy to transform our state object into an array of
// matching transactions that are sorted by time.
const filteredTransactions = sortBy(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous iteration of this logic resulted in the potential for the entire transaction list to be iterated through N + 1 times where N was the number of search terms. The + 1 is because the entire list was iterated through once to get only the current network transactions.

This code should both be more performant and still return transactions in the order in which they were expected prior to my changes.

}),
'time',
);
if (limit !== undefined) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous version of this code, the limit was computed before filtering (except current network filter). I don't think this will result in a functional change due to the fact that we aren't using filtering logic to get a subset of transactions in the UI.

@brad-decker brad-decker force-pushed the refactor-incoming-tx-controller branch from a24b030 to fe5944e Compare March 19, 2021 17:44
Base automatically changed from refactor-incoming-tx-controller to develop March 19, 2021 21:54
@brad-decker brad-decker force-pushed the refactor-tx-state-manager branch from b5a7f27 to 9e5c019 Compare March 19, 2021 22:02
@metamaskbot
Copy link
Collaborator

Builds ready [a440ce3]
Page Load Metrics (638 ± 14 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint447256105
domContentLoaded6007106373014
load6007116383014
domInteractive5997096373014

@brad-decker brad-decker force-pushed the refactor-tx-state-manager branch 2 times, most recently from fff90f3 to c4d2bde Compare March 22, 2021 16:43
@metamaskbot
Copy link
Collaborator

Builds ready [c4d2bde]
Page Load Metrics (638 ± 27 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45735884
domContentLoaded5708176375627
load5718186385627
domInteractive5698176375627

@brad-decker brad-decker force-pushed the refactor-tx-state-manager branch from 2fdaed1 to ae3a5a2 Compare March 22, 2021 20:38
@metamaskbot
Copy link
Collaborator

Builds ready [ae3a5a2]
Page Load Metrics (625 ± 32 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46785894
domContentLoaded3657026236833
load3677036256732
domInteractive3657026236832

@brad-decker brad-decker marked this pull request as ready for review March 22, 2021 22:05
@brad-decker brad-decker requested a review from a team as a code owner March 22, 2021 22:05
@brad-decker brad-decker requested a review from darkwing March 22, 2021 22:05
@danjm danjm self-requested a review March 24, 2021 14:42
@metamaskbot
Copy link
Collaborator

Builds ready [feece70]
Page Load Metrics (690 ± 25 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47916795
domContentLoaded6257676875124
load6267766905225
domInteractive6257676875124

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! I only got partway through - I'll try to review the rest today though.

break;
default:
if (typeof value !== 'string') {
throw ethErrors.rpc.invalidParams(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that additional validation was added throughout this function, but it looks to be identical to the validation already happening in tx-state-manager. Seems reasonable 👍

* use throughout the extension. The argument here will override everything
* in the resulting transaction meta.
*
* TODO: Don't overwrite everything?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

}

/**
* @returns {Array} the tx list with unapproved status
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, what a blatant lie. Good riddance!

Gudahtt
Gudahtt previously approved these changes Mar 26, 2021
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great work!

Storing transactions by id makes much more sense. I like how you've consolidated all of those transaction list functions as well.

I've left lots of smaller suggestions, but nothing major stood out. The migration looks good too - it seems pretty robust.

* @emits 'updateBadge' - When the number of transactions changes in state,
* the badge in the browser extension bar should be updated to reflect the
* number of pending transactions. This particular emit doesn't appear to
* bubble up anywhere that is actually used. TransactionController emits
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also agreed!

status: TRANSACTION_STATUSES.SUBMITTED,
};
const submittedTx0Dupe = {
id: 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I see that this id has changed, so this is no longer an exact duplicate transaction. But I can't think of any benefit to us testing two transactions with the same ID - lots of things would already not be working correctly if someone ended up in that state.

* @property {number} submittedTime - The time the transaction was submitted to
* @property {number} [submittedTime] - The time the transaction was submitted to
* the network, in Unix epoch time (ms).
* @property {TxError} [err] - The error encountered during the transaction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awww 😞 Well, today I learned that this is a thing that we do. We should be preserving the Error object, not deconstructing it into this "TxError" object. Oh well. A task for a future PR.

@metamaskbot
Copy link
Collaborator

Builds ready [69914db]
Page Load Metrics (624 ± 16 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45805784
domContentLoaded5687176223416
load5697186243416
domInteractive5677176223416

@brad-decker brad-decker requested a review from Gudahtt March 29, 2021 16:12
@Gudahtt
Copy link
Member

Gudahtt commented Mar 29, 2021

Changes look good to me! Ready to re-approve when the migration number has been updated to resolve that conflict.

@brad-decker brad-decker force-pushed the refactor-tx-state-manager branch from 69914db to 40f5cec Compare March 29, 2021 21:34
@metamaskbot
Copy link
Collaborator

Builds ready [40f5cec]
Page Load Metrics (630 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46715874
domContentLoaded33680262810751
load33880463010751
domInteractive33680262810751

@Gudahtt
Copy link
Member

Gudahtt commented Mar 30, 2021

One more rebase needed, to get past the CI failure

@brad-decker brad-decker force-pushed the refactor-tx-state-manager branch from 40f5cec to 4e48c28 Compare March 30, 2021 14:09
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
@metamaskbot
Copy link
Collaborator

Builds ready [17b510d]
Page Load Metrics (563 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47855895
domContentLoaded37876156211153
load38176256311153
domInteractive37876156111153

@brad-decker brad-decker merged commit 4080ed6 into develop Mar 30, 2021
@brad-decker brad-decker deleted the refactor-tx-state-manager branch March 30, 2021 14:54
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants