-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: Use Viem in finalizer for some OpStack chains #1798
base: master
Are you sure you want to change the base?
Conversation
$$ Currently showing my WIP trying to use the Viem client to support limited finalizer functionality: - check withdrawal status - build proveWithdrawalTransaction and finalizeWithdrawal args ## Current limitations of Viem: - No easy way to convert ethers Provider to [Viem transport](https://viem.sh/docs/clients/transports/custom), meaning that RPC calls won't go through our custom RetryProvider. The Viem transport does have retry and fallback logic natively but not caching built-in. I think we'll need a larger refactor to support this migration if we wanted to use Viem more widely throughout the codebase. We can probably get away with Viem in the finalizer if we restrict its use only for the few RPC calls required to support finalizer functions (e.g. building transaction args requires querying contracts) - `getWithdrawalStatus` only supports querying a transaction with a single withdrawal. This isn't very useful for us today since we usually multicall our withdrawals. - [Viem accounts](https://viem.sh/docs/clients/wallet#json-rpc-accounts) don't seem to be obviously interoperable with ethers Signers ## Suggested roadmap - Use Viem for optimism mainnet, and then a few op stack chains over time. - Build generalized Viem modules that could help us install viem into the broader codebase like: - converting between Ethers providers/signers and Viem transports/accounts
https://github.com/wevm/viem/releases/tag/viem%402.21.35 this viem release includes new fraud proof support for base
const publicClientL1 = viem | ||
.createPublicClient({ | ||
chain: chainIsProd(chainId) ? viemChains.mainnet : viemChains.sepolia, | ||
transport: viem.http(getCachedProvider(hubChainId, true).providers[0].connection.url), |
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 part is annoying: is there a better way to set up a viem.http() object without having to access the ethers.JSONRpcProvider's connection.url prop?
src/finalizer/utils/opStack.ts
Outdated
chain: chainIsProd(chainId) ? viemChains.mainnet : viemChains.sepolia, | ||
transport: viem.http(getCachedProvider(hubChainId, true).providers[0].connection.url), | ||
}) | ||
.extend(publicActionsL1() as any) as any; |
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.
Also really annoying and can't figure out how to get these typings to work, even the viem code itself has some weird castings so maybe its not that unexpected: https://github.com/wevm/viem/blob/80d0b61356f8a5acab2b9e622564e5b6fca53ccc/src/clients/createPublicClient.ts#L89
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.
Is this still in flight? My only question is if we'd still look to use viem for this list of chains
The eth-optimism NPM package is being deprecated
This package is built on
ethers.js
and it is scheduled for deprecation. The finalizer is one of the main packages in this repo that uses external SDK's so the finalizer eventually MUST migrate to the viem version of the optimism SDK. This PR adds OP-stack support for most chains we currently support minus a few that are non-standard.Current limitations of Viem:
any
to get types to matchThis PR got merged!getWithdrawalStatus
only supports querying a transaction with a single withdrawal. This isn't very useful for us today since we usually multicall our withdrawals. We need something like this PR in order to use Viem to finalizeSuggested roadmap
Resources