Skip to content

Commit

Permalink
Deploying more ULN options besides the defaults (SendUln302/ReceiveUl…
Browse files Browse the repository at this point in the history
…n302) on both chains as part of the bootstrap deployment.
  • Loading branch information
sirarthurmoney committed Dec 13, 2023
1 parent 6087da4 commit 494e789
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/ua-utils-evm-hardhat-test/deploy/001_bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network
args: [endpointV2Deployment.address],
})

await deployments.delete('SendUln302_Opt2')
const SendUln302_Opt2 = await deployments.deploy('SendUln302_Opt2', {
contract: 'SendUln302',
from: deployer,
args: [endpointV2Deployment.address, 0, 0],
})

await deployments.delete('ReceiveUln302_Opt2')
const ReceiveUln302_Opt2 = await deployments.deploy('ReceiveUln302_Opt2', {
contract: 'ReceiveUln302',
from: deployer,
args: [endpointV2Deployment.address],
})

await Promise.all(
['DefaultProxyAdmin', 'PriceFeed_Proxy', 'PriceFeed', 'PriceFeed_Implementation'].map((contractName) =>
deployments.delete(contractName)
Expand Down Expand Up @@ -134,6 +148,8 @@ const deploy: DeployFunction = async ({ getUnnamedAccounts, deployments, network
EndpointV2: endpointV2Deployment.address,
SendUln302: sendUln302.address,
ReceiveUln302: receiveUln302.address,
SendUln302_Opt2: SendUln302_Opt2.address,
ReceiveUln302_Opt2: ReceiveUln302_Opt2.address,
PriceFeed: priceFeed.address,
Executor: executor.address,
ExecutorFeeLib: executorFeeLib.address,
Expand Down
65 changes: 64 additions & 1 deletion packages/ua-utils-evm-hardhat-test/test/__utils__/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import { formatOmniPoint } from '@layerzerolabs/utils'
export const ethEndpoint = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'EndpointV2' }
export const ethReceiveUln = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'ReceiveUln302' }
export const ethSendUln = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'SendUln302' }
export const ethReceiveUln2_Opt2 = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'ReceiveUln302_Opt2' }
export const ethSendUln2_Opt2 = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'SendUln302_Opt2' }
export const ethExecutor = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'Executor' }
export const ethDvn = { eid: EndpointId.ETHEREUM_MAINNET, contractName: 'DVN' }
export const avaxEndpoint = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'EndpointV2' }
export const avaxReceiveUln = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'ReceiveUln302' }
export const avaxSendUln = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'SendUln302' }
export const avaxReceiveUln2_Opt2 = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'ReceiveUln302_Opt2' }
export const avaxSendUln2_Opt2 = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'SendUln302_Opt2' }
export const avaxExecutor = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'Executor' }
export const avaxDvn = { eid: EndpointId.AVALANCHE_MAINNET, contractName: 'DVN' }

Expand Down Expand Up @@ -155,6 +159,51 @@ export const setupDefaultEndpoint = async (): Promise<void> => {
connections: [],
}

const sendUlnConfig_Opt2: OmniGraphHardhat<Uln302NodeConfig, unknown> = {
contracts: [
{
contract: ethSendUln2_Opt2,
config: {
defaultUlnConfigs: [[EndpointId.AVALANCHE_MAINNET, ethUlnConfig]],
defaultExecutorConfigs: [
[EndpointId.AVALANCHE_MAINNET, getDefaultExecutorConfig(ethExecutorPoint.address)],
],
},
},
{
contract: avaxSendUln2_Opt2,
config: {
defaultUlnConfigs: [[EndpointId.ETHEREUM_MAINNET, avaxUlnConfig]],
defaultExecutorConfigs: [
[EndpointId.ETHEREUM_MAINNET, getDefaultExecutorConfig(avaxExecutorPoint.address)],
],
},
},
],
connections: [],
}

// This is the graph for ReceiveUln302
const receiveUlnConfig_Opt2: OmniGraphHardhat<Uln302NodeConfig, unknown> = {
contracts: [
{
contract: ethReceiveUln2_Opt2,
config: {
defaultUlnConfigs: [[EndpointId.AVALANCHE_MAINNET, ethUlnConfig]],
defaultExecutorConfigs: [],
},
},
{
contract: avaxReceiveUln2_Opt2,
config: {
defaultUlnConfigs: [[EndpointId.ETHEREUM_MAINNET, avaxUlnConfig]],
defaultExecutorConfigs: [],
},
},
],
connections: [],
}

// This is the graph for EndpointV2
const config: OmniGraphHardhat<unknown, EndpointEdgeConfig> = {
contracts: [
Expand Down Expand Up @@ -188,12 +237,26 @@ export const setupDefaultEndpoint = async (): Promise<void> => {
// Now we compile a list of all the transactions that need to be executed for the ULNs and Endpoints
const builderEndpoint = await OmniGraphBuilderHardhat.fromConfig(config)
const endpointTransactions = await configureEndpoint(builderEndpoint.graph, endpointSdkFactory)

const builderSendUln = await OmniGraphBuilderHardhat.fromConfig(sendUlnConfig)
const sendUlnTransactions = await configureUln302(builderSendUln.graph, ulnSdkFactory)

const builderReceiveUln = await OmniGraphBuilderHardhat.fromConfig(receiveUlnConfig)
const receiveUlnTransactions = await configureUln302(builderReceiveUln.graph, ulnSdkFactory)

const transactions = [...sendUlnTransactions, ...receiveUlnTransactions, ...endpointTransactions]
const builderSendUln_Opt2 = await OmniGraphBuilderHardhat.fromConfig(sendUlnConfig_Opt2)
const sendUlnTransactions_Opt2 = await configureUln302(builderSendUln_Opt2.graph, ulnSdkFactory)

const builderReceiveUln_Opt2 = await OmniGraphBuilderHardhat.fromConfig(receiveUlnConfig_Opt2)
const receiveUlnTransactions_Opt2 = await configureUln302(builderReceiveUln_Opt2.graph, ulnSdkFactory)

const transactions = [
...sendUlnTransactions,
...receiveUlnTransactions,
...endpointTransactions,
...sendUlnTransactions_Opt2,
...receiveUlnTransactions_Opt2,
]

logger.debug(`Executing ${transactions.length} transactions`)

Expand Down

0 comments on commit 494e789

Please sign in to comment.