Skip to content

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Oct 20, 2025

Explanation

  • fetch the OP Stack supported chain list from the gas API with a static fallback so OptimismLayer1GasFeeFlow can react to remote updates
  • make OracleLayer1GasFeeFlow accept an optional default oracle and throw unless subclasses override getOracleAddressForChain, removing the now-unneeded constructor in the Optimism flow
  • allow Layer1GasFeeFlow.matchesTransaction to be async

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

Note

Fetch OP Stack supported chains from the gas API with fallback, use the shared Optimism oracle, and make layer-1 flow matching async across flows and utilities.

  • Layer 1 Gas (OP Stack)
    • Fetch supported chains from gas.api.cx.metamask.io/v1/supportedNetworks with a static fallback list.
    • Use shared Optimism gas price oracle for all OP Stack networks via getOracleAddressForChain.
    • Make OptimismLayer1GasFeeFlow.matchesTransaction async; adjust logic to check remote list then fallback.
  • Oracle Flow Infrastructure
    • OracleLayer1GasFeeFlow now accepts optional default oracle; add overridable getOracleAddressForChain.
    • Update signing to use byte array and resolve oracle per-chain at call time.
  • API/Types & Utilities
    • Change Layer1GasFeeFlow.matchesTransaction to return Promise<boolean>.
    • Update getTransactionLayer1GasFee to await async matcher.
    • Make ScrollLayer1GasFeeFlow.matchesTransaction async.
  • Tests
    • Add/adjust tests for dynamic OP Stack support, fallback behavior, and async matchers.
    • Update GasFeePoller tests to pass messenger object and expect async behavior.
  • Changelog
    • Document improved OP Stack L1 fee estimation and async matcher.

Written by Cursor Bugbot for commit 044c238. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/expannd-op-stack-l1-gas-fees branch 5 times, most recently from b0cf270 to 0e779d8 Compare October 21, 2025 10:47
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/expannd-op-stack-l1-gas-fees branch 3 times, most recently from c0d7df5 to 3575c60 Compare October 22, 2025 11:07
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/expannd-op-stack-l1-gas-fees branch from 7b8c594 to 044c238 Compare October 22, 2025 13:25
@pedronfigueiredo pedronfigueiredo changed the title feat: Dynamic OP Stack L1 gas via gas API + opBNB oracle override feat: Dynamic OP Stack L1 gas via gas API Oct 22, 2025
### Changed

- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))
- Improve OP Stack layer 1 fee estimation by fetching the supported chain list from the gas API with a static fallback, using the shared Optimism gas price oracle contract for all OP Stack networks, and making `Layer1GasFeeFlow.matchesTransaction` asynchronous to support remote lookups. ([#6899](https://github.com/MetaMask/core/pull/6899))
Copy link
Member

Choose a reason for hiding this comment

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

This is intended to only list external changes.

So maybe as simple as:

Identify OP stack chains using gas API ?

export class OptimismLayer1GasFeeFlow extends OracleLayer1GasFeeFlow {
constructor() {
super(OPTIMISM_GAS_PRICE_ORACLE_ADDRESS);
async function fetchOptimismSupportedChains(): Promise<Set<number> | null> {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, could this be a private method inside the class? Or at least at the bottom of the file to highlight what is exported?

// BlockExplorer link: https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f#code
const OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =
const DEFAULT_OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =
'0x420000000000000000000000000000000000000F';
Copy link
Member

Choose a reason for hiding this comment

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

Minor, could define as Hex here instead.

readonly #signTransaction: boolean;

constructor(oracleAddress: Hex, signTransaction?: boolean) {
constructor(oracleAddress?: Hex, signTransaction?: boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we simplify by removing this and relying only on getOracleAddressForChain which could return the default vault in this class rather than in the Optimism class?

const DEFAULT_OPTIMISM_GAS_PRICE_ORACLE_ADDRESS =
'0x420000000000000000000000000000000000000F';

type SupportedNetworksResponse = {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, type below all the constants?

}

protected override getOracleAddressForChain(chainId: Hex): Hex {
return DEFAULT_OPTIMISM_GAS_PRICE_ORACLE_ADDRESS as Hex;
Copy link
Member

Choose a reason for hiding this comment

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

Didn't we have alternate oracles in the previous commit?

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.

2 participants