Skip to content

Commit

Permalink
Deploy registrar with transperent proxy
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Nov 21, 2024
1 parent 9d007bb commit 9a72fc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion l1-contracts/contracts/chain-registrar/ChainRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract ChainRegistrar is Ownable2StepUpgradeable, ReentrancyGuard {
PubdataPricingMode pubdataPricingMode;
}

constructor(address _bridgehub, address _l2Deployer, address _owner) reentrancyGuardInitializer {
function initialize(address _bridgehub, address _l2Deployer, address _owner) public reentrancyGuardInitializer {
bridgehub = IBridgehub(_bridgehub);
l2Deployer = _l2Deployer;
_transferOwnership(_owner);
Expand Down
21 changes: 16 additions & 5 deletions l1-contracts/deploy-scripts/DeployL1.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,24 @@ contract DeployL1Script is Script {
}

function deployChainRegistrar() internal {
bytes memory bytecodeImplementation = abi.encodePacked(type(ChainRegistrar).creationCode);
address chainRegistrarImplementation = deployViaCreate2(bytecodeImplementation);
console.log("Chain Registrar implementation deployed at:", chainRegistrarImplementation);

bytes memory bytecode = abi.encodePacked(
type(ChainRegistrar).creationCode,
abi.encode(addresses.bridgehub.bridgehubProxy, config.l2Deployer, config.ownerAddress)
type(TransparentUpgradeableProxy).creationCode,
abi.encode(
chainRegistrarImplementation,
addresses.transparentProxyAdmin,
abi.encodeCall(
ChainRegistrar.initialize,
(addresses.bridgehub.bridgehubProxy, config.l2Deployer, config.ownerAddress)
)
)
);
address contractAddress = deployViaCreate2(bytecode);
console.log("Chain Registrar deployed at:", contractAddress);
addresses.chainRegistrar = contractAddress;
address chainRegistrar = deployViaCreate2(bytecode);
console.log("Chain Registrar deployed at:", chainRegistrar);
addresses.chainRegistrar = chainRegistrar;
}

function deployChainAdmin() internal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ contract ChainRegistrarTest is Test {
vm.stopPrank();
vm.prank(stm.admin());
stm.setChainCreationParams(chainCreationParams);
chainRegistrar = new ChainRegistrar(address(bridgeHub), deployer, admin);
chainRegistrar = new ChainRegistrar();
chainRegistrar.initialize(address(bridgeHub), deployer, admin);
}

function test_SuccessfulProposal() public {
Expand Down

0 comments on commit 9a72fc2

Please sign in to comment.