Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway compatibility #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions l1-contracts/src/ProtocolUpgradeHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ contract ProtocolUpgradeHandler is IProtocolUpgradeHandler {
/// @dev Bridgehub smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication.
IPausable public immutable BRIDGE_HUB;

/// @dev The shared bridge that is used for all bridging.
IPausable public immutable SHARED_BRIDGE;
/// @dev The nullifier contract that is used for bridging.
IPausable public immutable L1_NULLIFIER;

/// @dev The asset router contract that is used for bridging.
IPausable public immutable L1_ASSET_ROUTER;

/// @dev Vault holding L1 native ETH and ERC20 tokens bridged into the ZK chains.
IPausable public immutable L1_NATIVE_TOKEN_VAULT;

/// @notice The address of the Security Council.
address public securityCouncil;
Expand Down Expand Up @@ -105,7 +111,9 @@ contract ProtocolUpgradeHandler is IProtocolUpgradeHandler {
IZKsyncEra _ZKsyncEra,
IStateTransitionManager _stateTransitionManager,
IPausable _bridgeHub,
IPausable _sharedBridge
IPausable _l1Nullifier,
IPausable _l1AssetRouter,
IPausable _l1NativeTokenVault
) {
// Soft configuration check for contracts that inherit this contract.
assert(STANDARD_LEGAL_VETO_PERIOD() <= EXTENDED_LEGAL_VETO_PERIOD);
Expand All @@ -123,7 +131,9 @@ contract ProtocolUpgradeHandler is IProtocolUpgradeHandler {
ZKSYNC_ERA = _ZKsyncEra;
STATE_TRANSITION_MANAGER = _stateTransitionManager;
BRIDGE_HUB = _bridgeHub;
SHARED_BRIDGE = _sharedBridge;
L1_NULLIFIER = _l1Nullifier;
L1_ASSET_ROUTER = _l1AssetRouter;
L1_NATIVE_TOKEN_VAULT = _l1NativeTokenVault;
}

/*//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -394,7 +404,9 @@ contract ProtocolUpgradeHandler is IProtocolUpgradeHandler {
}

try BRIDGE_HUB.pause() {} catch {}
try SHARED_BRIDGE.pause() {} catch {}
try L1_NULLIFIER.pause() {} catch {}
vladbochok marked this conversation as resolved.
Show resolved Hide resolved
try L1_ASSET_ROUTER.pause() {} catch {}
try L1_NATIVE_TOKEN_VAULT.pause() {} catch {}
}

/// @dev Unfreezes the protocol and resumes normal operations.
Expand Down Expand Up @@ -438,7 +450,9 @@ contract ProtocolUpgradeHandler is IProtocolUpgradeHandler {
}
vladbochok marked this conversation as resolved.
Show resolved Hide resolved

try BRIDGE_HUB.unpause() {} catch {}
try SHARED_BRIDGE.unpause() {} catch {}
try L1_NULLIFIER.unpause() {} catch {}
vladbochok marked this conversation as resolved.
Show resolved Hide resolved
try L1_ASSET_ROUTER.unpause() {} catch {}
try L1_NATIVE_TOKEN_VAULT.unpause() {} catch {}
}

/*//////////////////////////////////////////////////////////////
Expand Down
8 changes: 6 additions & 2 deletions l1-contracts/src/TestnetProtocolUpgradeHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ contract TestnetProtocolUpgradeHandler is ProtocolUpgradeHandler {
IZKsyncEra _ZKsyncEra,
IStateTransitionManager _stateTransitionManager,
IPausable _bridgeHub,
IPausable _sharedBridge
IPausable _l1Nullifier,
IPausable _l1AssetRouter,
IPausable _l1NativeTokenVault
)
ProtocolUpgradeHandler(
_securityCouncil,
Expand All @@ -38,7 +40,9 @@ contract TestnetProtocolUpgradeHandler is ProtocolUpgradeHandler {
_ZKsyncEra,
_stateTransitionManager,
_bridgeHub,
_sharedBridge
_l1Nullifier,
_l1AssetRouter,
_l1NativeTokenVault
)
{}
}
24 changes: 18 additions & 6 deletions l1-contracts/test/ProtocolUpgradeHandler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ contract TestProtocolUpgradeHandler is Test {
IZKsyncEra zksyncAddress;
IStateTransitionManager stateTransitionManager;
IPausable bridgeHub;
IPausable sharedBridge;
IPausable l1Nullifier;
IPausable l1AssetRouter;
IPausable l1NativeTokenVault;

ProtocolUpgradeHandler handler;
uint256[] chainIds;
Expand Down Expand Up @@ -74,7 +76,9 @@ contract TestProtocolUpgradeHandler is Test {
);
}
vm.expectCall(address(bridgeHub), abi.encodeWithSelector(IPausable.pause.selector));
vm.expectCall(address(sharedBridge), abi.encodeWithSelector(IPausable.pause.selector));
vm.expectCall(address(l1Nullifier), abi.encodeWithSelector(IPausable.pause.selector));
vm.expectCall(address(l1AssetRouter), abi.encodeWithSelector(IPausable.pause.selector));
vm.expectCall(address(l1NativeTokenVault), abi.encodeWithSelector(IPausable.pause.selector));
}

function _emptyProposal(bytes32 _salt) internal returns (IProtocolUpgradeHandler.UpgradeProposal memory) {
Expand Down Expand Up @@ -154,7 +158,9 @@ contract TestProtocolUpgradeHandler is Test {
stateTransitionManager = IStateTransitionManager(address(new StateTransitionManagerMock(chainIds)));

bridgeHub = IPausable(address(new EmptyContract()));
sharedBridge = IPausable(address(new EmptyContract()));
l1Nullifier = IPausable(address(new EmptyContract()));
l1AssetRouter = IPausable(address(new EmptyContract()));
l1NativeTokenVault = IPausable(address(new EmptyContract()));

handler = new ProtocolUpgradeHandler(
securityCouncil,
Expand All @@ -164,7 +170,9 @@ contract TestProtocolUpgradeHandler is Test {
zksyncAddress,
stateTransitionManager,
bridgeHub,
sharedBridge
l1Nullifier,
l1AssetRouter,
l1NativeTokenVault
);
}

Expand All @@ -184,7 +192,9 @@ contract TestProtocolUpgradeHandler is Test {
zksyncAddress,
stateTransitionManager,
bridgeHub,
sharedBridge
l1Nullifier,
l1AssetRouter,
l1NativeTokenVault
);
assertEq(testHandler.securityCouncil(), securityCouncil);
assertEq(testHandler.guardians(), guardians);
Expand All @@ -193,7 +203,9 @@ contract TestProtocolUpgradeHandler is Test {
assertEq(address(testHandler.ZKSYNC_ERA()), address(zksyncAddress));
assertEq(address(testHandler.STATE_TRANSITION_MANAGER()), address(stateTransitionManager));
assertEq(address(testHandler.BRIDGE_HUB()), address(bridgeHub));
assertEq(address(testHandler.SHARED_BRIDGE()), address(sharedBridge));
assertEq(address(testHandler.L1_NULLIFIER()), address(l1Nullifier));
assertEq(address(testHandler.L1_ASSET_ROUTER()), address(l1AssetRouter));
assertEq(address(testHandler.L1_NATIVE_TOKEN_VAULT()), address(l1NativeTokenVault));
}

function test_StateUpgradeIncorrectProof() public {
Expand Down