Skip to content

Commit 657a07e

Browse files
authored
feat(protocol-contracts): add mainnet lz config for governance (#1387)
* feat(protocol-contracts): add mainnet lz config for governance * chore(protocol-contracts): updated sender contract * chore(protocol-contracts): update governance env file
1 parent 977aea7 commit 657a07e

File tree

7 files changed

+129
-64
lines changed

7 files changed

+129
-64
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
PRIVATE_KEY=
22
SEPOLIA_RPC_URL=
33
RPC_URL_ZAMA_GATEWAY_TESTNET=
4+
MAINNET_RPC_URL=
5+
RPC_URL_ZAMA_GATEWAY_MAINNET=
46
ETHERSCAN_API=TA5XXXXXXXXXXXXXXXXXXXXXXXXXXXGX9
57
BLOCKSCOUT_API=https://explorer-xxxx-xxxxxxx.conduit.xyz/api # don't forget the /api suffix at the end
68
SAFE_PROXY_ADDRESS=
9+
DAO_ADDRESS=

protocol-contracts/governance/contracts/GovernanceOAppSender.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ contract GovernanceOAppSender is OAppSender, OAppOptionsType3 {
5757
uint256 chainID = block.chainid;
5858
if (chainID == 1) {
5959
// chainID of ethereum-mainnet i.e linked to gateway-mainnet.
60-
revert("TODO: to fill with correct value, destEid unknown yet for Zama mainnet");
60+
DESTINATION_EID = 30397;
6161
} else if (chainID == 11155111) {
6262
// chainID of ethereum-testnet i.e linked to gateway-testnet.
6363
DESTINATION_EID = 40424;

protocol-contracts/governance/hardhat.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ const config: HardhatUserConfig = {
6666
accounts,
6767
},
6868
'gateway-mainnet': {
69-
// @ts-ignore: TODO: Remove TS ignore once LayerZero endpoint is deployed.
7069
eid: EndpointId.ZAMA_V2_MAINNET,
7170
url: process.env.RPC_URL_ZAMA_GATEWAY_MAINNET || '',
7271
accounts,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { EndpointId } from '@layerzerolabs/lz-definitions'
2+
import { TwoWayConfig, generateConnectionsConfig } from '@layerzerolabs/metadata-tools'
3+
4+
import type { OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
5+
6+
const ethereumContract: OmniPointHardhat = {
7+
eid: EndpointId.ETHEREUM_V2_MAINNET,
8+
contractName: 'GovernanceOAppSender',
9+
}
10+
11+
const zamaMainnetContract: OmniPointHardhat = {
12+
eid: EndpointId.ZAMA_V2_MAINNET,
13+
contractName: 'GovernanceOAppReceiver',
14+
}
15+
16+
// To connect the above chains to each other, we need the following pathway:
17+
// Ethereum -> ZamaGatewayMainnet
18+
19+
// We don't use enforced executor gas options here, so we should ensure `options` is set to the correct value through profiling the gas usage of calling GovernanceOAppReceiver._lzReceive(...) on the destination chain.
20+
// To learn more, read https://docs.layerzero.network/v2/concepts/applications/oapp-standard#execution-options-and-enforced-settings
21+
22+
const pathways: TwoWayConfig[] = [
23+
[
24+
ethereumContract, // Chain A contract
25+
zamaMainnetContract, // Chain B contract
26+
// TODO: Add custom ZAMA DVN in next line?
27+
[['LayerZero Labs', 'Nethermind'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
28+
[15, undefined], // [A to B confirmations, B to A confirmations] // NOTE: `undefined` is used here because we want an uniderectional pathway
29+
[undefined, undefined], // NOTE: first `undefined` is because we do not enforce gas, since proposals are arbitrary calls. Instead, we will use a gas profiler to calculate the gas needed for proposal execution and adds a relative buffer on top. Second `undefined` is used here because we want an uniderectional pathway.
30+
],
31+
]
32+
33+
export default async function () {
34+
// Generate the connections config based on the pathways
35+
const connections = await generateConnectionsConfig(pathways)
36+
return {
37+
contracts: [
38+
{
39+
contract: zamaMainnetContract,
40+
config: { owner: process.env.SAFE_PROXY_ADDRESS, delegate: process.env.SAFE_PROXY_ADDRESS },
41+
},
42+
{
43+
contract: ethereumContract,
44+
config: { owner: process.env.DAO_ADDRESS, delegate: process.env.DAO_ADDRESS },
45+
},
46+
],
47+
connections,
48+
}
49+
}

protocol-contracts/governance/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
"@babel/core": "^7.23.9",
2525
"@layerzerolabs/eslint-config-next": "~2.3.39",
2626
"@layerzerolabs/io-devtools": "~0.3.0",
27-
"@layerzerolabs/lz-definitions": "^3.0.75",
27+
"@layerzerolabs/lz-definitions": "^3.0.147",
2828
"@layerzerolabs/lz-evm-messagelib-v2": "^3.0.75",
2929
"@layerzerolabs/lz-evm-protocol-v2": "^3.0.75",
30+
"@layerzerolabs/lz-evm-sdk-v2": "^3.0.147",
3031
"@layerzerolabs/lz-evm-v1-0.7": "^3.0.75",
3132
"@layerzerolabs/lz-v2-utilities": "^3.0.75",
3233
"@layerzerolabs/metadata-tools": "^3.0.0",

protocol-contracts/governance/pnpm-lock.yaml

Lines changed: 73 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol-contracts/token/layerzero.config.mainnet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const pathways: TwoWayConfig[] = [
3737
ethereumContract, // Chain A contract
3838
zamaMainnetContract, // Chain B contract
3939
// TODO: Add custom ZAMA DVN in next line?
40-
[['LayerZero Labs'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
40+
[['LayerZero Labs', 'Nethermind'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
4141
[15, 20], // [A to B confirmations, B to A confirmations]
4242
[EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
4343
],

0 commit comments

Comments
 (0)