diff --git a/packages/agents/lighthouse/example.http b/packages/agents/lighthouse/example.http new file mode 100644 index 0000000000..d0ce866495 --- /dev/null +++ b/packages/agents/lighthouse/example.http @@ -0,0 +1,10 @@ +@lighthouseUrl = https://lighthouse-prover-subscriber.mainnet.connext.ninja + +@adminToken = foo + +POST {{lighthouseUrl}}/clear-cache +Content-Type: application/json + +{ + "adminToken": "{{adminToken}}" +} diff --git a/packages/agents/lighthouse/package.json b/packages/agents/lighthouse/package.json index 7a14727341..90e5e4153b 100644 --- a/packages/agents/lighthouse/package.json +++ b/packages/agents/lighthouse/package.json @@ -27,7 +27,7 @@ "author": "Connext", "license": "ISC", "dependencies": { - "@arbitrum/sdk": "3.1.11", + "@arbitrum/sdk": "4.0.1", "@connext/nxtp-adapters-database": "workspace:*", "@connext/nxtp-adapters-relayer": "workspace:*", "@connext/nxtp-adapters-subgraph": "workspace:*", @@ -35,7 +35,7 @@ "@connext/nxtp-utils": "workspace:*", "@connext/smart-contracts": "workspace:*", "@consensys/linea-sdk": "0.1.6", - "@eth-optimism/sdk": "3.2.0", + "@eth-optimism/sdk": "3.3.2", "@mantleio/sdk": "1.0.0", "@sinclair/typebox": "0.25.21", "@types/aws-lambda": "8.10.110", diff --git a/packages/agents/lighthouse/src/mockable.ts b/packages/agents/lighthouse/src/mockable.ts index 95ce39dcaf..82232d94dd 100644 --- a/packages/agents/lighthouse/src/mockable.ts +++ b/packages/agents/lighthouse/src/mockable.ts @@ -9,8 +9,8 @@ import { getDeployedRootManagerContract as _getDeployedRootManagerContract } fro import { CrossChainMessenger as _OptimismCrossChainMessenger } from "@eth-optimism/sdk"; import { CrossChainMessenger as _MantleCrossChainMessenger } from "@mantleio/sdk"; import { sendWithRelayerWithBackup as _sendWithRelayerWithBackup } from "@connext/nxtp-adapters-relayer"; -import { EventFetcher as _EventFetcher, L2TransactionReceipt as _L2TransactionReceipt } from "@arbitrum/sdk"; -import { L1ToL2MessageGasEstimator } from "@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator"; +import { EventFetcher as _EventFetcher, ChildTransactionReceipt as _ChildTransactionReceipt } from "@arbitrum/sdk"; +import { ParentToChildMessageGasEstimator } from "@arbitrum/sdk/dist/lib/message/ParentToChildMessageGasEstimator"; import { getBaseFee as _getBaseFee } from "@arbitrum/sdk/dist/lib/utils/lib"; import { LineaSDK as _LineaSDK } from "@consensys/linea-sdk"; import { @@ -42,7 +42,7 @@ export const sendWithRelayerWithBackup = _sendWithRelayerWithBackup; export const EventFetcher = _EventFetcher; -export const L2TransactionReceipt = _L2TransactionReceipt; +export const ChildTransactionReceipt = _ChildTransactionReceipt; export const RollupUserLogic__factory = _RollupUserLogic__factory; @@ -72,8 +72,10 @@ export const getZkSyncWeb3Provider = (url: string): zk.Provider => { return new zk.Provider(url); }; -export const getL1ToL2MessageGasEstimator = (l2Provider: providers.JsonRpcProvider): L1ToL2MessageGasEstimator => { - return new L1ToL2MessageGasEstimator(l2Provider); +export const getParentToChildMessageGasEstimator = ( + l2Provider: providers.JsonRpcProvider, +): ParentToChildMessageGasEstimator => { + return new ParentToChildMessageGasEstimator(l2Provider); }; export const getContract = (address: string, abi: ContractInterface, provider?: providers.JsonRpcProvider) => diff --git a/packages/agents/lighthouse/src/tasks/processFromRoot/helpers/arbitrum.ts b/packages/agents/lighthouse/src/tasks/processFromRoot/helpers/arbitrum.ts index d906caa77a..c2bfdc4dc2 100644 --- a/packages/agents/lighthouse/src/tasks/processFromRoot/helpers/arbitrum.ts +++ b/packages/agents/lighthouse/src/tasks/processFromRoot/helpers/arbitrum.ts @@ -1,11 +1,11 @@ import { createLoggingContext, jsonifyError } from "@connext/nxtp-utils"; import { BigNumber, BigNumberish, utils } from "ethers"; -import { l2Networks } from "@arbitrum/sdk/dist/lib/dataEntities/networks"; +import { getChildrenForNetwork } from "@arbitrum/sdk"; import { NodeInterface__factory } from "@arbitrum/sdk/dist/lib/abi/factories/NodeInterface__factory"; import { getContext } from "../processFromRoot"; import { ConfirmDataDoesNotMatch, NoRootAvailable, RollUpNodeStaked } from "../errors"; -import { EventFetcher, JsonRpcProvider, L2TransactionReceipt, RollupUserLogic__factory } from "../../../mockable"; +import { EventFetcher, JsonRpcProvider, ChildTransactionReceipt, RollupUserLogic__factory } from "../../../mockable"; import { ArbitrumNodeCreatedEventsNotFound } from "../../../errors"; import { GetProcessArgsParams } from "."; @@ -37,7 +37,7 @@ export const getProcessFromArbitrumRootArgs = async ({ // // get the tx const spokeJsonProvider = new JsonRpcProvider(spokeProvider); const tx = await spokeJsonProvider.getTransactionReceipt(sendHash); - const l2TxnReceipt = new L2TransactionReceipt(tx); + const l2TxnReceipt = new ChildTransactionReceipt(tx); // @ts-ignore const dataIsOnL1 = await l2TxnReceipt.isDataAvailable(spokeJsonProvider); if (!dataIsOnL1) { @@ -45,7 +45,7 @@ export const getProcessFromArbitrumRootArgs = async ({ } // get the proof const hubJsonProvider = new JsonRpcProvider(hubProvider); - const [reader] = await l2TxnReceipt.getL2ToL1Messages(hubJsonProvider); + const [reader] = await l2TxnReceipt.getChildToParentMessages(hubJsonProvider); const msg = (reader as any).nitroReader; if (!msg?.event) { throw new Error(`Could not find event for message in ${sendHash}`); @@ -78,7 +78,7 @@ export const getProcessFromArbitrumRootArgs = async ({ // 2. (not used) Calculate the send root and the item hash using the `Outbox.sol` interface, then // find the event emitted after the `ethBlockNum` of the message containing a matching // sendRoot. Find the nodeNum from this event, and submit to chain (seen below) - const arbNetwork = l2Networks[spokeChainId]; + const arbNetwork = getChildrenForNetwork(hubChainId).find((n) => n.chainId === spokeChainId)!; const latest = await hubJsonProvider.getBlockNumber(); const fetcher = new EventFetcher(hubJsonProvider); logger.info("Fetching events", requestContext, methodContext, { @@ -105,7 +105,7 @@ export const getProcessFromArbitrumRootArgs = async ({ const log = logs[mid]; let sendCount = BigNumber.from(msg.event.position as BigNumberish); try { - const block = await msg.getBlockFromNodeLog(spokeJsonProvider, log); + const block = await msg.getBlockFromAssertionLog(spokeJsonProvider, log); sendCount = BigNumber.from(block.sendCount); } catch (e: unknown) { logger.warn("Failed to get block from node log", requestContext, methodContext, { @@ -116,6 +116,7 @@ export const getProcessFromArbitrumRootArgs = async ({ if (sendCount.gt(msg.event.position as BigNumberish)) { foundLog = log; right = mid - 1; + left = right + 1; } else { left = mid + 1; } @@ -123,7 +124,7 @@ export const getProcessFromArbitrumRootArgs = async ({ const earliestNodeWithExit = foundLog.event.nodeNum; const rollup = RollupUserLogic__factory.getContract(arbNetwork.ethBridge.rollup, RollupUserLogic__factory.abi); - const foundBlock = await msg.getBlockFromNodeNum( + const foundBlock = await msg.getBlockFromAssertionId( rollup.connect(hubJsonProvider), earliestNodeWithExit, spokeJsonProvider, diff --git a/packages/agents/lighthouse/src/tasks/propagate/helpers/arbitrum.ts b/packages/agents/lighthouse/src/tasks/propagate/helpers/arbitrum.ts index b1215d96c4..5866c37e8d 100644 --- a/packages/agents/lighthouse/src/tasks/propagate/helpers/arbitrum.ts +++ b/packages/agents/lighthouse/src/tasks/propagate/helpers/arbitrum.ts @@ -6,7 +6,7 @@ import { NoSpokeConnector, NoHubConnector, NoProviderForDomain } from "../errors import { ExtraPropagateParam } from "../operations/propagate"; import { getJsonRpcProvider, - getL1ToL2MessageGasEstimator, + getParentToChildMessageGasEstimator, getBaseFee, getInterface, getBestProvider, @@ -62,7 +62,7 @@ export const getPropagateParams = async ( try { const l2Provider = getJsonRpcProvider(l2RpcUrl); - const l1ToL2MessageGasEstimate = getL1ToL2MessageGasEstimator(l2Provider); + const l1ToL2MessageGasEstimate = getParentToChildMessageGasEstimator(l2Provider); // example encoded payload: 0x4ff746f6000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000207465737400000000000000000000000000000000000000000000000000000000 // length = 200 not including 0x = 100 bytes diff --git a/packages/agents/lighthouse/test/tasks/processFromRoot/helpers/arbitrum.spec.ts b/packages/agents/lighthouse/test/tasks/processFromRoot/helpers/arbitrum.spec.ts index 64182017e7..5f0626d7ea 100644 --- a/packages/agents/lighthouse/test/tasks/processFromRoot/helpers/arbitrum.spec.ts +++ b/packages/agents/lighthouse/test/tasks/processFromRoot/helpers/arbitrum.spec.ts @@ -1,6 +1,6 @@ import { Logger, createRequestContext, expect, mkHash } from "@connext/nxtp-utils"; import { stub, SinonStub, createStubInstance, SinonStubbedInstance, spy } from "sinon"; -import { L2ToL1MessageReader } from "@arbitrum/sdk"; +import { ChildToParentMessageReader } from "@arbitrum/sdk"; import { NodeInterface__factory } from "@arbitrum/sdk/dist/lib/abi/factories/NodeInterface__factory"; import * as MockableFns from "../../../../src/mockable"; @@ -20,14 +20,14 @@ class MockJsonRpcProvider { } let isDataAvailableStub: SinonStub; -let l2ToL1MessageReader: SinonStubbedInstance; +let l2ToL1MessageReader: SinonStubbedInstance; class MockL2TransactionReceipt { public isDataAvailable = isDataAvailableStub; - public getL2ToL1Messages = stub().resolves([l2ToL1MessageReader]); + public getChildToParentMessages = stub().resolves([l2ToL1MessageReader]); } class MockL2TransactionReceiptTemp { public isDataAvailable = isDataAvailableStub; - public getL2ToL1Messages = stub().resolves([{}]); + public getChildToParentMessages = stub().resolves([{}]); } class MockEventFetcher { @@ -49,11 +49,11 @@ describe("Helpers: Arbitrum", () => { let confirmData: SinonStub; beforeEach(() => { isDataAvailableStub = stub().resolves(true); - l2ToL1MessageReader = createStubInstance(L2ToL1MessageReader, { + l2ToL1MessageReader = createStubInstance(ChildToParentMessageReader, { getOutboxProof: Promise.resolve(["hello", "world"]), } as any); (l2ToL1MessageReader as any).nitroReader = { - getBlockFromNodeNum: (...args: any) => + getBlockFromAssertionId: (...args: any) => Promise.resolve({ blockNumber: constants.One, nodeNum: constants.One, @@ -61,7 +61,7 @@ describe("Helpers: Arbitrum", () => { sendCount: constants.One, hash: mkHash("0x456"), } as any), - getBlockFromNodeLog: (...args: any) => + getBlockFromAssertionLog: (...args: any) => Promise.resolve({ blockNumber: constants.One, nodeNum: constants.One, @@ -71,7 +71,7 @@ describe("Helpers: Arbitrum", () => { } as any), event: { position: constants.One, ethBlockNum: constants.One }, }; - stub(MockableFns, "L2TransactionReceipt").value(MockL2TransactionReceipt); + stub(MockableFns, "ChildTransactionReceipt").value(MockL2TransactionReceipt); stub(MockableFns, "JsonRpcProvider").value(MockJsonRpcProvider); stub(MockableFns, "EventFetcher").value(MockEventFetcher); stub(MockableFns, "Outbox__factory").value(mockOutboxFactory); @@ -101,6 +101,7 @@ describe("Helpers: Arbitrum", () => { isDataAvailableStub.resolves(false); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -119,6 +120,7 @@ describe("Helpers: Arbitrum", () => { confirmData.returns([{ confirmData: "0xfoo" }]); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -143,6 +145,7 @@ describe("Helpers: Arbitrum", () => { ]); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -167,6 +170,7 @@ describe("Helpers: Arbitrum", () => { ]); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -182,9 +186,10 @@ describe("Helpers: Arbitrum", () => { }); it("should throw error in case msg event is not present", async () => { - stub(MockableFns, "L2TransactionReceipt").value(MockL2TransactionReceiptTemp); + stub(MockableFns, "ChildTransactionReceipt").value(MockL2TransactionReceiptTemp); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -201,6 +206,7 @@ describe("Helpers: Arbitrum", () => { it("should work", async () => { const args = await getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -219,6 +225,7 @@ describe("Helpers: Arbitrum", () => { stub(MockableFns, "EventFetcher").value(MockEventFetcherError); await expect( getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", @@ -235,7 +242,7 @@ describe("Helpers: Arbitrum", () => { it("should have warning in getBlockFromNodeLog fails", async () => { (l2ToL1MessageReader as any).nitroReader = { - getBlockFromNodeNum: (...args: any) => + getBlockFromAssertionId: (...args: any) => Promise.resolve({ blockNumber: constants.One, nodeNum: constants.One, @@ -243,7 +250,7 @@ describe("Helpers: Arbitrum", () => { sendCount: constants.One, hash: mkHash("0x456"), } as any), - getBlockFromNodeLog: (...args: any) => + getBlockFromAssertionLog: (...args: any) => Promise.reject({ blockNumber: constants.One, nodeNum: constants.One, @@ -256,6 +263,7 @@ describe("Helpers: Arbitrum", () => { const loggerSpy = spy(getContext().logger, "warn"); const args = await getProcessFromArbitrumRootArgs({ + isSpokeClaim: false, spokeChainId: 42161, spokeDomainId: "1", spokeProvider: "world", diff --git a/packages/agents/lighthouse/test/tasks/propagate/helpers/arbitrum.spec.ts b/packages/agents/lighthouse/test/tasks/propagate/helpers/arbitrum.spec.ts index 28c2a099d6..3456925ba4 100644 --- a/packages/agents/lighthouse/test/tasks/propagate/helpers/arbitrum.spec.ts +++ b/packages/agents/lighthouse/test/tasks/propagate/helpers/arbitrum.spec.ts @@ -7,19 +7,22 @@ import * as Mockable from "../../../../src/mockable"; import { getPropagateParams } from "../../../../src/tasks/propagate/helpers/arbitrum"; import { getInterfaceMock, propagateCtxMock, getBestProviderMock } from "../../../globalTestHook"; import { mock } from "../../../mock"; -import { L1ToL2MessageGasEstimator } from "@arbitrum/sdk"; +import { ParentToChildMessageGasEstimator } from "@arbitrum/sdk"; const requestContext = createRequestContext("test"); const estimateSubmissionFee = Promise.resolve(constants.One); const estimateRetryableTicketGasLimit = Promise.resolve(constants.Two); -let l1ToL2: SinonStubbedInstance; +let l1ToL2: SinonStubbedInstance; describe("Helpers: Arbitrum ", () => { beforeEach(() => { - l1ToL2 = createStubInstance(L1ToL2MessageGasEstimator, { estimateSubmissionFee, estimateRetryableTicketGasLimit }); + l1ToL2 = createStubInstance(ParentToChildMessageGasEstimator, { + estimateSubmissionFee, + estimateRetryableTicketGasLimit, + }); stub(Mockable, "getJsonRpcProvider").returns(createStubInstance(providers.JsonRpcProvider)); - stub(Mockable, "getL1ToL2MessageGasEstimator").returns(l1ToL2); + stub(Mockable, "getParentToChildMessageGasEstimator").returns(l1ToL2); stub(Mockable, "getBaseFee").resolves(BigNumber.from(1)); getInterfaceMock.returns({ encodeFunctionData: stub().resolves(mkBytes32("0xcalldadta")) }); }); diff --git a/packages/deployments/contracts/package.json b/packages/deployments/contracts/package.json index 61c958e88f..0cef63ee83 100644 --- a/packages/deployments/contracts/package.json +++ b/packages/deployments/contracts/package.json @@ -51,10 +51,10 @@ "author": "Connext", "license": "ISC", "dependencies": { - "@eth-optimism/sdk": "3.2.0" + "@eth-optimism/sdk": "3.3.2" }, "devDependencies": { - "@arbitrum/sdk": "3.1.11", + "@arbitrum/sdk": "4.0.1", "@certusone/wormhole-sdk": "0.9.21", "@connext/nxtp-utils": "workspace:*", "@consensys/linea-sdk": "0.1.6", diff --git a/packages/deployments/contracts/src/cli/op-mode/switchMode.ts b/packages/deployments/contracts/src/cli/op-mode/switchMode.ts index da1510b283..255b25494d 100644 --- a/packages/deployments/contracts/src/cli/op-mode/switchMode.ts +++ b/packages/deployments/contracts/src/cli/op-mode/switchMode.ts @@ -1,6 +1,6 @@ import commandLineArgs from "command-line-args"; -import { Wallet } from "ethers"; +import { Contract, Wallet } from "ethers"; import { Env, getProviderFromHardhatConfig } from "../.."; import { SUPPORTED_DOMAINS, HUBS, updateIfNeeded } from "../helpers"; import { @@ -107,6 +107,17 @@ export const switchMode = async () => { // Update SpokeConnector console.log(`\tUpdating SpokeConnector (${deployments.SpokeConnector.address})...`); + const owner = await deployments.SpokeConnector.contract.owner(); + const contract = new Contract( + owner, + ["function getThreshold() view returns (uint256)"], + deployments.SpokeConnector.contract.provider, + ); + let threshold = "N/A"; + try { + threshold = await contract.getThreshold(); + } catch (e) {} + console.log(`\t\tOwner: ${owner}, threshold: ${threshold}`); await updateIfNeeded( optimistic ? { diff --git a/packages/deployments/contracts/tasks/connector/processFromRoot.ts b/packages/deployments/contracts/tasks/connector/processFromRoot.ts index 78fcd94eee..8dfdd5ac46 100644 --- a/packages/deployments/contracts/tasks/connector/processFromRoot.ts +++ b/packages/deployments/contracts/tasks/connector/processFromRoot.ts @@ -1,8 +1,8 @@ import { task } from "hardhat/config"; -import { EventFetcher, L2TransactionReceipt } from "@arbitrum/sdk"; +import { EventFetcher, ChildTransactionReceipt, getChildrenForNetwork } from "@arbitrum/sdk"; + import { BigNumber, BigNumberish, constants, Contract, providers, Wallet } from "ethers"; import { defaultAbiCoder, keccak256 } from "ethers/lib/utils"; -import { l2Networks } from "@arbitrum/sdk/dist/lib/dataEntities/networks"; import { DEFAULT_L2_CONTRACT_ADDRESSES, CrossChainMessenger as OptimismCrossChainMessenger, @@ -53,7 +53,7 @@ const processFromPolygonRoot = async (spoke: number, sendHash: string, hubProvid SEND_MESSAGE_EVENT_SIG, providerMapping, ); - if (!hash || !payload) { + if (!payload) { throw new Error(`no hash or payload. already or not yet ready to be processed`); } console.log("hash: ", hash); @@ -75,16 +75,16 @@ const processFromArbitrumRoot = async ( // // uint256 _index, x // // L2Message calldata _message x // // get the tx - const l2TxnReceipt = new L2TransactionReceipt(await spokeProvider.getTransactionReceipt(sendHash)); + const l2TxnReceipt = new ChildTransactionReceipt(await spokeProvider.getTransactionReceipt(sendHash)); // @ts-ignore const dataIsOnL1 = await l2TxnReceipt.isDataAvailable(spokeProvider); if (!dataIsOnL1) { throw new Error(`tx data not yet posted to l1`); } // get the proof - const [reader] = await l2TxnReceipt.getL2ToL1Messages(hubProvider); + const [reader] = await l2TxnReceipt.getChildToParentMessages(hubProvider); console.log("msg:", (reader as any).nitroReader.event); - const msg = (reader as any).nitroReader; + const msg = (reader as any).nitroReader; //as nitro.ChildToParentMessageReaderNitro; if (!msg?.event) { throw new Error(`Could not find event for message in ${sendHash}`); } @@ -115,13 +115,17 @@ const processFromArbitrumRoot = async ( // 2. Calculate the send root and the item hash using the `Outbox.sol` interface, then // find the event emitted after the `ethBlockNum` of the message containing a matching // sendRoot. Find the nodeNum from this event, and submit to chain. Not used. - const arbNetwork = l2Networks[spoke]; + const arbNetwork = getChildrenForNetwork(1).find((n) => n.chainId === spoke); + if (!arbNetwork) { + throw new Error(`could not find arbitrum child network for spoke ${spoke}`); + } const fetcher = new EventFetcher(hubProvider); console.log("searching for node created events at", arbNetwork.ethBridge.rollup); const logs = await fetcher.getEvents(RollupUserLogic__factory, (t) => t.filters.NodeCreated(), { fromBlock: msg.event.ethBlockNum.toNumber(), toBlock: "latest", }); + console.log("found", logs.length, "logs to sort through. searching for send count >", msg.event.position.toString()); // use binary search to find the first node with sendCount > this.event.position // default to the last node since we already checked above let foundLog: FetchedEvent = logs[logs.length - 1]; @@ -130,11 +134,18 @@ const processFromArbitrumRoot = async ( while (left <= right) { const mid = Math.floor((left + right) / 2); const log = logs[mid]; - const block = await msg.getBlockFromNodeLog(spokeProvider, log); - const sendCount = BigNumber.from(block.sendCount); + let sendCount = BigNumber.from(0); + try { + const block = await msg.getBlockFromAssertionLog(spokeProvider, log); + sendCount = BigNumber.from(block.sendCount); + } catch (e) { + console.warn("failed to get block:", e); + } + console.log("- sendCount", sendCount.toString()); if (sendCount.gt(msg.event.position as BigNumberish)) { foundLog = log; right = mid - 1; + left = right + 1; } else { left = mid + 1; } @@ -146,7 +157,7 @@ const processFromArbitrumRoot = async ( RollupUserLogic__factory.abi, deployer.connect(hubProvider), ); - const foundBlock = await msg.getBlockFromNodeNum(rollup, earliestNodeWithExit, spokeProvider); + const foundBlock = await msg.getBlockFromAssertionId(rollup, earliestNodeWithExit, spokeProvider); console.log("node:", earliestNodeWithExit.toString()); console.log("msg.position", msg.event.position.toString()); console.log("foundLog:", foundLog); @@ -324,7 +335,7 @@ export default task("process-from-root", "Call `Connector.processFromRoot()` to .addOptionalParam("networkType", "Type of network of contracts") .setAction( async ({ env: _env, tx: sendHash, spoke: _spoke, networkType: _networkType }: TaskArgs, { deployments }) => { - const deployer = Wallet.fromMnemonic(process.env.MAINNET_MNEMONIC!); + const deployer = Wallet.fromMnemonic(process.env.MAINNET_MNEMONIC ?? process.env.MNEMONIC!); const env = mustGetEnv(_env); const spoke = +_spoke; @@ -354,6 +365,7 @@ export default task("process-from-root", "Call `Connector.processFromRoot()` to args = await processFromOptimismRoot(spoke, sendHash, protocolConfig, l2Provider, l1Provider); break; case "Arbitrum": + method = "processMessageFromRoot"; args = await processFromArbitrumRoot(spoke, sendHash, l2Provider, l1Provider, deployer); break; case "Polygon": diff --git a/packages/deployments/contracts/tasks/connector/redeem.ts b/packages/deployments/contracts/tasks/connector/redeem.ts index dbe6c0f785..79034af550 100644 --- a/packages/deployments/contracts/tasks/connector/redeem.ts +++ b/packages/deployments/contracts/tasks/connector/redeem.ts @@ -1,4 +1,4 @@ -import { L1ToL2MessageStatus, L1TransactionReceipt } from "@arbitrum/sdk"; +import { ParentToChildMessageStatus, ParentTransactionReceipt } from "@arbitrum/sdk"; import { providers, Wallet } from "ethers"; import { task } from "hardhat/config"; @@ -26,16 +26,16 @@ const redeemFromArbitrum = async ( spokeProvider: providers.JsonRpcProvider, ) => { // Get the message receipt from arbitrum sdk - const receipt = new L1TransactionReceipt(await hubProvider.getTransactionReceipt(hash)); + const receipt = new ParentTransactionReceipt(await hubProvider.getTransactionReceipt(hash)); console.log("got l1 -> l2 message receipt on l1", receipt.transactionHash); // get the mesesage (assume only one arb message in receipt) - const [message] = await receipt.getL1ToL2Messages(signer.connect(spokeProvider)); + const [message] = await receipt.getParentToChildMessages(signer.connect(spokeProvider)); const { status } = await message.waitForStatus(); console.log("got l1 -> l2 message", message); // check to see if it needs redemption - if (status != L1ToL2MessageStatus.FUNDS_DEPOSITED_ON_L2) { + if (status != ParentToChildMessageStatus.FUNDS_DEPOSITED_ON_CHILD) { throw new Error(`Not ready to redeem, or was auto-redeemed. Status: ${status}`); } diff --git a/packages/utils/src/maticjs/error.ts b/packages/utils/src/maticjs/error.ts index 90d4f2cd23..0a68c906c6 100644 --- a/packages/utils/src/maticjs/error.ts +++ b/packages/utils/src/maticjs/error.ts @@ -4,6 +4,7 @@ export enum MaticJsErrorType { BlockNotIncluded = "no_block_found", IncorrectTx = "incorrect_transaction", TxNotCheckpointed = "transaction_not_checkpointed", + NoExitHash = "no_exit_hash", } // custom errors for better error handling diff --git a/packages/utils/src/maticjs/proof.ts b/packages/utils/src/maticjs/proof.ts index c7698bbbd3..a8cbbd604f 100644 --- a/packages/utils/src/maticjs/proof.ts +++ b/packages/utils/src/maticjs/proof.ts @@ -64,7 +64,7 @@ export const generateExitPayload = async ( try { exitHash = await maticClient.exitUtil.getExitHash(burnTxHash, 0, eventSignature); } catch (error: any) { - throw new InfoError(MaticJsErrorType.TxNotCheckpointed, "Burn transaction has not been checkpointed yet"); + throw new InfoError(MaticJsErrorType.NoExitHash, "Could not retrieve the exit hash"); } // build payload for exit diff --git a/yarn.lock b/yarn.lock index 47f35db495..159984c4eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -70,15 +70,16 @@ __metadata: languageName: node linkType: hard -"@arbitrum/sdk@npm:3.1.11": - version: 3.1.11 - resolution: "@arbitrum/sdk@npm:3.1.11" +"@arbitrum/sdk@npm:4.0.1": + version: 4.0.1 + resolution: "@arbitrum/sdk@npm:4.0.1" dependencies: "@ethersproject/address": ^5.0.8 "@ethersproject/bignumber": ^5.1.1 "@ethersproject/bytes": ^5.0.8 + async-mutex: ^0.4.0 ethers: ^5.1.0 - checksum: 79066b07d685755c53f4d7a2862f84c189ab07207d7c4cf8909b540cfbeb07007fec5d7cb9057c2c01df4ee196653cdbe17674bf80eb45bf2fb64f07b8d5f6a2 + checksum: 7404c019563538c078f24b9f965d99ca5080435cd681628ac0f7aef2f7777806ec10ffcb3b31ccb9b44d951572ed219cfc1bde8f5a3f0878b7cbd9af4b4b334d languageName: node linkType: hard @@ -2428,7 +2429,7 @@ __metadata: version: 0.0.0-use.local resolution: "@connext/lighthouse@workspace:packages/agents/lighthouse" dependencies: - "@arbitrum/sdk": 3.1.11 + "@arbitrum/sdk": 4.0.1 "@connext/nxtp-adapters-database": "workspace:*" "@connext/nxtp-adapters-relayer": "workspace:*" "@connext/nxtp-adapters-subgraph": "workspace:*" @@ -2436,7 +2437,7 @@ __metadata: "@connext/nxtp-utils": "workspace:*" "@connext/smart-contracts": "workspace:*" "@consensys/linea-sdk": 0.1.6 - "@eth-optimism/sdk": 3.2.0 + "@eth-optimism/sdk": 3.3.2 "@graphql-codegen/cli": 3.0.0 "@mantleio/sdk": 1.0.0 "@sinclair/typebox": 0.25.21 @@ -2946,11 +2947,11 @@ __metadata: version: 0.0.0-use.local resolution: "@connext/smart-contracts@workspace:packages/deployments/contracts" dependencies: - "@arbitrum/sdk": 3.1.11 + "@arbitrum/sdk": 4.0.1 "@certusone/wormhole-sdk": 0.9.21 "@connext/nxtp-utils": "workspace:*" "@consensys/linea-sdk": 0.1.6 - "@eth-optimism/sdk": 3.2.0 + "@eth-optimism/sdk": 3.3.2 "@gelatonetwork/relay-context": 2.1.0 "@mantleio/sdk": 1.0.0 "@matterlabs/hardhat-zksync-deploy": 0.6.3 @@ -3465,13 +3466,6 @@ __metadata: languageName: node linkType: hard -"@eth-optimism/contracts-bedrock@npm:0.17.1": - version: 0.17.1 - resolution: "@eth-optimism/contracts-bedrock@npm:0.17.1" - checksum: ae75458ca843dc36d050a484a97226112d1c5a1453cb8a59a1a64e4805052984663b2d83ca1a2764751ea182e09ee53ddc1ab19c6a94885a6e743371498060a2 - languageName: node - linkType: hard - "@eth-optimism/contracts@npm:0.6.0": version: 0.6.0 resolution: "@eth-optimism/contracts@npm:0.6.0" @@ -3509,9 +3503,9 @@ __metadata: languageName: node linkType: hard -"@eth-optimism/core-utils@npm:0.13.1": - version: 0.13.1 - resolution: "@eth-optimism/core-utils@npm:0.13.1" +"@eth-optimism/core-utils@npm:^0.13.2": + version: 0.13.2 + resolution: "@eth-optimism/core-utils@npm:0.13.2" dependencies: "@ethersproject/abi": ^5.7.0 "@ethersproject/abstract-provider": ^5.7.0 @@ -3524,27 +3518,26 @@ __metadata: "@ethersproject/properties": ^5.7.0 "@ethersproject/rlp": ^5.7.0 "@ethersproject/web": ^5.7.1 - chai: ^4.3.9 + chai: ^4.3.10 ethers: ^5.7.2 node-fetch: ^2.6.7 - checksum: ed1f1bcec4fd308463c6bd6e6cc8f6c89041dfa5e0c03c67ee487f5b3bef7bb34c59ea1f8039d00cc0e8696ed8ae9a4486c10d86b2db1d9dadb94294fc83b6fc + checksum: 4603b4a43b06d4b8117bdfa8175709a7ff8c708d7b439c16997c590fed976ee3b2989362b47aad4ffdbce0c1f9b8f86140d308e55fa553d2daaae1ba054ae927 languageName: node linkType: hard -"@eth-optimism/sdk@npm:3.2.0": - version: 3.2.0 - resolution: "@eth-optimism/sdk@npm:3.2.0" +"@eth-optimism/sdk@npm:3.3.2": + version: 3.3.2 + resolution: "@eth-optimism/sdk@npm:3.3.2" dependencies: "@eth-optimism/contracts": 0.6.0 - "@eth-optimism/contracts-bedrock": 0.17.1 - "@eth-optimism/core-utils": 0.13.1 + "@eth-optimism/core-utils": ^0.13.2 lodash: ^4.17.21 merkletreejs: ^0.3.11 rlp: ^2.2.7 - semver: ^7.5.4 + semver: ^7.6.0 peerDependencies: ethers: ^5 - checksum: e8101a3d9c3dde9f02bc0862aa1afe68235505976b27e1ea1bcb4524d4fd9531fdb66dcbb841ff3f8b38fd9110a51260f38a434532d72b6857710c1d76a1d2a4 + checksum: d24707c9540a5e9c7f4a123e7dd085ebd4cfa861ffce3fb124bd3c7c92da5d7c92ddf488582cfc3cda17bde010cfda5812c183750ae9cd0ebae913328eae47c2 languageName: node linkType: hard @@ -10739,6 +10732,15 @@ __metadata: languageName: node linkType: hard +"async-mutex@npm:^0.4.0": + version: 0.4.1 + resolution: "async-mutex@npm:0.4.1" + dependencies: + tslib: ^2.4.0 + checksum: cb529c0d257c8ff8e5b26c81b36127a255e545edee2c42c76247d533b89a7664037d95f33130f964de49b111ad3324ead8dcccd419c47acdfeb7413ed93063a1 + languageName: node + linkType: hard + "async-retry@npm:^1.3.1": version: 1.3.3 resolution: "async-retry@npm:1.3.3" @@ -12876,7 +12878,22 @@ __metadata: languageName: node linkType: hard -"chai@npm:^4.3.4, chai@npm:^4.3.9": +"chai@npm:^4.3.10": + version: 4.5.0 + resolution: "chai@npm:4.5.0" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.3 + deep-eql: ^4.1.3 + get-func-name: ^2.0.2 + loupe: ^2.3.6 + pathval: ^1.1.1 + type-detect: ^4.1.0 + checksum: 70e5a8418a39e577e66a441cc0ce4f71fd551a650a71de30dd4e3e31e75ed1f5aa7119cf4baf4a2cb5e85c0c6befdb4d8a05811fad8738c1a6f3aa6a23803821 + languageName: node + linkType: hard + +"chai@npm:^4.3.4": version: 4.4.1 resolution: "chai@npm:4.4.1" dependencies: @@ -28141,7 +28158,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4": +"semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.3": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -28152,6 +28169,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.6.0": + version: 7.6.3 + resolution: "semver@npm:7.6.3" + bin: + semver: bin/semver.js + checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8 + languageName: node + linkType: hard + "semver@npm:~5.4.1": version: 5.4.1 resolution: "semver@npm:5.4.1" @@ -30735,6 +30761,13 @@ __metadata: languageName: node linkType: hard +"type-detect@npm:^4.1.0": + version: 4.1.0 + resolution: "type-detect@npm:4.1.0" + checksum: 3b32f873cd02bc7001b00a61502b7ddc4b49278aabe68d652f732e1b5d768c072de0bc734b427abf59d0520a5f19a2e07309ab921ef02018fa1cb4af155cdb37 + languageName: node + linkType: hard + "type-fest@npm:^0.18.0": version: 0.18.1 resolution: "type-fest@npm:0.18.1"