Skip to content

Commit

Permalink
FIx audittens L10 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless authored Dec 2, 2024
1 parent 9db7c17 commit dc549e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion l1-contracts/contracts/bridgehub/Bridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {BridgehubL2TransactionRequest, L2Message, L2Log, TxStatus} from "../comm
import {AddressAliasHelper} from "../vendor/AddressAliasHelper.sol";
import {IMessageRoot} from "./IMessageRoot.sol";
import {ICTMDeploymentTracker} from "./ICTMDeploymentTracker.sol";
import {MigrationPaused, AssetIdAlreadyRegistered, ChainAlreadyLive, ChainNotLegacy, CTMNotRegistered, ChainIdNotRegistered, AssetHandlerNotRegistered, ZKChainLimitReached, CTMAlreadyRegistered, CTMNotRegistered, ZeroChainId, ChainIdTooBig, BridgeHubAlreadyRegistered, AddressTooLow, MsgValueMismatch, ZeroAddress, Unauthorized, SharedBridgeNotSet, WrongMagicValue, ChainIdAlreadyExists, ChainIdMismatch, ChainIdCantBeCurrentChain, EmptyAssetId, AssetIdNotSupported, IncorrectBridgeHubAddress} from "../common/L1ContractErrors.sol";
import {SettlementLayersMustSettleOnL1, MigrationPaused, AssetIdAlreadyRegistered, ChainAlreadyLive, ChainNotLegacy, CTMNotRegistered, ChainIdNotRegistered, AssetHandlerNotRegistered, ZKChainLimitReached, CTMAlreadyRegistered, CTMNotRegistered, ZeroChainId, ChainIdTooBig, BridgeHubAlreadyRegistered, AddressTooLow, MsgValueMismatch, ZeroAddress, Unauthorized, SharedBridgeNotSet, WrongMagicValue, ChainIdAlreadyExists, ChainIdMismatch, ChainIdCantBeCurrentChain, EmptyAssetId, AssetIdNotSupported, IncorrectBridgeHubAddress} from "../common/L1ContractErrors.sol";

import {AssetHandlerModifiers} from "../bridge/interfaces/AssetHandlerModifiers.sol";

Expand Down Expand Up @@ -309,6 +309,9 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
uint256 _newSettlementLayerChainId,
bool _isWhitelisted
) external onlyOwner onlyL1 {
if (settlementLayer[_newSettlementLayerChainId] != block.chainid) {
revert SettlementLayersMustSettleOnL1();
}
whitelistedSettlementLayers[_newSettlementLayerChainId] = _isWhitelisted;
emit SettlementLayerRegistered(_newSettlementLayerChainId, _isWhitelisted);
}
Expand Down Expand Up @@ -714,6 +717,10 @@ contract Bridgehub is IBridgehub, ReentrancyGuard, Ownable2StepUpgradeable, Paus
require(settlementLayer[bridgehubData.chainId] == block.chainid, "BH: not current SL");
settlementLayer[bridgehubData.chainId] = _settlementChainId;

if (whitelistedSettlementLayers[bridgehubData.chainId]) {
revert SettlementLayersMustSettleOnL1();
}

address zkChain = zkChainMap.get(bridgehubData.chainId);
require(zkChain != address(0), "BH: zkChain not registered");
require(_originalCaller == IZKChain(zkChain).getAdmin(), "BH: incorrect sender");
Expand Down
2 changes: 2 additions & 0 deletions l1-contracts/contracts/common/L1ContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ error NotBridgehub(address addr);
error InvalidAddress(address expected, address actual);
// 0xfa5cd00f
error NotAllowed(address addr);
// 0x02181a13
error SettlementLayersMustSettleOnL1();
// 0x1850b46b
error TokenNotLegacy();
// 0x1929b7de
Expand Down

0 comments on commit dc549e2

Please sign in to comment.