Skip to content

Commit db7fab9

Browse files
committed
feat: rollup-bridge-contracts deployment and test config enhancements
1 parent 6f2f794 commit db7fab9

File tree

6 files changed

+65
-16
lines changed

6 files changed

+65
-16
lines changed

rollup-bridge-contracts/deploy/config/config-helper.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ export interface L1NetworkConfig {
2525
}
2626

2727
export interface L1TestConfig {
28-
ethDepositTestConfig: L1ETHDepositTestConfig;
28+
l2DepositRecipient: string;
29+
l2FeeRefundRecipient: string;
30+
l1ETHDepositTestConfig: L1ETHDepositTestConfig;
31+
l1ERC20DepositTestConfig: L1ERC20DepositTestConfig;
2932
}
3033

3134
export interface L1ETHDepositTestConfig {
32-
ethAmount: number; // Amount of ETH to deposit on L1
35+
amount: number; // Amount of ETH to deposit on L1
36+
gasLimit: number;
37+
totalNativeAmount: number;
38+
userMaxFeePerGas: number;
39+
userMaxPriorityFeePerGas: number;
40+
}
41+
42+
export interface L1ERC20DepositTestConfig {
43+
tokenAddress: string;
44+
amount: number;
3345
gasLimit: number;
3446
totalNativeAmount: number;
3547
userMaxFeePerGas: number;
@@ -286,14 +298,13 @@ export interface L2NetworkConfig {
286298
l2BridgeMessengerConfig: L2BridgeMessengerConfig;
287299
l2EnshrinedTokenBridgeConfig: L2EnshrinedTokenBridgeConfig;
288300
l2ETHBridgeConfig: L2ETHBridgeConfig;
301+
l2TestConfig: L2TestConfig;
289302
}
290303

291304
export interface L2CommonConfig {
292305
owner: string;
293306
admin: string;
294307
relayer: string;
295-
depositRecipient: string;
296-
feeRefundRecipient: string;
297308
tokens: EnshrinedToken[];
298309
mockL1Bridge?: string; // Optional field to retain backward compatibility
299310
}
@@ -346,6 +357,19 @@ export interface L2ETHBridgeConfig {
346357
}
347358
}
348359

360+
export interface L2TestConfig {
361+
ethTestEventData: ETHTestEventData;
362+
erc20TestEventData: ERC20TestEventData;
363+
}
364+
365+
export interface ETHTestEventData {
366+
messageHash: string;
367+
}
368+
369+
export interface ERC20TestEventData {
370+
messageHash: string;
371+
}
372+
349373
const nilNetworkConfigFilePath = path.join(__dirname, 'nil-deployment-config.json');
350374
const nilNetworkConfigArchiveFilePath = path.join(
351375
__dirname,

rollup-bridge-contracts/deploy/config/l1-deployment-config.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@
77
"shardId": 1
88
},
99
"l1TestConfig": {
10-
"ethAmount": 1000000000000,
10+
"l2DepositRecipient": "",
11+
"l2FeeRefundRecipient": "",
12+
"l1ETHDepositTestConfig": {
13+
"amount": 1000000000000,
1114
"gasLimit": 1000,
1215
"totalNativeAmount": 1200000000,
1316
"userMaxFeePerGas": 0,
1417
"userMaxPriorityFeePerGas": 0
18+
},
19+
"l1ERC20DepositTestConfig": {
20+
"tokenAddress": "",
21+
"amount": 0,
22+
"gasLimit": 0,
23+
"totalNativeAmount": 0,
24+
"userMaxFeePerGas": 0,
25+
"userMaxPriorityFeePerGas": 0
26+
}
1527
},
1628
"l1CommonContracts": {
1729
"weth": ""

rollup-bridge-contracts/deploy/config/nil-deployment-config.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"owner": "",
66
"admin": "",
77
"relayer": "",
8-
"depositRecipient": "",
9-
"feeRefundRecipient": "",
108
"tokens": [
119
{
1210
"name": "USD Coin",
@@ -65,7 +63,15 @@
6563
"l2ETHBridgeProxy": "",
6664
"l2ETHBridgeImplementation": ""
6765
}
66+
},
67+
"l2TestConfig": {
68+
"ethTestEventData": {
69+
"messageHash": ""
70+
},
71+
"erc20TestEventData": {
72+
"messageHash": ""
73+
}
6874
}
6975
}
7076
}
71-
}
77+
}

rollup-bridge-contracts/deploy/config/nil-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export interface BatchInfo {
2020

2121
export const proposerRoleHash = ethers.keccak256(ethers.toUtf8Bytes("PROPOSER_ROLE"));
2222

23+
export const relayerRoleHash = ethers.keccak256(ethers.toUtf8Bytes("RELAYER_ROLE"));

rollup-bridge-contracts/scripts/bridge-test/bridge-eth.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
isValidAddress,
88
loadNilNetworkConfig,
99
L2NetworkConfig,
10+
L1NetworkConfig,
1011
} from '../../deploy/config/config-helper';
1112
import { bigIntReplacer, extractAndParseMessageSentEventLog, MessageSentEvent } from './get-messenger-events';
1213

@@ -19,7 +20,7 @@ const l1EthBridgeABI = JSON.parse(fs.readFileSync(l1EthBridgeABIPath, 'utf8')).a
1920
// npx hardhat run scripts/bridge-test/bridge-eth.ts --network geth
2021
export async function bridgeETH() {
2122
const networkName = network.name;
22-
const config = loadL1NetworkConfig(networkName);
23+
const config: L1NetworkConfig = loadL1NetworkConfig(networkName);
2324

2425
if (!isValidAddress(config.l1ETHBridge.l1ETHBridgeProxy)) {
2526
throw new Error('Invalid l1ETHBridgeProxy address in config');
@@ -42,11 +43,11 @@ export async function bridgeETH() {
4243

4344
const l2DepositRecipient = l2NetworkConfig.l2CommonConfig.depositRecipient;
4445
const l2FeeRefundAddress = l2NetworkConfig.l2CommonConfig.feeRefundRecipient;
45-
const eth_amount = config.l1TestConfig.ethDepositTestConfig.ethAmount;
46-
const gasLimit = config.l1TestConfig.ethDepositTestConfig.gasLimit;
47-
const total_native_amount = config.l1TestConfig.ethDepositTestConfig.totalNativeAmount;
48-
const userMaxFeePerGas = config.l1TestConfig.ethDepositTestConfig.userMaxFeePerGas;
49-
const userMaxPriorityFeePerGas = config.l1TestConfig.ethDepositTestConfig.userMaxPriorityFeePerGas;
46+
const eth_amount = config.l1TestConfig.l1ETHDepositTestConfig.amount;
47+
const gasLimit = config.l1TestConfig.l1ETHDepositTestConfig.gasLimit;
48+
const total_native_amount = config.l1TestConfig.l1ETHDepositTestConfig.totalNativeAmount;
49+
const userMaxFeePerGas = config.l1TestConfig.l1ETHDepositTestConfig.userMaxFeePerGas;
50+
const userMaxPriorityFeePerGas = config.l1TestConfig.l1ETHDepositTestConfig.userMaxPriorityFeePerGas;
5051

5152
console.log(`bridging ${eth_amount} (WEI) to recipient: ${l2DepositRecipient}`);
5253

@@ -77,6 +78,9 @@ export async function bridgeETH() {
7778
const messageSentEvent: MessageSentEvent = messageSentEventLogData;
7879

7980
console.log(`messageSentEvent for depositETH is: ${JSON.stringify(messageSentEvent, bigIntReplacer, 2)}`);
81+
82+
const messageHash = messageSentEvent.messageHash;
83+
8084
}
8185

8286
async function main() {

rollup-bridge-contracts/task/clear-l2-deployments.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ task("clear-l2-deployments", "Clears L2DeploymentConfig entries in nil-deploymen
1414
config.l2CommonConfig.admin = "";
1515
config.l2CommonConfig.owner = "";
1616
config.l2CommonConfig.mockL1Bridge = "";
17-
config.l2CommonConfig.depositRecipient = "";
18-
config.l2CommonConfig.feeRefundRecipient = "";
17+
config.l2CommonConfig.relayer = "";
1918

2019
// clear all deployed contract address under config
2120
config.l2BridgeMessengerConfig.l2BridgeMessengerContracts.l2BridgeMessengerImplementation = "";
@@ -24,6 +23,9 @@ task("clear-l2-deployments", "Clears L2DeploymentConfig entries in nil-deploymen
2423

2524
config.l2CommonConfig.mockL1Bridge = "";
2625

26+
config.l2TestConfig.erc20TestEventData.messageHash = "";
27+
config.l2TestConfig.ethTestEventData.messageHash = "";
28+
2729
config.l2ETHBridgeConfig.l2ETHBridgeContracts.l2ETHBridgeImplementation = "";
2830
config.l2ETHBridgeConfig.l2ETHBridgeContracts.l2ETHBridgeProxy = "";
2931
config.l2ETHBridgeConfig.l2ETHBridgeContracts.proxyAdmin = "";

0 commit comments

Comments
 (0)