Skip to content

Commit 7a844fa

Browse files
committed
Merge remote-tracking branch 'origin/draft-v31' into sma/refactor-tests
2 parents b0090ee + 02c8b38 commit 7a844fa

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

core/tests/ts-integration/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ export const ArtifactL1AssetRouter = readContract(`${ARTIFACTS_PATH}`, 'L1AssetR
5858
export const ArtifactL1AssetTracker = readContract(`${ARTIFACTS_PATH}`, 'L1AssetTracker');
5959
export const ArtifactL2AssetTracker = readContract(`${ARTIFACTS_PATH}`, 'L2AssetTracker');
6060
export const ArtifactDummyInteropRecipient = readContract(`${L1_ZK_ARTIFACTS_PATH}`, 'DummyInteropRecipient');
61+
export const ArtifactIBridgehubBase = readContract(`${ARTIFACTS_PATH}`, 'IBridgehubBase');
62+
export const ArtifactIGetters = readContract(`${ARTIFACTS_PATH}`, 'IGetters');
63+
export const ArtifactIChainAssetHandler = readContract(`${ARTIFACTS_PATH}`, 'IChainAssetHandler');

core/tests/ts-integration/src/helpers.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import {
99
GATEWAY_CHAIN_ID,
1010
L2_INTEROP_ROOT_STORAGE_ADDRESS,
1111
L2_BRIDGEHUB_ADDRESS,
12-
ArtifactL2InteropRootStorage
12+
ArtifactL2InteropRootStorage,
13+
ArtifactIBridgehubBase,
14+
ArtifactIGetters
1315
} from './constants';
1416

1517
import { log } from 'console';
@@ -107,17 +109,9 @@ export async function waitUntilBlockExecutedOnGateway(
107109
gwWallet: zksync.Wallet,
108110
blockNumber: number
109111
) {
110-
const bridgehub = new ethers.Contract(
111-
L2_BRIDGEHUB_ADDRESS,
112-
['function getZKChain(uint256) view returns (address)'],
113-
gwWallet
114-
);
115-
const zkChainAddr = await bridgehub.getZKChain(await wallet.provider.getNetwork().then((net) => net.chainId));
116-
const gettersFacet = new ethers.Contract(
117-
zkChainAddr,
118-
['function getTotalBatchesExecuted() view returns (uint256)'],
119-
gwWallet
120-
);
112+
const bridgehub = new ethers.Contract(L2_BRIDGEHUB_ADDRESS, ArtifactIBridgehubBase.abi, gwWallet);
113+
const zkChainAddr = await bridgehub.getZKChain(await wallet.provider.getNetwork().then((net: any) => net.chainId));
114+
const gettersFacet = new ethers.Contract(zkChainAddr, ArtifactIGetters.abi, gwWallet);
121115

122116
let batchNumber = (await wallet.provider.getBlockDetails(blockNumber)).l1BatchNumber;
123117
let currentExecutedBatchNumber = 0;

core/tests/upgrade-test/tests/upgrade.test.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -591,15 +591,10 @@ async function publishBytecode(
591591
nonce: number
592592
): Promise<number> {
593593
const hash = zksync.utils.hashBytecode(bytecode);
594-
const abi = [
595-
'function publishBytecode(bytes calldata _bytecode) public',
596-
'function publishingBlock(bytes32 _hash) public view returns (uint256)'
597-
];
598-
599-
const contract = new ethers.Contract(bytecodeSupplierAddr, abi, wallet);
594+
const contract = new ethers.Contract(bytecodeSupplierAddr, contracts.bytecodesSupplierAbi, wallet);
600595
const block = await contract.publishingBlock(hash);
601596
if (block == BigInt(0)) {
602-
const tx = await contract.publishBytecode(bytecode, { nonce });
597+
const tx = await contract.publishEraBytecode(bytecode, { nonce });
603598
await tx.wait();
604599
return 1;
605600
}
@@ -778,21 +773,17 @@ async function pauseMigrationsCalldata(
778773
// For gateway, get the ChainAssetHandler address from L2 Bridgehub
779774
const l2BridgehubContract = new ethers.Contract(
780775
L2_BRIDGEHUB_ADDRESS,
781-
['function chainAssetHandler() external view returns (address)'],
776+
contracts.bridgehubAbi,
782777
gatewayInfo.gatewayProvider
783778
);
784779
chainAssetHandlerAddr = await l2BridgehubContract.chainAssetHandler();
785780
} else {
786781
// For L1, get the ChainAssetHandler address from L1 Bridgehub
787-
const bridgehubContract = new ethers.Contract(
788-
l1BridgehubAddr,
789-
['function chainAssetHandler() external view returns (address)'],
790-
l1Provider
791-
);
782+
const bridgehubContract = new ethers.Contract(l1BridgehubAddr, contracts.bridgehubAbi, l1Provider);
792783
chainAssetHandlerAddr = await bridgehubContract.chainAssetHandler();
793784
}
794785

795-
const iface = new ethers.Interface(['function pauseMigration() external']);
786+
const iface = contracts.chainAssetHandlerAbi;
796787

797788
return prepareGovernanceCalldata(
798789
chainAssetHandlerAddr,

core/tests/upgrade-test/tests/utils.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export interface Contracts {
4141
complexUpgraderAbi: any;
4242
counterBytecode: any;
4343
chainTypeManager: any;
44+
bytecodesSupplierAbi: any;
45+
bridgehubAbi: any;
46+
chainAssetHandlerAbi: any;
4447
}
4548

4649
export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
@@ -70,6 +73,15 @@ export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
7073
).deployedBytecode,
7174
chainTypeManager: new ethers.Interface(
7275
require(`${CONTRACTS_FOLDER}/l1-contracts/out/EraChainTypeManager.sol/EraChainTypeManager.json`).abi
76+
),
77+
bytecodesSupplierAbi: new ethers.Interface(
78+
require(`${CONTRACTS_FOLDER}/l1-contracts/out/BytecodesSupplier.sol/BytecodesSupplier.json`).abi
79+
),
80+
bridgehubAbi: new ethers.Interface(
81+
require(`${CONTRACTS_FOLDER}/l1-contracts/out/IBridgehubBase.sol/IBridgehubBase.json`).abi
82+
),
83+
chainAssetHandlerAbi: new ethers.Interface(
84+
require(`${CONTRACTS_FOLDER}/l1-contracts/out/IChainAssetHandler.sol/IChainAssetHandler.json`).abi
7385
)
7486
};
7587
} else {
@@ -99,6 +111,17 @@ export function initContracts(pathToHome: string, zkStack: boolean): Contracts {
99111
.deployedBytecode,
100112
chainTypeManager: new ethers.Interface(
101113
require(`${L1_CONTRACTS_FOLDER}/state-transition/ChainTypeManager.sol/ChainTypeManager.json`).abi
114+
),
115+
bytecodesSupplierAbi: new ethers.Interface(
116+
require(`${L1_CONTRACTS_FOLDER}/upgrades/BytecodesSupplier.sol/BytecodesSupplier.json`).abi
117+
),
118+
bridgehubAbi: new ethers.Interface(
119+
require(`${L1_CONTRACTS_FOLDER}/core/bridgehub/IBridgehubBase.sol/IBridgehubBase.json`).abi
120+
),
121+
chainAssetHandlerAbi: new ethers.Interface(
122+
require(
123+
`${L1_CONTRACTS_FOLDER}/core/chain-asset-handler/IChainAssetHandler.sol/IChainAssetHandler.json`
124+
).abi
102125
)
103126
};
104127
}

0 commit comments

Comments
 (0)