Skip to content

Conversation

@danjm
Copy link
Contributor

@danjm danjm commented Feb 16, 2024

Cherry pick of #22997 to v11.10.0. That PR's description is below

Update the hardfork in the transaction common used to estimate L1 optimism fees to London, fixing display of Layer 1 optimsim fees

The bug was that Layer 1 fees were not being displayed on the confirmation screen for transactions on Optimism.

This was because estimatedL1Fees was null, because fetchEstimatedL1Fee was failing, because
TransactionFactory.fromTxData(txParams, { common }) in buildUnserializedTransaction was throwing an error, because txParams has a type === 2, but EIP-1559 transactions are not supported on the spurious dragon hardfork, which is what was being used in the common configuration of that TransactionFactory.fromTxData call.

This became a problem after
https://github.com/MetaMask/core/pull/3817/files. That PR correctly fixed a bug which could result in the transaction type being removed from the txMeta.txParams when addTransaction in the tx controller was called. With that bug fix, there was now a type present on the txParams that got passed to the aforementioned
TransactionFactory.fromTxData call. Prior to that bug fix, there was no type on txParams at that point, the ethereumjs-tx TransactionFactory was treating these transactions as legacy transactions, and so was constructing a type 0 transaction, and the fact that the hardfork was spurious dragon was not a problem

This PR fixes the problem by updating the hardfork param used in the common configuration of that TransactionFactory.fromTxData call. This should not have a functional effect, as this will cause no change in data and value of the tx passed to the smart contract to generate an fee estimate, except that this may result in more accurate L1 fee estimates (that is not certain though).

Fixes: #22945

  1. Create a transaction on OP Mainnet
  2. Click "Fee details" on the confirmation screen
  3. The layer 1 fee details should be visible

Screenshot from 2024-02-16 09-27-25

Update the hardfork in the transaction common used to estimate L1 optimism fees to London, fixing display of Layer 1 optimsim fees

The bug was that Layer 1 fees were not being displayed on the
confirmation screen for transactions on Optimism.

This was because `estimatedL1Fees` was null, because
`fetchEstimatedL1Fee` was failing, because
`TransactionFactory.fromTxData(txParams, { common })` in
`buildUnserializedTransaction` was throwing an error, because `txParams`
has a `type` === `2`, but EIP-1559 transactions are not supported on the
spurious dragon hardfork, which is what was being used in the `common`
configuration of that `TransactionFactory.fromTxData` call.

This became a problem after
https://github.com/MetaMask/core/pull/3817/files. That PR correctly
fixed a bug which could result in the transaction type being removed
from the `txMeta.txParams` when `addTransaction` in the tx controller
was called. With that bug fix, there was now a `type` present on the
`txParams` that got passed to the aforementioned
`TransactionFactory.fromTxData` call. Prior to that bug fix, there was
no `type` on `txParams` at that point, the ethereumjs-tx
TransactionFactory was treating these transactions as legacy
transactions, and so was constructing a type 0 transaction, and the fact
that the hardfork was spurious dragon was not a problem

This PR fixes the problem by updating the hardfork param used in the
`common` configuration of that `TransactionFactory.fromTxData` call.
This should not have a functional effect, as this will cause no change
in data and value of the tx passed to the smart contract to generate an
fee estimate, except that this may result in more accurate L1 fee
estimates (that is not certain though).

Fixes: #22945

1. Create a transaction on OP Mainnet
2. Click "Fee details" on the confirmation screen
3.  The layer 1 fee details should be visible

![Screenshot from 2024-02-16
09-27-25](https://github.com/MetaMask/metamask-extension/assets/7499938/6c759096-f393-4101-b9af-a3542e313571)

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [ ] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@danjm danjm requested a review from a team as a code owner February 16, 2024 14:38
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@danjm danjm merged commit 4b24c1c into Version-v11.10.0 Feb 16, 2024
@danjm danjm deleted the cherry-pick-67eb0bca9e branch February 16, 2024 15:22
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2024
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants