Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"redis4": "npm:redis@^4.1.0",
"superstruct": "^1.0.3",
"ts-node": "^10.9.1",
"viem": "^2.33.0",
"viem": "^2.33.1",
"winston": "^3.10.0",
"zksync-ethers": "^5.7.2"
},
Expand All @@ -55,7 +55,7 @@
"main": "dist/index.js",
"scripts": {
"build-bigint-buffer": "[ -d node_modules/bigint-buffer ] && command -v node-gyp > /dev/null && cd node_modules/bigint-buffer && node-gyp configure && node-gyp build || echo 'Skipping bigint-buffer build: folder or node-gyp not found'",
"postinstall": "yarn build-bigint-buffer; yarn update-addresses",
"postinstall": "patch-package; yarn build-bigint-buffer; yarn update-addresses",
Copy link
Member Author

Choose a reason for hiding this comment

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

I left this in for now in case we ever decide to add patch-packages to the repo. They are pretty useful for quick fixes. The /patches/ folder is empty for now

"lint": "yarn eslint && yarn prettier --list-different",
"lint-fix": "yarn eslint --fix && yarn prettier --write",
"prettier": "prettier .",
Expand Down Expand Up @@ -105,6 +105,7 @@
"ethereum-waffle": "^4.0.10",
"hardhat-gas-reporter": "^1.0.9",
"node-gyp": "^11.0.0",
"patch-package": "^8.0.0",
"prettier": "^2.8.8",
"prettier-plugin-solidity": "^1.1.3",
"pretty-quick": "^3.1.3",
Expand Down
32 changes: 6 additions & 26 deletions src/finalizer/utils/opStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as viem from "viem";
import * as viemChains from "viem/chains";
import {
getWithdrawals,
GetWithdrawalStatusReturnType,
buildProveWithdrawal,
getWithdrawalStatus,
getL2Output,
Expand Down Expand Up @@ -49,7 +48,6 @@ import {
import { CONTRACT_ADDRESSES, OPSTACK_CONTRACT_OVERRIDES } from "../../common";
import OPStackPortalL1 from "../../common/abi/OpStackPortalL1.json";
import { FinalizerPromise, CrossChainMessage } from "../types";
import { BaseError } from "viem";
const { utils } = ethers;

interface CrossChainMessageWithEvent {
Expand Down Expand Up @@ -391,30 +389,12 @@ async function viem_multicallOptimismFinalizations(
hash: event.txnRef as `0x${string}`,
});
const withdrawal = getWithdrawals(receipt)[logIndexesForMessage[i]];
let withdrawalStatus: GetWithdrawalStatusReturnType;
try {
withdrawalStatus = await getWithdrawalStatus(publicClientL1 as viem.Client, {
receipt,
chain: publicClientL1.chain as viem.Chain,
targetChain: viemOpStackTargetChainParam,
logIndex: logIndexesForMessage[i],
});
} catch (error: unknown) {
// @dev: This is a temporary fix necessary because the latest version of Viem does not correctly handle the
// new OptimismPortal2's custom revert errors correctly and therefore the getWithdrawalStatus function
// does not correctly return the withdrawal status. We can remove this once this error reason is added
// here: https://github.com/wevm/viem/blob/4751e43e9c7b88de415f89a9d606d972104386b9/src/op-stack/actions/getWithdrawalStatus.ts#L286
// Note: 0xd9bc01be is the signature of the OptimismPortal_ProofNotOldEnough() revert error.
if ((error as BaseError).shortMessage.includes("0xd9bc01be")) {
// 0xd9bc01be = bytes4(keccak256("OptimismPortal_ProofNotOldEnough()"))
withdrawalStatus = "waiting-to-finalize";
} else if ((error as BaseError).shortMessage.includes("0xcca6afda")) {
// 0xcca6afda = bytes4(keccak256("OptimismPortal_Unproven()"))
withdrawalStatus = "waiting-to-prove";
} else {
throw error;
}
}
const withdrawalStatus = await getWithdrawalStatus(publicClientL1 as viem.Client, {
receipt,
chain: publicClientL1.chain as viem.Chain,
targetChain: viemOpStackTargetChainParam,
logIndex: logIndexesForMessage[i],
});
withdrawalStatuses.push(withdrawalStatus);
if (withdrawalStatus === "ready-to-prove") {
const l2Output = await getL2Output(publicClientL1 as viem.Client, {
Expand Down
Loading
Loading