Skip to content

feat: use feature flags for gas estimation buffers #5637

Merged
matthewwalsh0 merged 4 commits intomainfrom
feat/gas-estimate-buffer-feature-flags
Apr 15, 2025
Merged

feat: use feature flags for gas estimation buffers #5637
matthewwalsh0 merged 4 commits intomainfrom
feat/gas-estimate-buffer-feature-flags

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Apr 14, 2025

Explanation

Use feature flags to configure the gas estimation buffers, including support for specific chain and type-4 buffers.

[FeatureFlag.GasBuffer]?: {
    /** Fallback buffer for all chains and transactions. */
    default?: number;

    /**
     * Buffer for included network RPCs only and not those added by user.
     * Takes priority over `default`.
     */
    included?: number;

    /** Buffers for specific chains. */
    perChainConfig?: {
      [chainId: Hex]: {
        /**
         * Buffer for the chain for all transactions.
         * Takes priority over non-chain `included`.
         */
        base?: number;

        /**
         * Buffer if network RPC is included and not added by user.
         * Takes priority over `base`.
         */
        included?: number;

        /**
         * Buffer for the chain for EIP-7702 / type 4 transactions only.
         * Only if `data` included and `to` matches `from`.
         * Takes priority over `included` and `base`.
         */
        eip7702?: number;
      };
    };
  };

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@matthewwalsh0
Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-b9c3c977",
  "@metamask-previews/address-book-controller": "6.0.3-preview-b9c3c977",
  "@metamask-previews/announcement-controller": "7.0.3-preview-b9c3c977",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-b9c3c977",
  "@metamask-previews/approval-controller": "7.1.3-preview-b9c3c977",
  "@metamask-previews/assets-controllers": "56.0.0-preview-b9c3c977",
  "@metamask-previews/base-controller": "8.0.0-preview-b9c3c977",
  "@metamask-previews/bridge-controller": "13.0.0-preview-b9c3c977",
  "@metamask-previews/bridge-status-controller": "12.0.1-preview-b9c3c977",
  "@metamask-previews/build-utils": "3.0.3-preview-b9c3c977",
  "@metamask-previews/chain-agnostic-permission": "0.3.0-preview-b9c3c977",
  "@metamask-previews/composable-controller": "11.0.0-preview-b9c3c977",
  "@metamask-previews/controller-utils": "11.7.0-preview-b9c3c977",
  "@metamask-previews/earn-controller": "0.11.0-preview-b9c3c977",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-b9c3c977",
  "@metamask-previews/ens-controller": "16.0.0-preview-b9c3c977",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-b9c3c977",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-b9c3c977",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-b9c3c977",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-b9c3c977",
  "@metamask-previews/keyring-controller": "21.0.2-preview-b9c3c977",
  "@metamask-previews/logging-controller": "6.0.4-preview-b9c3c977",
  "@metamask-previews/message-manager": "12.0.1-preview-b9c3c977",
  "@metamask-previews/multichain": "4.0.0-preview-b9c3c977",
  "@metamask-previews/multichain-api-middleware": "0.1.1-preview-b9c3c977",
  "@metamask-previews/multichain-network-controller": "0.3.0-preview-b9c3c977",
  "@metamask-previews/multichain-transactions-controller": "0.9.0-preview-b9c3c977",
  "@metamask-previews/name-controller": "8.0.3-preview-b9c3c977",
  "@metamask-previews/network-controller": "23.2.0-preview-b9c3c977",
  "@metamask-previews/notification-services-controller": "5.0.1-preview-b9c3c977",
  "@metamask-previews/permission-controller": "11.0.6-preview-b9c3c977",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-b9c3c977",
  "@metamask-previews/phishing-controller": "12.4.1-preview-b9c3c977",
  "@metamask-previews/polling-controller": "13.0.0-preview-b9c3c977",
  "@metamask-previews/preferences-controller": "17.0.0-preview-b9c3c977",
  "@metamask-previews/profile-sync-controller": "11.0.1-preview-b9c3c977",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-b9c3c977",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-b9c3c977",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-b9c3c977",
  "@metamask-previews/sample-controllers": "0.1.0-preview-b9c3c977",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-b9c3c977",
  "@metamask-previews/signature-controller": "27.1.0-preview-b9c3c977",
  "@metamask-previews/token-search-discovery-controller": "2.1.0-preview-b9c3c977",
  "@metamask-previews/transaction-controller": "54.0.0-preview-b9c3c977",
  "@metamask-previews/user-operation-controller": "33.0.0-preview-b9c3c977"
}

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review April 14, 2025 21:54
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners April 14, 2025 21:54
@matthewwalsh0 matthewwalsh0 force-pushed the feat/gas-estimate-buffer-feature-flags branch from 0fa0602 to 1634185 Compare April 15, 2025 10:30
@matthewwalsh0
Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "27.0.0-preview-1634185",
  "@metamask-previews/address-book-controller": "6.0.3-preview-1634185",
  "@metamask-previews/announcement-controller": "7.0.3-preview-1634185",
  "@metamask-previews/app-metadata-controller": "1.0.0-preview-1634185",
  "@metamask-previews/approval-controller": "7.1.3-preview-1634185",
  "@metamask-previews/assets-controllers": "56.0.0-preview-1634185",
  "@metamask-previews/base-controller": "8.0.0-preview-1634185",
  "@metamask-previews/bridge-controller": "13.0.0-preview-1634185",
  "@metamask-previews/bridge-status-controller": "12.0.1-preview-1634185",
  "@metamask-previews/build-utils": "3.0.3-preview-1634185",
  "@metamask-previews/chain-agnostic-permission": "0.3.0-preview-1634185",
  "@metamask-previews/composable-controller": "11.0.0-preview-1634185",
  "@metamask-previews/controller-utils": "11.7.0-preview-1634185",
  "@metamask-previews/earn-controller": "0.11.0-preview-1634185",
  "@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-1634185",
  "@metamask-previews/ens-controller": "16.0.0-preview-1634185",
  "@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-1634185",
  "@metamask-previews/gas-fee-controller": "23.0.0-preview-1634185",
  "@metamask-previews/json-rpc-engine": "10.0.3-preview-1634185",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-1634185",
  "@metamask-previews/keyring-controller": "21.0.2-preview-1634185",
  "@metamask-previews/logging-controller": "6.0.4-preview-1634185",
  "@metamask-previews/message-manager": "12.0.1-preview-1634185",
  "@metamask-previews/multichain": "4.0.0-preview-1634185",
  "@metamask-previews/multichain-api-middleware": "0.1.1-preview-1634185",
  "@metamask-previews/multichain-network-controller": "0.3.0-preview-1634185",
  "@metamask-previews/multichain-transactions-controller": "0.9.0-preview-1634185",
  "@metamask-previews/name-controller": "8.0.3-preview-1634185",
  "@metamask-previews/network-controller": "23.2.0-preview-1634185",
  "@metamask-previews/notification-services-controller": "6.0.0-preview-1634185",
  "@metamask-previews/permission-controller": "11.0.6-preview-1634185",
  "@metamask-previews/permission-log-controller": "3.0.3-preview-1634185",
  "@metamask-previews/phishing-controller": "12.4.1-preview-1634185",
  "@metamask-previews/polling-controller": "13.0.0-preview-1634185",
  "@metamask-previews/preferences-controller": "17.0.0-preview-1634185",
  "@metamask-previews/profile-sync-controller": "12.0.0-preview-1634185",
  "@metamask-previews/queued-request-controller": "10.0.0-preview-1634185",
  "@metamask-previews/rate-limit-controller": "6.0.3-preview-1634185",
  "@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-1634185",
  "@metamask-previews/sample-controllers": "0.1.0-preview-1634185",
  "@metamask-previews/selected-network-controller": "22.0.0-preview-1634185",
  "@metamask-previews/signature-controller": "27.1.0-preview-1634185",
  "@metamask-previews/token-search-discovery-controller": "2.1.0-preview-1634185",
  "@metamask-previews/transaction-controller": "54.0.0-preview-1634185",
  "@metamask-previews/user-operation-controller": "33.0.0-preview-1634185"
}

@matthewwalsh0 matthewwalsh0 merged commit 018f006 into main Apr 15, 2025
198 checks passed
@matthewwalsh0 matthewwalsh0 deleted the feat/gas-estimate-buffer-feature-flags branch April 15, 2025 13:21
matthewwalsh0 added a commit that referenced this pull request Apr 16, 2025
Use feature flags to configure the gas estimation buffers, including
support for specific chain and type-4 buffers.

```js
[FeatureFlag.GasBuffer]?: {
    /** Fallback buffer for all chains and transactions. */
    default?: number;

    /**
     * Buffer for included network RPCs only and not those added by user.
     * Takes priority over `default`.
     */
    included?: number;

    /** Buffers for specific chains. */
    perChainConfig?: {
      [chainId: Hex]: {
        /**
         * Buffer for the chain for all transactions.
         * Takes priority over non-chain `included`.
         */
        base?: number;

        /**
         * Buffer if network RPC is included and not added by user.
         * Takes priority over `base`.
         */
        included?: number;

        /**
         * Buffer for the chain for EIP-7702 / type 4 transactions only.
         * Only if `data` included and `to` matches `from`.
         * Takes priority over `included` and `base`.
         */
        eip7702?: number;
      };
    };
  };
```

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
dbrans pushed a commit to MetaMask/metamask-extension that referenced this pull request Apr 16, 2025
## **Description**

Cherry-pick of #31913 for `12.16.1`.

Creating manual PR as patch required for
`@metamask/transaction-controller`.

Patch changes are cherry-picks of
[#5600](MetaMask/core#5600),
[#5635](MetaMask/core#5635), and
[#5637](MetaMask/core#5637), built from
[patch/transaction-controller-extension-12-16-1](MetaMask/core@patch/transaction-controller-extension-12-16-0...patch/transaction-controller-extension-12-16-1).

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32023?quickstart=1)

## **Related issues**

## **Manual testing steps**

## **Screenshots/Recordings**

### **Before**

### **After**

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] 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/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] 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.
matthewwalsh0 added a commit to MetaMask/metamask-extension that referenced this pull request Apr 21, 2025
Cherry-pick of #31913 for `12.16.1`.

Creating manual PR as patch required for
`@metamask/transaction-controller`.

Patch changes are cherry-picks of
[#5600](MetaMask/core#5600),
[#5635](MetaMask/core#5635), and
[#5637](MetaMask/core#5637), built from
[patch/transaction-controller-extension-12-16-1](MetaMask/core@patch/transaction-controller-extension-12-16-0...patch/transaction-controller-extension-12-16-1).

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32023?quickstart=1)

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] 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/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

- [ ] 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.
matthewwalsh0 added a commit that referenced this pull request Apr 21, 2025
Use feature flags to configure the gas estimation buffers, including
support for specific chain and type-4 buffers.

```js
[FeatureFlag.GasBuffer]?: {
    /** Fallback buffer for all chains and transactions. */
    default?: number;

    /**
     * Buffer for included network RPCs only and not those added by user.
     * Takes priority over `default`.
     */
    included?: number;

    /** Buffers for specific chains. */
    perChainConfig?: {
      [chainId: Hex]: {
        /**
         * Buffer for the chain for all transactions.
         * Takes priority over non-chain `included`.
         */
        base?: number;

        /**
         * Buffer if network RPC is included and not added by user.
         * Takes priority over `base`.
         */
        included?: number;

        /**
         * Buffer for the chain for EIP-7702 / type 4 transactions only.
         * Only if `data` included and `to` matches `from`.
         * Takes priority over `included` and `base`.
         */
        eip7702?: number;
      };
    };
  };
```

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
MajorLift pushed a commit to MetaMask/metamask-extension that referenced this pull request Apr 21, 2025
## **Description**

Cherry-pick of #31913 for `12.17.0`.

Creating manual PR as patch required for
`@metamask/transaction-controller`.

Patch changes are cherry-picks of
[#5635](MetaMask/core#5635) and
[#5637](MetaMask/core#5637), built from
[patch/transaction-controller-extension-12-17-0](MetaMask/core@@metamask/transaction-controller@54.0.0...patch/transaction-controller-extension-12-17-0).

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32144?quickstart=1)

## **Related issues**

## **Manual testing steps**

## **Screenshots/Recordings**

### **Before**

### **After**

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] 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.
salimtb pushed a commit that referenced this pull request Apr 23, 2025
## Explanation

Use feature flags to configure the gas estimation buffers, including
support for specific chain and type-4 buffers.

```js
[FeatureFlag.GasBuffer]?: {
    /** Fallback buffer for all chains and transactions. */
    default?: number;

    /**
     * Buffer for included network RPCs only and not those added by user.
     * Takes priority over `default`.
     */
    included?: number;

    /** Buffers for specific chains. */
    perChainConfig?: {
      [chainId: Hex]: {
        /**
         * Buffer for the chain for all transactions.
         * Takes priority over non-chain `included`.
         */
        base?: number;

        /**
         * Buffer if network RPC is included and not added by user.
         * Takes priority over `base`.
         */
        included?: number;

        /**
         * Buffer for the chain for EIP-7702 / type 4 transactions only.
         * Only if `data` included and `to` matches `from`.
         * Takes priority over `included` and `base`.
         */
        eip7702?: number;
      };
    };
  };
```

## References

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants