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

Ensure correct tx category when sending to contracts without tx data #7252

Merged
merged 5 commits into from
Oct 7, 2019

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Oct 4, 2019

Fixes #7115

@danjm danjm requested a review from frankiebee as a code owner October 4, 2019 18:56
danfinlay
danfinlay previously approved these changes Oct 4, 2019
Copy link
Contributor

@danfinlay danfinlay 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 to me, thanks for the catch!

Gudahtt
Gudahtt previously approved these changes Oct 4, 2019
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 reasonable to me

@metamaskbot
Copy link
Collaborator

Builds ready [6157275]

@danjm danjm dismissed stale reviews from Gudahtt and danfinlay via d8cbddb October 4, 2019 20:00
@danjm danjm requested a review from whymarrh as a code owner October 4, 2019 20:00
@@ -243,12 +244,21 @@ async function estimateGas ({
}

// if not, fall back to block gasLimit
if (!blockGasLimit) {
try {
blockGasLimit = await this.query.getBlockByNumber('latest', false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't getBlockByNumber return a block object, not a number string like we probably expect here?

Copy link
Member

Choose a reason for hiding this comment

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

I believe it's impossible for blockGasLimit to ever be falsey, because it's given a default value of MIN_GAS_LIMIT_HEX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this to something simpler. We don't really need a strictly accurate blockGasLimit at this point.

Meanwhile, I think blockGasLimit can be falsey if the value passed to this function is defined but falsey.

e.g.

danjm@pop-os:~/kyokan/metamask-extension$ node
> const t = ({ a = 10, b }) => console.log(`${a} | ${b}`)
undefined
> t({ a: null, b: 5})
null | 5
undefined
> t({ a: '', b: 5})
 | 5
undefined
> t({ b: 5})
10 | 5
undefined

@metamaskbot
Copy link
Collaborator

Builds ready [11c5b15]

@@ -243,12 +244,17 @@ async function estimateGas ({
}

// if not, fall back to block gasLimit
if (!blockGasLimit) {
blockGasLimit = ARBITRARY_HIGH_BLOCK_GAS_LIMIT
Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure how the problem this is solving (the account tracker not having a valid current block gas limit) relates to the bug this PR is meant to address. That problem might also be better solved in the background, though I'm not sure how... maybe by having a valid default instead of empty string, and/or exposing the 'loading' state to the UI so it can wait for the first block to get read, and/or dealing with errors in a different manner.

I suppose setting this default here for the time being is fine though; maybe it's the quickest way to fix this for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yeah, sorry. This solves an additional bug that was discovered while QAing the fix to the primary bug. It relates in the sense that it is a bug in our gas estimation logic.

I would say a background fix may also be needed, but as it stands, if this function receives a falsey but defined blockGasLimit, it will break as such a value will cause an error when passed to multiplyCurrencies below.

Copy link
Contributor

@danfinlay danfinlay left a comment

Choose a reason for hiding this comment

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

Looks like this should do it!

@danfinlay danfinlay merged commit 38df647 into develop Oct 7, 2019
Gudahtt pushed a commit that referenced this pull request Oct 7, 2019
…7252)

* Ensure correct transaction category when sending to contracts but there is no txParams data

* Update gas when pasting address in send

* Gracefully fall back is send.util/estimateGas when blockGasLimit from background is falsy

* Remove network request frontend fallback for blockGasLimit

* Add some needed slow downs to e2e tests
@danfinlay danfinlay deleted the fix-contract-send-gas branch October 7, 2019 19:31
Gudahtt pushed a commit that referenced this pull request Oct 8, 2019
…7252)

* Ensure correct transaction category when sending to contracts but there is no txParams data

* Update gas when pasting address in send

* Gracefully fall back is send.util/estimateGas when blockGasLimit from background is falsy

* Remove network request frontend fallback for blockGasLimit

* Add some needed slow downs to e2e tests
Gudahtt added a commit that referenced this pull request Oct 8, 2019
* master: (34 commits)
  Update changelog for v7.2.3
  Fix e2e tests and gas default (#7267)
  Do not transate on seed phrases
  test:integration - fix renamed test data file
  lint fix
  test:e2e - fix bail condition
  test:e2e - fix responsie argument
  test:e2e - refactor missed spec file
  test:e2e - only overwrite window.fetch once per session
  test:e2e - rework fetch-mocks
  test:e2e - add extra delay before closing popups
  test:e2e - factor out prepareExtensionForTesting
  test - e2e - dedupe fetchMocking + compose script as fn
  Ensure correct tx category when sending to contracts without tx data (#7252)
  Version v7.2.3
  Add v7.2.2 to changelog
  Update minimum Firefox verison to 56.0 (#7213)
  Version v7.2.2
  Update changelog for v7.2.1, v7.2.0, and v7.1.1
  Add `appName` message to each locale
  ...
Gudahtt added a commit that referenced this pull request Oct 9, 2019
* origin/master: (34 commits)
  Update changelog for v7.2.3
  Fix e2e tests and gas default (#7267)
  Do not transate on seed phrases
  test:integration - fix renamed test data file
  lint fix
  test:e2e - fix bail condition
  test:e2e - fix responsie argument
  test:e2e - refactor missed spec file
  test:e2e - only overwrite window.fetch once per session
  test:e2e - rework fetch-mocks
  test:e2e - add extra delay before closing popups
  test:e2e - factor out prepareExtensionForTesting
  test - e2e - dedupe fetchMocking + compose script as fn
  Ensure correct tx category when sending to contracts without tx data (#7252)
  Version v7.2.3
  Add v7.2.2 to changelog
  Update minimum Firefox verison to 56.0 (#7213)
  Version v7.2.2
  Update changelog for v7.2.1, v7.2.0, and v7.1.1
  Add `appName` message to each locale
  ...
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.

Sending eth to contract fallback fails with default gas
4 participants