Skip to content

Commit bad769b

Browse files
committed
Add constructor checks to Adapters, update deploy script
1 parent 844e391 commit bad769b

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

contracts/chain-adapters/ZkStack_Adapter.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ contract ZkStack_Adapter is AdapterInterface, CircleCCTPAdapter {
6565

6666
error ETHGasTokenRequired();
6767
error TransactionFeeTooHigh();
68+
error InvalidBridgeConfig();
6869

6970
/**
7071
* @notice Constructs new Adapter.
@@ -101,6 +102,17 @@ contract ZkStack_Adapter is AdapterInterface, CircleCCTPAdapter {
101102
MAX_TX_GASPRICE = _maxTxGasprice;
102103
L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT = _l1GasToL2GasPerPubDataLimit;
103104
SHARED_BRIDGE = BRIDGE_HUB.sharedBridge();
105+
address zero = address(0);
106+
if (address(_l1Usdc) != zero) {
107+
if (_usdcSharedBridge == zero && address(_cctpTokenMessenger) == zero) {
108+
revert InvalidBridgeConfig();
109+
}
110+
111+
// Bridged and Native USDC are mutually exclusive.
112+
if (_usdcSharedBridge != zero && address(_cctpTokenMessenger) != zero) {
113+
revert InvalidBridgeConfig();
114+
}
115+
}
104116
USDC_SHARED_BRIDGE = _usdcSharedBridge;
105117
address gasToken = BRIDGE_HUB.baseToken(CHAIN_ID);
106118
if (gasToken != ETH_TOKEN_ADDRESS) {

contracts/chain-adapters/ZkStack_CustomGasToken_Adapter.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface, CircleCCTPAdapter {
8585
event ZkStackMessageRelayed(bytes32 indexed canonicalTxHash);
8686
error ETHGasTokenNotAllowed();
8787
error TransactionFeeTooHigh();
88+
error InvalidBridgeConfig();
8889

8990
/**
9091
* @notice Constructs new Adapter.
@@ -124,6 +125,17 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface, CircleCCTPAdapter {
124125
MAX_TX_GASPRICE = _maxTxGasprice;
125126
L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT = _l1GasToL2GasPerPubDataLimit;
126127
SHARED_BRIDGE = BRIDGE_HUB.sharedBridge();
128+
address zero = address(0);
129+
if (address(_l1Usdc) != zero) {
130+
if (_usdcSharedBridge == zero && address(_cctpTokenMessenger) == zero) {
131+
revert InvalidBridgeConfig();
132+
}
133+
134+
// Bridged and Native USDC are mutually exclusive.
135+
if (_usdcSharedBridge != zero && address(_cctpTokenMessenger) != zero) {
136+
revert InvalidBridgeConfig();
137+
}
138+
}
127139
USDC_SHARED_BRIDGE = _usdcSharedBridge;
128140
CUSTOM_GAS_TOKEN = BRIDGE_HUB.baseToken(CHAIN_ID);
129141
if (CUSTOM_GAS_TOKEN == ETH_TOKEN_ADDRESS) {

deploy/059_deploy_lens_spokepool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
44
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
55
import { getDeployedAddress } from "../src/DeploymentUtils";
66
import { getSpokePoolDeploymentInfo } from "../utils/utils.hre";
7-
import { FILL_DEADLINE_BUFFER, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, WGHO } from "./consts";
7+
import { FILL_DEADLINE_BUFFER, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, WGHO, ZERO_ADDRESS } from "./consts";
88

99
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1010
const contractName = "Lens_SpokePool";
@@ -19,7 +19,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1919

2020
const artifact = await deployer.loadArtifact(contractName);
2121

22-
const { zkErc20Bridge, zkUSDCBridge, cctpTokenMessenger } = L2_ADDRESS_MAP[spokeChainId];
22+
const { zkErc20Bridge, zkUSDCBridge, cctpTokenMessenger = ZERO_ADDRESS } = L2_ADDRESS_MAP[spokeChainId];
2323
const initArgs = [
2424
0, // Start at 0 since this first time we're deploying this spoke pool. On future upgrades increase this.
2525
zkErc20Bridge,

0 commit comments

Comments
 (0)