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

_checkIfTxWasDropped nextworkNextNonce type correction #8827

Merged
merged 9 commits into from
Jun 17, 2020

Conversation

tmashuang
Copy link
Contributor

@tmashuang tmashuang commented Jun 17, 2020

No radix-16 needed for nonce, already done,. NextNetworkNonce BN doesn't need it either, returns number when parsed.

Stringify on networkNonce before parseInt.

Just remove radix-16 on nextNetworkNonce.

Radix-10 on nextworkNextNonce BN.

networkNextNonce.toNumber()

Fixes #8688.

No radix-16 needed for nonce, already done, and BN doesn't need to be radix, returns number.
@tmashuang tmashuang requested a review from a team as a code owner June 17, 2020 04:08
@metamaskbot
Copy link
Collaborator

Builds ready [efd9c0d]
Page Load Metrics (662 ± 44 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint3393502211
domContentLoaded3637936609244
load3657976629244
domInteractive3637936609244

@whymarrh
Copy link
Contributor

I don't understand, why isn't this needed/correct?

@tmashuang
Copy link
Contributor Author

tmashuang commented Jun 17, 2020

parseInt(0x18, 16) !== parseInt('0x18', 16)

edit
parseInt('0x18', 16) //24
parseInt(0x18, 16) //36
const nextNetworkNonce = new BN([24])
parseInt(nextNetworkNonce, 16) //36

@Gudahtt
Copy link
Member

Gudahtt commented Jun 17, 2020

I think the problem here is that networkNextNonce is a BigNumber, which gets .toString'd by parseInt implicitly, giving a base-10 string representation. Parsing that base-10 string representation of the number using a radix of 16 would give the wrong answer sometimes.

This also explains why I wasn't able to reproduce the problem - my transaction count was below 10, so the base-10 and base-16 numbers were equivalent.

@tmashuang tmashuang changed the title ParseInt of nonce and nextNetworkNonce correction ParseInt nextNetworkNonce correction Jun 17, 2020
tmashuang and others added 2 commits June 17, 2020 09:49
Gudahtt
Gudahtt previously approved these changes Jun 17, 2020
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!

@tmashuang tmashuang changed the title ParseInt nextNetworkNonce correction ParseInt nextworkNextNonce correction Jun 17, 2020
@Gudahtt Gudahtt dismissed their stale review June 17, 2020 17:02

Ah, unit test failures. It looks like the stub was returning a string, when it should have been returning a BN

@metamaskbot
Copy link
Collaborator

Builds ready [65f8e0e]
Page Load Metrics (734 ± 31 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint33141573014
domContentLoaded6269137326431
load6289157346431
domInteractive6269137326431

Gudahtt
Gudahtt previously approved these changes Jun 17, 2020
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! (though I do agree that using .toNumber() is marginally better)

Gudahtt
Gudahtt previously approved these changes Jun 17, 2020
@metamaskbot
Copy link
Collaborator

Builds ready [fd435ec]
Page Load Metrics (1165 ± 88 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint54175903818
domContentLoaded6451549116218287
load6471551116518288
domInteractive6441549116218287

@tmashuang tmashuang merged commit 753a3eb into develop Jun 17, 2020
@tmashuang tmashuang deleted the parseInt-correction branch June 17, 2020 21:13
@tmashuang tmashuang changed the title ParseInt nextworkNextNonce correction _checkIfTxWasDropped nextworkNextNonce type correction Jun 17, 2020
Gudahtt added a commit that referenced this pull request Jun 23, 2020
* origin/develop:
  Fix signing method bugs (#8833)
  replace icons with Checkbox component (#8830)
  Use gulp-cli@2.3.0 (#8845)
  Use node-sass@4.14.1 (#8844)
  Call getMethodDataAsync when knownMethodData[fourBytePrefix] object is empty (#8836)
  Update connected status popover content (#8834)
  Use @metamask/controllers@2.0.1 (#8832)
  ParseInt nextworkNextNonce correction (#8827)
  Fix first time onboarding popup position (#8829)
  fix overflowing contract names and origins (#8823)
  Hide 'Expand view' button in fullscreen (#8826)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with Txs being labeled as dropped but still pending
4 participants