Skip to content

Commit

Permalink
Merge pull request #5748 from connext/5704-implement-mode-connectors
Browse files Browse the repository at this point in the history
fix: mode mainnet LH works
  • Loading branch information
wanglonghong authored Feb 23, 2024
2 parents e233f30 + 742ba45 commit 8a253b8
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 104 deletions.
2 changes: 1 addition & 1 deletion packages/agents/lighthouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@connext/nxtp-utils": "workspace:*",
"@connext/smart-contracts": "workspace:*",
"@consensys/linea-sdk": "0.1.6",
"@eth-optimism/sdk": "2.1.0",
"@eth-optimism/sdk": "3.2.0",
"@mantleio/sdk": "1.0.0",
"@sinclair/typebox": "0.25.21",
"@types/aws-lambda": "8.10.110",
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/lighthouse/src/mockable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Contract, ContractInterface, ethers, providers, utils } from "ethers";
import * as zk from "zksync-web3";

import { getProcessFromMetisRootArgs as _getMessagesByTransaction } from "./tasks/processFromRoot/helpers/metis/args";
import { getMessagesByTransaction as _getMessagesByTransaction } from "./tasks/processFromRoot/helpers/metis/utils";

export const getDeployedRootManagerContract = _getDeployedRootManagerContract;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
export * from "./args";
import { createLoggingContext } from "@connext/nxtp-utils";
import { CrossChainMessageProof, DEFAULT_L2_CONTRACT_ADDRESSES } from "@eth-optimism/sdk";
import { BigNumber, providers } from "ethers";

import { OptimismCrossChainMessenger } from "../../../../mockable";
import { NoRootAvailable } from "../../errors";
import { getContext } from "../../processFromRoot";
import { GetProcessArgsParams } from "..";

import { getMessageProof, getMessageStateRoot, getMessagesByTransaction } from "./utils";

/**
* This is for pre-bedrock versions of the optimism contracts. Currently, this is used by:
* - Mantle
* - Metis
*/
export const getProcessFromMetisRootArgs = async ({
spokeChainId,
hubChainId,
spokeProvider,
hubProvider,
sendHash,
_requestContext,
}: GetProcessArgsParams): Promise<[string, string, string, BigNumber, CrossChainMessageProof]> => {
const { logger } = getContext();
const { requestContext, methodContext } = createLoggingContext(getProcessFromMetisRootArgs.name, _requestContext);
logger.info("Method start", requestContext, methodContext);
// When processing from root on optimism, you need the following information:
// address _target, -> connector
// address _sender, -> mirror connector
// bytes memory _message, -> calldata
// uint256 _messageNonce, -> ?
// L2MessageInclusionProof memory _proof -> taken from sdk

// create the messenger
const messenger = new OptimismCrossChainMessenger({
l2ChainId: spokeChainId,
l2SignerOrProvider: new providers.JsonRpcProvider(spokeProvider),
l1ChainId: hubChainId,
l1SignerOrProvider: new providers.JsonRpcProvider(hubProvider),
contracts: {
l1: {
AddressManager: "0x918778e825747a892b17C66fe7D24C618262867d",
L1CrossDomainMessenger: "0x081D1101855bD523bA69A9794e0217F0DB6323ff",
L1StandardBridge: "0x3980c9ed79d2c191A89E02Fa3529C60eD6e9c04b",
StateCommitmentChain: "0xf209815E595Cdf3ed0aAF9665b1772e608AB9380",
CanonicalTransactionChain: "0x56a76bcC92361f6DF8D75476feD8843EdC70e1C9",
BondManager: "0xf51B9C9a1c12e7E48BEC15DC358D0C1f0d7Eb3be",
OptimismPortal: "0x0000000000000000000000000000000000000000",
L2OutputOracle: "0x0000000000000000000000000000000000000000",
},
l2: DEFAULT_L2_CONTRACT_ADDRESSES,
},
bedrock: false,
});

// check to make sure you can prove
const root = await getMessageStateRoot(messenger, sendHash);
if (!root) {
throw new NoRootAvailable(spokeChainId, hubChainId, requestContext, methodContext);
}

// get the message to get the message nonce
const [message] = await getMessagesByTransaction(messenger, sendHash);
logger.info("Got message from metis", requestContext, methodContext, { message });

// get the inclusion proof
const proof = await getMessageProof(messenger, sendHash);
logger.info("Got proof from metis", requestContext, methodContext, { proof });

return [message.target, message.sender, message.message, message.messageNonce, proof];
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export const getProcessFromModeRootArgs = async ({
contracts: {
l1: {
AddressManager: "0x50eF494573f28Cad6B64C31b7a00Cdaa48306e15",
L1CrossDomainMessenger: "0x735aDBbE72226BD52e818E7181953f42E3b0FF21",
L1StandardBridge: "0x9c67ACcb38137CB761587032179b176c9276Eb5a",
L1CrossDomainMessenger: "0x95bDCA6c8EdEB69C98Bd5bd17660BaCef1298A6f",
L1StandardBridge: "0x735aDBbE72226BD52e818E7181953f42E3b0FF21",
StateCommitmentChain: "0x0000000000000000000000000000000000000000",
CanonicalTransactionChain: "0x0000000000000000000000000000000000000000",
BondManager: "0x0000000000000000000000000000000000000000",
OptimismPortal: "0xad3DC277d3242938F8Be18f0560e3d9B9988C46A",
OptimismPortal: "0x8B34b14c7c7123459Cf3076b8Cb929BE097d0C07",
L2OutputOracle: "0x4317ba146D4933D889518a3e5E11Fe7a53199b04",
},
l2: DEFAULT_L2_CONTRACT_ADDRESSES,
Expand Down Expand Up @@ -84,7 +84,7 @@ export const getProcessFromModeRootArgs = async ({
gasLimit,
data,
};
logger.info("Got withdrawal tx from optimism", requestContext, methodContext, { tx });
logger.info("Got withdrawal tx from mode", requestContext, methodContext, { tx });

// get the proof
const proof = await messenger.getBedrockMessageProof(sendHash);
Expand Down
2 changes: 1 addition & 1 deletion packages/deployments/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"author": "Connext",
"license": "ISC",
"dependencies": {
"@eth-optimism/sdk": "2.1.0"
"@eth-optimism/sdk": "3.2.0"
},
"devDependencies": {
"@arbitrum/sdk": "3.1.11",
Expand Down
75 changes: 51 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ __metadata:
"@connext/nxtp-utils": "workspace:*"
"@connext/smart-contracts": "workspace:*"
"@consensys/linea-sdk": 0.1.6
"@eth-optimism/sdk": 2.1.0
"@eth-optimism/sdk": 3.2.0
"@graphql-codegen/cli": 3.0.0
"@mantleio/sdk": 1.0.0
"@sinclair/typebox": 0.25.21
Expand Down Expand Up @@ -2933,7 +2933,7 @@ __metadata:
"@certusone/wormhole-sdk": 0.9.21
"@connext/nxtp-utils": "workspace:*"
"@consensys/linea-sdk": 0.1.6
"@eth-optimism/sdk": 2.1.0
"@eth-optimism/sdk": 3.2.0
"@gelatonetwork/relay-context": 2.1.0
"@mantleio/sdk": 1.0.0
"@matterlabs/hardhat-zksync-deploy": 0.6.3
Expand Down Expand Up @@ -3448,15 +3448,10 @@ __metadata:
languageName: node
linkType: hard

"@eth-optimism/contracts-bedrock@npm:0.14.0":
version: 0.14.0
resolution: "@eth-optimism/contracts-bedrock@npm:0.14.0"
dependencies:
"@eth-optimism/core-utils": ^0.12.0
"@openzeppelin/contracts": 4.7.3
"@openzeppelin/contracts-upgradeable": 4.7.3
ethers: ^5.7.0
checksum: ca9abf55660573b0dbd701d5154d8d083b7fdb4e49951678e30acf97e5e161d202e62a17fbff7fbdbe36dd61128598b169d7c8c8cd913db80adaaa6b5a5ac79c
"@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

Expand Down Expand Up @@ -3497,9 +3492,9 @@ __metadata:
languageName: node
linkType: hard

"@eth-optimism/core-utils@npm:^0.12.0":
version: 0.12.3
resolution: "@eth-optimism/core-utils@npm:0.12.3"
"@eth-optimism/core-utils@npm:0.13.1":
version: 0.13.1
resolution: "@eth-optimism/core-utils@npm:0.13.1"
dependencies:
"@ethersproject/abi": ^5.7.0
"@ethersproject/abstract-provider": ^5.7.0
Expand All @@ -3512,26 +3507,27 @@ __metadata:
"@ethersproject/properties": ^5.7.0
"@ethersproject/rlp": ^5.7.0
"@ethersproject/web": ^5.7.1
chai: ^4.3.7
chai: ^4.3.9
ethers: ^5.7.2
node-fetch: ^2.6.7
checksum: c1ac822d2829c1a2bf8654ab1374fbb9cbdfbc4d4a1b34dd3c026a1f9c007c100c4a7e0e88b3e8f7681580506d50edbc34f4b094da2fb9d3e72066a1b3506d22
checksum: ed1f1bcec4fd308463c6bd6e6cc8f6c89041dfa5e0c03c67ee487f5b3bef7bb34c59ea1f8039d00cc0e8696ed8ae9a4486c10d86b2db1d9dadb94294fc83b6fc
languageName: node
linkType: hard

"@eth-optimism/sdk@npm:2.1.0":
version: 2.1.0
resolution: "@eth-optimism/sdk@npm:2.1.0"
"@eth-optimism/sdk@npm:3.2.0":
version: 3.2.0
resolution: "@eth-optimism/sdk@npm:3.2.0"
dependencies:
"@eth-optimism/contracts": 0.6.0
"@eth-optimism/contracts-bedrock": 0.14.0
"@eth-optimism/core-utils": 0.12.0
"@eth-optimism/contracts-bedrock": 0.17.1
"@eth-optimism/core-utils": 0.13.1
lodash: ^4.17.21
merkletreejs: ^0.2.27
merkletreejs: ^0.3.11
rlp: ^2.2.7
semver: ^7.5.4
peerDependencies:
ethers: ^5
checksum: 8002d32734cde69524b23ec79e5b9dfeb56994ef65008f94c73067b2d391aa70f4b9cca5313e617c3391ae6547dce78a3c12a6898748295b04ee67448a9ddc4d
checksum: e8101a3d9c3dde9f02bc0862aa1afe68235505976b27e1ea1bcb4524d4fd9531fdb66dcbb841ff3f8b38fd9110a51260f38a434532d72b6857710c1d76a1d2a4
languageName: node
linkType: hard

Expand Down Expand Up @@ -12868,7 +12864,7 @@ __metadata:
languageName: node
linkType: hard

"chai@npm:^4.3.4, chai@npm:^4.3.7":
"chai@npm:^4.3.4, chai@npm:^4.3.9":
version: 4.4.1
resolution: "chai@npm:4.4.1"
dependencies:
Expand Down Expand Up @@ -14199,6 +14195,13 @@ __metadata:
languageName: node
linkType: hard

"crypto-js@npm:^4.2.0":
version: 4.2.0
resolution: "crypto-js@npm:4.2.0"
checksum: f051666dbc077c8324777f44fbd3aaea2986f198fe85092535130d17026c7c2ccf2d23ee5b29b36f7a4a07312db2fae23c9094b644cc35f7858b1b4fcaf27774
languageName: node
linkType: hard

"crypto-randomuuid@npm:^1.0.0":
version: 1.0.0
resolution: "crypto-randomuuid@npm:1.0.0"
Expand Down Expand Up @@ -22995,6 +22998,19 @@ __metadata:
languageName: node
linkType: hard

"merkletreejs@npm:^0.3.11":
version: 0.3.11
resolution: "merkletreejs@npm:0.3.11"
dependencies:
bignumber.js: ^9.0.1
buffer-reverse: ^1.0.1
crypto-js: ^4.2.0
treeify: ^1.1.0
web3-utils: ^1.3.4
checksum: 93edb8ec66aa6c9f59aa0902e675590e3791692893bb3e8c1018f758367ded1bf7d6b1057ccde3729b283ca946a316838a631a922960b76889b3be528c43ef4e
languageName: node
linkType: hard

"meros@npm:^1.2.1":
version: 1.3.0
resolution: "meros@npm:1.3.0"
Expand Down Expand Up @@ -27916,6 +27932,17 @@ __metadata:
languageName: node
linkType: hard

"semver@npm:^7.5.4":
version: 7.6.0
resolution: "semver@npm:7.6.0"
dependencies:
lru-cache: ^6.0.0
bin:
semver: bin/semver.js
checksum: 7427f05b70786c696640edc29fdd4bc33b2acf3bbe1740b955029044f80575fc664e1a512e4113c3af21e767154a94b4aa214bf6cd6e42a1f6dba5914e0b208c
languageName: node
linkType: hard

"semver@npm:~5.4.1":
version: 5.4.1
resolution: "semver@npm:5.4.1"
Expand Down

0 comments on commit 8a253b8

Please sign in to comment.