Skip to content

Commit 3a1b5d4

Browse files
use chain admin for bridgehub manipulations (#799)
Signed-off-by: Danil <deniallugo@gmail.com> Co-authored-by: Vlad Bochok <41153528+vladbochok@users.noreply.github.com>
1 parent 73b20c4 commit 3a1b5d4

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

l1-contracts/deploy-scripts/DeployL1.s.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,15 @@ contract DeployL1Script is Script {
586586

587587
Bridgehub bridgehub = Bridgehub(addresses.bridgehub.bridgehubProxy);
588588
bridgehub.transferOwnership(addresses.governance);
589+
bridgehub.setPendingAdmin(addresses.chainAdmin);
589590

590591
L1SharedBridge sharedBridge = L1SharedBridge(addresses.bridges.sharedBridgeProxy);
591592
sharedBridge.transferOwnership(addresses.governance);
593+
sharedBridge.setPendingAdmin(addresses.chainAdmin);
592594

593595
StateTransitionManager stm = StateTransitionManager(addresses.stateTransition.stateTransitionProxy);
594596
stm.transferOwnership(addresses.governance);
597+
stm.setPendingAdmin(addresses.chainAdmin);
595598

596599
vm.stopBroadcast();
597600
console.log("Owners updated");
@@ -702,6 +705,7 @@ contract DeployL1Script is Script {
702705
addresses.blobVersionedHashRetriever
703706
);
704707
vm.serializeAddress("deployed_addresses", "validator_timelock_addr", addresses.validatorTimelock);
708+
vm.serializeAddress("deployed_addresses", "chain_admin", addresses.chainAdmin);
705709
vm.serializeString("deployed_addresses", "bridgehub", bridgehub);
706710
vm.serializeString("deployed_addresses", "state_transition", stateTransition);
707711
string memory deployedAddresses = vm.serializeString("deployed_addresses", "bridges", bridges);

l1-contracts/deploy-scripts/RegisterHyperchain.s.sol

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {Script, console2 as console} from "forge-std/Script.sol";
77
import {Vm} from "forge-std/Vm.sol";
88
import {stdToml} from "forge-std/StdToml.sol";
99

10-
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
11-
import {IBridgehub} from "contracts/bridgehub/IBridgehub.sol";
10+
import {Bridgehub} from "contracts/bridgehub/Bridgehub.sol";
1211
import {IZkSyncHyperchain} from "contracts/state-transition/chain-interfaces/IZkSyncHyperchain.sol";
1312
import {ValidatorTimelock} from "contracts/state-transition/ValidatorTimelock.sol";
1413
import {Governance} from "contracts/governance/Governance.sol";
@@ -118,20 +117,17 @@ contract RegisterHyperchainScript is Script {
118117
}
119118

120119
function registerTokenOnBridgehub() internal {
121-
IBridgehub bridgehub = IBridgehub(config.bridgehub);
122-
Ownable ownable = Ownable(config.bridgehub);
120+
Bridgehub bridgehub = Bridgehub(config.bridgehub);
123121

124122
if (bridgehub.tokenIsRegistered(config.baseToken)) {
125123
console.log("Token already registered on Bridgehub");
126124
} else {
127125
bytes memory data = abi.encodeCall(bridgehub.addToken, (config.baseToken));
128-
Utils.executeUpgrade({
129-
_governor: ownable.owner(),
130-
_salt: bytes32(config.bridgehubCreateNewChainSalt),
126+
Utils.chainAdminMulticall({
127+
_chainAdmin: bridgehub.admin(),
131128
_target: config.bridgehub,
132129
_data: data,
133-
_value: 0,
134-
_delay: 0
130+
_value: 0
135131
});
136132
console.log("Token registered on Bridgehub");
137133
}
@@ -156,8 +152,7 @@ contract RegisterHyperchainScript is Script {
156152
}
157153

158154
function registerHyperchain() internal {
159-
IBridgehub bridgehub = IBridgehub(config.bridgehub);
160-
Ownable ownable = Ownable(config.bridgehub);
155+
Bridgehub bridgehub = Bridgehub(config.bridgehub);
161156

162157
vm.recordLogs();
163158
bytes memory data = abi.encodeCall(
@@ -172,14 +167,7 @@ contract RegisterHyperchainScript is Script {
172167
)
173168
);
174169

175-
Utils.executeUpgrade({
176-
_governor: ownable.owner(),
177-
_salt: bytes32(config.bridgehubCreateNewChainSalt),
178-
_target: config.bridgehub,
179-
_data: data,
180-
_value: 0,
181-
_delay: 0
182-
});
170+
Utils.chainAdminMulticall({_chainAdmin: bridgehub.admin(), _target: config.bridgehub, _data: data, _value: 0});
183171
console.log("Hyperchain registered");
184172

185173
// Get new diamond proxy address from emitted events

l1-contracts/deploy-scripts/Utils.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
1010
import {REQUIRED_L2_GAS_PRICE_PER_PUBDATA} from "contracts/common/Config.sol";
1111
import {L2_DEPLOYER_SYSTEM_CONTRACT_ADDR} from "contracts/common/L2ContractAddresses.sol";
1212
import {L2ContractHelper} from "contracts/common/libraries/L2ContractHelper.sol";
13+
import {IChainAdmin} from "contracts/governance/IChainAdmin.sol";
1314

1415
library Utils {
1516
// Cheatcodes address, 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D.
@@ -288,6 +289,15 @@ library Utils {
288289
return bytecode;
289290
}
290291

292+
function chainAdminMulticall(address _chainAdmin, address _target, bytes memory _data, uint256 _value) internal {
293+
IChainAdmin chainAdmin = IChainAdmin(_chainAdmin);
294+
295+
IChainAdmin.Call[] memory calls = new IChainAdmin.Call[](1);
296+
calls[0] = IChainAdmin.Call({target: _target, value: _value, data: _data});
297+
vm.broadcast();
298+
chainAdmin.multicall(calls, true);
299+
}
300+
291301
function executeUpgrade(
292302
address _governor,
293303
bytes32 _salt,

0 commit comments

Comments
 (0)