-
-
Notifications
You must be signed in to change notification settings - Fork 253
feat: Dynamic OP Stack L1 gas via gas API #6899
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
base: main
Are you sure you want to change the base?
Conversation
b0cf270
to
0e779d8
Compare
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
packages/transaction-controller/src/gas-flows/OptimismLayer1GasFeeFlow.ts
Outdated
Show resolved
Hide resolved
c0d7df5
to
3575c60
Compare
7b8c594
to
044c238
Compare
### 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)) |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
Explanation
References
Checklist
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.
gas.api.cx.metamask.io/v1/supportedNetworks
with a static fallback list.getOracleAddressForChain
.OptimismLayer1GasFeeFlow.matchesTransaction
async; adjust logic to check remote list then fallback.OracleLayer1GasFeeFlow
now accepts optional default oracle; add overridablegetOracleAddressForChain
.Layer1GasFeeFlow.matchesTransaction
to returnPromise<boolean>
.getTransactionLayer1GasFee
to await async matcher.ScrollLayer1GasFeeFlow.matchesTransaction
async.GasFeePoller
tests to pass messenger object and expect async behavior.Written by Cursor Bugbot for commit 044c238. This will update automatically on new commits. Configure here.