Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit eef8c43

Browse files
AgusVelez5scnale
authored andcommitted
Deprecate matching engine evm scripts
1 parent f60734a commit eef8c43

9 files changed

+159
-57
lines changed
Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,66 @@
1-
import { runOnEvms, ChainInfo, LoggerFn, getContractAddress, getDeploymentArgs, getVerifyCommand } from "../../../helpers";
1+
import { runOnEvms, ChainInfo, LoggerFn, getContractAddress, getDeploymentArgs, getVerifyCommand, verificationApiKeys, flattenObject } from "../../../helpers";
22
import { ethers } from "ethers";
33
import { execSync } from "child_process";
44
import path from "path";
55
import chalk from "chalk";
66

77
runOnEvms("bytecode-verification-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
8+
9+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
10+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
11+
812
// The root path of the foundry project
913
const rootPath = path.resolve('../evm/');
1014

11-
if (chain.externalId === undefined)
12-
throw new Error(`Chain ${chain.chainId} does not have an external ID`);
13-
14-
// Implementation data
15-
const implementationName = "MatchingEngine";
16-
const implementationPath = 'src/MatchingEngine/MatchingEngine.sol';
17-
const implementationAddress = getContractAddress("MatchingEngineImplementation", chain.chainId);
18-
const implementationDeploymentArgs = getDeploymentArgs("MatchingEngineImplementation", chain.chainId);
19-
const implementationConstructorSignature = "constructor(address,address,address,uint24,uint24,uint8,uint8,uint8)";
20-
const verifyImplementationCommand = getVerifyCommand(
21-
implementationName,
22-
implementationPath,
23-
implementationAddress,
24-
implementationConstructorSignature,
25-
implementationDeploymentArgs,
26-
parseInt(chain.externalId)
27-
);
28-
29-
// Proxy data
30-
const proxyName = "ERC1967Proxy";
31-
const proxyPath = 'lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol';
32-
const proxyAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
33-
const proxyDeploymentArgs = getDeploymentArgs("MatchingEngineProxy", chain.chainId);
34-
const proxyConstructorSignature = "constructor(address,bytes)";
35-
const verifyProxyCommand = getVerifyCommand(
36-
proxyName,
37-
proxyPath,
38-
proxyAddress,
39-
proxyConstructorSignature,
40-
proxyDeploymentArgs,
41-
parseInt(chain.externalId)
42-
);
43-
44-
log(chalk.green("Verifying implementation bytecode..."));
45-
execSync(verifyImplementationCommand, { stdio: "inherit", cwd: rootPath });
46-
console.log()
47-
48-
log(chalk.green("Verifying proxy bytecode..."));
49-
execSync(verifyProxyCommand, { stdio: "inherit", cwd: rootPath });
50-
console.log()
15+
16+
const verifiersData = verificationApiKeys.find((x) => x.chainId == chain.chainId);
17+
const verifiers = flattenObject(verifiersData!);
18+
delete verifiers.chainId;
19+
20+
21+
for (let [name, value] of Object.entries(verifiers)) {
22+
name = name.split("-")[0];
23+
24+
// Implementation data
25+
const implementationName = "MatchingEngine";
26+
const implementationPath = 'src/MatchingEngine/MatchingEngine.sol';
27+
const implementationAddress = getContractAddress("MatchingEngineImplementation", chain.chainId);
28+
const implementationDeploymentArgs = getDeploymentArgs("MatchingEngineImplementation", chain.chainId);
29+
const implementationConstructorSignature = "constructor(address,address,address,uint24,uint24,uint8,uint8,uint8)";
30+
const verifyImplementationCommand = getVerifyCommand(
31+
chain,
32+
implementationName,
33+
implementationPath,
34+
implementationAddress,
35+
implementationConstructorSignature,
36+
implementationDeploymentArgs,
37+
name,
38+
value
39+
);
40+
41+
// Proxy data
42+
const proxyName = "ERC1967Proxy";
43+
const proxyPath = 'lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol';
44+
const proxyAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
45+
const proxyDeploymentArgs = getDeploymentArgs("MatchingEngineProxy", chain.chainId);
46+
const proxyConstructorSignature = "constructor(address,bytes)";
47+
const verifyProxyCommand = getVerifyCommand(
48+
chain,
49+
proxyName,
50+
proxyPath,
51+
proxyAddress,
52+
proxyConstructorSignature,
53+
proxyDeploymentArgs,
54+
name,
55+
value
56+
);
57+
58+
log(chalk.green("Verifying implementation bytecode..."));
59+
execSync(verifyImplementationCommand, { stdio: "inherit", cwd: rootPath });
60+
console.log()
61+
62+
log(chalk.green("Verifying proxy bytecode..."));
63+
execSync(verifyProxyCommand, { stdio: "inherit", cwd: rootPath });
64+
console.log()
65+
}
5166
});

deployment/scripts/evm/MatchingEngine/config-matching-engine.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@ import { runOnEvmsSequentially, ChainInfo, LoggerFn, getContractInstance, getCon
33
import { ethers } from "ethers";
44
import { getConfigurationDifferences, logDiff } from "./utils";
55
import confirm from '@inquirer/confirm';
6+
import { inspect } from "util";
7+
import chalk from "chalk";
68

79
runOnEvmsSequentially("config-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
10+
11+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
12+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
13+
814
const matchingEngineAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
915
const matchingEngine = (await getContractInstance("MatchingEngine", matchingEngineAddress, chain)) as MatchingEngine;
1016
const diff = await getConfigurationDifferences(chain);
1117

18+
console.log(inspect(diff, { depth: null, colors: true }));
19+
1220
log(`MatchingEngine configuration differences on chain ${chain.chainId}:`);
13-
logDiff(diff, log);
21+
logDiff(diff, log, ["new", "update"]);
1422

1523
const deployConfig: boolean = await confirm({ message: 'Continue?', default: false });
1624
if (!deployConfig){
@@ -37,7 +45,10 @@ runOnEvmsSequentially("config-matching-engine", async (chain: ChainInfo, signer:
3745

3846
// Router endpoints
3947
for (const { wormholeChainId, router, mintRecipient, circleDomain } of routerEndpoints) {
40-
const offChainEndpoint = getFormattedEndpoint(router.offChain, mintRecipient.offChain);
48+
const offChainEndpoint = {
49+
router: router.offChain,
50+
mintRecipient: mintRecipient.offChain
51+
};
4152

4253
// Add new router endpoint if all values are zero
4354
if (Number(router?.onChain) === 0 && Number(mintRecipient?.onChain) === 0 && Number(circleDomain?.onChain) === 0) {
@@ -52,19 +63,18 @@ runOnEvmsSequentially("config-matching-engine", async (chain: ChainInfo, signer:
5263
continue;
5364
}
5465

55-
// Disable router endpoint, must be the three values zero
56-
if (Number(router?.offChain) === 0 && Number(mintRecipient?.offChain) === 0 && Number(circleDomain?.offChain) === 0) {
57-
await matchingEngine.disableRouterEndpoint(wormholeChainId);
58-
log(`Router endpoint disabled for wormholeChainId ${wormholeChainId}`);
59-
continue;
60-
}
61-
6266
// Update router endpoint
6367
if (
64-
router?.onChain.toString() !== router?.offChain.toString() ||
65-
mintRecipient?.onChain.toString() !== mintRecipient?.offChain.toString() ||
68+
router?.onChain.toString() !== offChainEndpoint.router.toString() ||
69+
mintRecipient?.onChain.toString() !== offChainEndpoint.mintRecipient.toString() ||
6670
circleDomain?.onChain.toString() !== circleDomain?.offChain.toString()
67-
) {
71+
) {
72+
73+
if (Number(router?.offChain) === 0 && Number(mintRecipient?.offChain) === 0 && Number(circleDomain?.offChain) === 0) {
74+
log(`Router endpoint already disabled for wormholeChainId ${wormholeChainId}.`);
75+
continue;
76+
}
77+
6878
if (wormholeChainId === 0)
6979
throw new Error('Invalid wormholeChainId when adding new router endpoint');
7080

deployment/scripts/evm/MatchingEngine/deploy-matching-engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { runOnEvms, ChainInfo, LoggerFn, writeDeployedContract } from "../../../
33
import { MatchingEngineConfiguration } from "../../../config/config-types";
44
import { deployImplementation, getMachingEngineConfiguration } from "./utils";
55
import { ERC1967Proxy__factory } from "../../../contract-bindings";
6+
import chalk from "chalk";
67

78
runOnEvms("deploy-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
9+
10+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
11+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
12+
813
const config = await getMachingEngineConfiguration(chain);
914
const implementation = await deployImplementation(signer, config, log);
1015
await deployProxy(signer, config, implementation, log);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { MatchingEngine } from "../../../contract-bindings";
2+
import { runOnEvmsSequentially, ChainInfo, LoggerFn, getContractInstance, getContractAddress } from "../../../helpers";
3+
import { ethers } from "ethers";
4+
import { getConfigurationDifferences, logRoutersDiff } from "./utils";
5+
import confirm from '@inquirer/confirm';
6+
import chalk from "chalk";
7+
8+
runOnEvmsSequentially("disable-router-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
9+
10+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
11+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
12+
13+
const matchingEngineAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
14+
const matchingEngine = (await getContractInstance("MatchingEngine", matchingEngineAddress, chain)) as MatchingEngine;
15+
const diff = await getConfigurationDifferences(chain);
16+
17+
log(`MatchingEngine configuration differences on chain ${chain.chainId}:`);
18+
logRoutersDiff(diff, log, ["delete"]);
19+
20+
const deployConfig: boolean = await confirm({ message: 'Continue?', default: false });
21+
if (!deployConfig){
22+
log(`Configuration deployment aborted on chain ${chain.chainId}`);
23+
return;
24+
}
25+
26+
const { routerEndpoints } = diff;
27+
28+
// Router endpoints
29+
for (const { wormholeChainId, router, mintRecipient, circleDomain } of routerEndpoints) {
30+
31+
// Disable router endpoint, must be the three values zero
32+
if (Number(router?.offChain) === 0 && Number(mintRecipient?.offChain) === 0 && Number(circleDomain?.offChain) === 0) {
33+
await matchingEngine.disableRouterEndpoint(wormholeChainId);
34+
log(`Router endpoint disabled for wormholeChainId ${wormholeChainId}`);
35+
}
36+
}
37+
});

deployment/scripts/evm/MatchingEngine/get-config-diff-matching-engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { runOnEvms, ChainInfo, LoggerFn } from "../../../helpers";
22
import { ethers } from "ethers";
33
import { getConfigurationDifferences, logDiff } from "./utils";
4+
import chalk from "chalk";
45

56
runOnEvms("get-config-diff-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
7+
8+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
9+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
10+
611
const diff = await getConfigurationDifferences(chain);
712
log(`MatchingEngine configuration differences on chain ${chain.chainId}:`);
813
logDiff(diff, log);

deployment/scripts/evm/MatchingEngine/read-config-matching-engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import { runOnEvms, ChainInfo, LoggerFn } from "../../../helpers";
22
import { ethers } from "ethers";
33
import { getOnChainMachingEngineConfiguration } from "./utils";
44
import { inspect } from "util";
5+
import chalk from "chalk";
56

67
runOnEvms("read-config-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
8+
9+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
10+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
11+
712
const onChainConfig = await getOnChainMachingEngineConfiguration(chain);
813
log(`MatchingEngine configuration for chainId ${chain.chainId}:`);
914
log(inspect(onChainConfig, { depth: null, colors: true, compact: true }));

deployment/scripts/evm/MatchingEngine/update-owner-assistant-matching-engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { runOnEvmsSequentially, ChainInfo, LoggerFn, getContractInstance, getCon
33
import { ethers } from "ethers";
44
import { getConfigurationDifferences } from "./utils";
55
import confirm from '@inquirer/confirm';
6+
import chalk from "chalk";
67

78
runOnEvmsSequentially("update-owner-assistant-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
9+
10+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
11+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
12+
813
const matchingEngineAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
914
const matchingEngine = (await getContractInstance("MatchingEngine", matchingEngineAddress, chain)) as MatchingEngine;
1015
const diff = await getConfigurationDifferences(chain);

deployment/scripts/evm/MatchingEngine/upgrade-matching-engine.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { ethers } from "ethers";
33
import { deployImplementation, getMachingEngineConfiguration } from "./utils";
44
import { MatchingEngine } from "../../../contract-bindings";
55
import { MatchingEngineConfiguration } from "../../../config/config-types";
6+
import chalk from "chalk";
67

78
runOnEvms("upgrade-matching-engine", async (chain: ChainInfo, signer: ethers.Signer, log: LoggerFn) => {
9+
10+
console.warn(chalk.yellow("This script is deprecated due to the only MatchingEngine contract is deployed in Solana."))
11+
throw new Error("This script is deprecated due to the only MatchingEngine contract is deployed in Solana.");
12+
813
const currentImplementationAddress = getContractAddress("MatchingEngineImplementation", chain.chainId);
914
const proxyAddress = getContractAddress("MatchingEngineProxy", chain.chainId);
1015
const proxy = (await getContractInstance("MatchingEngine", proxyAddress, chain)) as MatchingEngine;

deployment/scripts/evm/MatchingEngine/utils.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,38 @@ export async function getConfigurationDifferences(chain: ChainInfo) {
125125
return differences;
126126
}
127127

128-
export function logDiff(differences: Record<string, any>, log: LoggerFn) {
128+
export function logDiff(differences: Record<string, any>, log: LoggerFn, valuesToShow?: Array<"new" | "update" | "delete">) {
129129
logComparision('feeRecipient', differences.feeRecipient, log);
130130
logComparision('cctpAllowance', differences.cctpAllowance, log);
131131

132+
logRoutersDiff(differences, log, valuesToShow);
133+
}
134+
135+
export function logRoutersDiff(differences: Record<string, any>, log: LoggerFn, valuesToShow?: Array<"new" | "update" | "delete">) {
132136
let routersLogged = false;
133137
for (const { wormholeChainId, router, mintRecipient, circleDomain } of differences.routerEndpoints) {
138+
// In no one is different, skip
134139
if (!someoneIsDifferent([router, mintRecipient, circleDomain]))
135140
continue;
136141

142+
// Edge case: if only mintRecipient is different and the off chain values are 0 (the endpoint is disabled), skip
143+
if (
144+
someoneIsDifferent([mintRecipient]) &&
145+
!someoneIsDifferent([router, circleDomain]) &&
146+
(Number(router.onChain) === 0 && Number(circleDomain.onChain) === 0) &&
147+
(Number(mintRecipient.offChain) === 0)
148+
) {
149+
continue;
150+
}
151+
137152
if (!routersLogged) {
138153
log('Router endpoints:');
139154
routersLogged = true;
140155
}
141156

142157
log(`WormholeChainId ${wormholeChainId}:`);
143-
logComparision('router', router, log);
144-
logComparision('mintRecipient', mintRecipient, log);
145-
logComparision('circleDomain', circleDomain, log);
158+
logComparision('router', router, log, valuesToShow);
159+
logComparision('mintRecipient', mintRecipient, log, valuesToShow);
160+
logComparision('circleDomain', circleDomain, log, valuesToShow);
146161
}
147162
}

0 commit comments

Comments
 (0)