Skip to content

Commit

Permalink
N-02 Typographical Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
koloz193 committed Jul 2, 2024
1 parent 1957571 commit dccc19d
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 48 deletions.
6 changes: 3 additions & 3 deletions l1-contracts/contracts/bridge/L1SharedBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {ETH_TOKEN_ADDRESS, TWO_BRIDGES_MAGIC_VALUE} from "../common/Config.sol";
import {IBridgehub, L2TransactionRequestTwoBridgesInner, L2TransactionRequestDirect} from "../bridgehub/IBridgehub.sol";
import {IGetters} from "../state-transition/chain-interfaces/IGetters.sol";
import {L2_BASE_TOKEN_SYSTEM_CONTRACT_ADDR} from "../common/L2ContractAddresses.sol";
import {Unauthorized, ZeroAddress, SharedBridgeValueAlreadySet, SharedBridgeKey, NoFundsTransferred, ZeroBalance, ValueMismatch, NonEmptyMsgValue, L2BridgeNotSet, TokenNotSupported, WithdrawIncorrectAmount, EmptyDeposit, DepositExists, AddressAlreadyUsed, InvalidProof, DepositDoesNotExist, InsufficientChainBalance, WithdrawalFailed, ShareadBridgeValueNotSet, WithdrawalAlreadyFinalized, WithdrawalFailed, L2WithdrawalMessageWrongLength, InvalidSelector, SharedBridgeBalanceMismatch} from "../common/L1ContractErrors.sol";
import {Unauthorized, ZeroAddress, SharedBridgeValueAlreadySet, SharedBridgeKey, NoFundsTransferred, ZeroBalance, ValueMismatch, NonEmptyMsgValue, L2BridgeNotSet, TokenNotSupported, WithdrawIncorrectAmount, EmptyDeposit, DepositExists, AddressAlreadyUsed, InvalidProof, DepositDoesNotExist, InsufficientChainBalance, WithdrawFailed, ShareadBridgeValueNotSet, WithdrawalAlreadyFinalized, L2WithdrawalMessageWrongLength, InvalidSelector, SharedBridgeBalanceMismatch} from "../common/L1ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
Expand Down Expand Up @@ -510,7 +510,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade
callSuccess := call(gas(), _depositSender, _amount, 0, 0, 0, 0)
}
if (!callSuccess) {
revert WithdrawalFailed();
revert WithdrawFailed();
}
} else {
IERC20(_l1Token).safeTransfer(_depositSender, _amount);
Expand Down Expand Up @@ -651,7 +651,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Ownable2StepUpgrade
callSuccess := call(gas(), l1Receiver, amount, 0, 0, 0, 0)
}
if (!callSuccess) {
revert WithdrawalFailed();
revert WithdrawFailed();
}
} else {
// Withdraw funds
Expand Down
4 changes: 0 additions & 4 deletions l1-contracts/contracts/common/L1ContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ error PreviousUpgradeNotFinalized(bytes32 txHash);
error PreviousUpgradeNotCleaned();
// 0x826fb11e
error InsufficientChainBalance();
// 0x27fcd9d1
error WithdrawalFailed();
// 0x97e1359e
error L2WithdrawalMessageWrongLength(uint256 messageLen);
// 0xff8811ff
Expand Down Expand Up @@ -247,8 +245,6 @@ error PubdataCommitmentsEmpty();
error PubdataCommitmentsTooBig();
// 0x53e6d04d
error InvalidPubdataCommitmentsSize();
// 0x32eb8b2f
error LegacyMethodIsSupportedOnlyForEra();
// 0x3580370c
error ReplaceFunctionFacetAddressZero();
// 0x667d17de
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {L2_BOOTLOADER_ADDRESS, L2_TO_L1_MESSENGER_SYSTEM_CONTRACT_ADDR} from "..

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

import {LegacyMethodIsSupportedOnlyForEra, OnlyEraSupported, BatchNotExecuted, HashedLogIsDefault, BaseTokenGasPriceDenominatorNotSet, TransactionNotAllowed, GasPerPubdataMismatch, TooManyFactoryDeps, MsgValueTooLow} from "../../../common/L1ContractErrors.sol";
import {OnlyEraSupported, BatchNotExecuted, HashedLogIsDefault, BaseTokenGasPriceDenominatorNotSet, TransactionNotAllowed, GasPerPubdataMismatch, TooManyFactoryDeps, MsgValueTooLow} from "../../../common/L1ContractErrors.sol";

// While formally the following import is not used, it is needed to inherit documentation from it
import {IZkSyncHyperchainBase} from "../../chain-interfaces/IZkSyncHyperchainBase.sol";
Expand Down Expand Up @@ -202,7 +202,7 @@ contract MailboxFacet is ZkSyncHyperchainBase, IMailbox {
bytes32[] calldata _merkleProof
) external nonReentrant {
if (s.chainId != ERA_CHAIN_ID) {
revert LegacyMethodIsSupportedOnlyForEra();
revert OnlyEraSupported();
}
IL1SharedBridge(s.baseTokenBridge).finalizeWithdrawal({
_chainId: ERA_CHAIN_ID,
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/upgrades/BaseZkSyncUpgradeGenesis.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity 0.8.24;
import {SafeCast} from "@openzeppelin/contracts-v4/utils/math/SafeCast.sol";

import {BaseZkSyncUpgrade} from "./BaseZkSyncUpgrade.sol";
import {ProtocolVersionShouldBeGreater, ProtocolVersionDeltaTooLarge, PreviousUpgradeNotFinalized, PreviousUpgradeBatchNotCleared, ProtocolMajorVersionNotZero} from "./ZkSyncUpgradeErrors.sol";
import {ProtocolVersionTooSmall, ProtocolVersionDeltaTooLarge, PreviousUpgradeNotFinalized, PreviousUpgradeBatchNotCleared, ProtocolMajorVersionNotZero} from "./ZkSyncUpgradeErrors.sol";
import {MAX_ALLOWED_MINOR_VERSION_DELTA} from "../common/Config.sol";
import {SemVer} from "../common/libraries/SemVer.sol";

Expand All @@ -23,7 +23,7 @@ abstract contract BaseZkSyncUpgradeGenesis is BaseZkSyncUpgrade {
// IMPORTANT Genesis Upgrade difference: Note this is the only thing change > to >=
_newProtocolVersion < previousProtocolVersion
) {
revert ProtocolVersionShouldBeGreater(previousProtocolVersion, _newProtocolVersion);
revert ProtocolVersionTooSmall();
}
// slither-disable-next-line unused-return
(uint32 previousMajorVersion, uint32 previousMinorVersion, ) = SemVer.unpackSemVer(
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/upgrades/ZkSyncUpgradeErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

pragma solidity 0.8.24;

// 0x6d172ab2
error ProtocolVersionShouldBeGreater(uint256 _oldProtocolVersion, uint256 _newProtocolVersion);
// 0x88d7b498
error ProtocolVersionTooSmall();
// 0xe1a9736b
error ProtocolVersionDeltaTooLarge(uint256 _proposedDelta, uint256 _maxDelta);
// 0xa0bdf77d
Expand Down
4 changes: 2 additions & 2 deletions l2-contracts/contracts/TestnetPaymaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IERC20} from "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";
import {IPaymaster, ExecutionResult, PAYMASTER_VALIDATION_SUCCESS_MAGIC} from "./interfaces/IPaymaster.sol";
import {IPaymasterFlow} from "./interfaces/IPaymasterFlow.sol";
import {Transaction, BOOTLOADER_ADDRESS} from "./L2ContractHelper.sol";
import {InvalidCaller, InvalidInput, InsufficientAllowance, FailedToTransferTokens, UnsupportedPaymasterFlow} from "./errors/L2ContractErrors.sol";
import {Unauthorized, InvalidInput, InsufficientAllowance, FailedToTransferTokens, UnsupportedPaymasterFlow} from "./errors/L2ContractErrors.sol";

// This is a dummy paymaster. It expects the paymasterInput to contain its "signature" as well as the needed exchange rate.
// It supports only approval-based paymaster flow.
Expand All @@ -21,7 +21,7 @@ contract TestnetPaymaster is IPaymaster {
magic = PAYMASTER_VALIDATION_SUCCESS_MAGIC;

if (msg.sender != BOOTLOADER_ADDRESS) {
revert InvalidCaller(msg.sender);
revert Unauthorized(msg.sender);
}

if (_transaction.paymasterInput.length < 4) {
Expand Down
12 changes: 6 additions & 6 deletions l2-contracts/contracts/bridge/L2SharedBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {AddressAliasHelper} from "../vendor/AddressAliasHelper.sol";
import {L2ContractHelper, DEPLOYER_SYSTEM_CONTRACT, IContractDeployer} from "../L2ContractHelper.sol";
import {SystemContractsCaller} from "../SystemContractsCaller.sol";

import {EmptyAddress, EmptyBytes32, InvalidCaller, AddressMismatch, AmountMustBeGreaterThanZero, DeployFailed} from "../errors/L2ContractErrors.sol";
import {ZeroAddress, EmptyBytes32, Unauthorized, AddressMismatch, AmountMustBeGreaterThanZero, DeployFailed} from "../errors/L2ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
Expand Down Expand Up @@ -60,15 +60,15 @@ contract L2SharedBridge is IL2SharedBridge, Initializable {
address _aliasedOwner
) external reinitializer(2) {
if (_l1SharedBridge == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}

if (_l2TokenProxyBytecodeHash == bytes32(0)) {
revert EmptyBytes32();
}

if (_aliasedOwner == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}

l1SharedBridge = _l1SharedBridge;
Expand All @@ -80,7 +80,7 @@ contract L2SharedBridge is IL2SharedBridge, Initializable {
l2TokenBeacon.transferOwnership(_aliasedOwner);
} else {
if (_l1Bridge == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}
l1Bridge = _l1Bridge;
// l2StandardToken and l2TokenBeacon are already deployed on ERA, and stored in the proxy
Expand All @@ -105,7 +105,7 @@ contract L2SharedBridge is IL2SharedBridge, Initializable {
AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1Bridge &&
AddressAliasHelper.undoL1ToL2Alias(msg.sender) != l1SharedBridge
) {
revert InvalidCaller(msg.sender);
revert Unauthorized(msg.sender);
}

address expectedL2Token = l2TokenAddress(_l1Token);
Expand Down Expand Up @@ -151,7 +151,7 @@ contract L2SharedBridge is IL2SharedBridge, Initializable {

address l1Token = l1TokenAddress[_l2Token];
if (l1Token == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}

bytes memory message = _getL1WithdrawMessage(_l1Receiver, l1Token, _amount);
Expand Down
8 changes: 4 additions & 4 deletions l2-contracts/contracts/bridge/L2StandardERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {UpgradeableBeacon} from "@openzeppelin/contracts-v4/proxy/beacon/Upgrade
import {ERC1967Upgrade} from "@openzeppelin/contracts-v4/proxy/ERC1967/ERC1967Upgrade.sol";

import {IL2StandardToken} from "./interfaces/IL2StandardToken.sol";
import {EmptyAddress, Unauthorized, NonSequentialVersion} from "../errors/L2ContractErrors.sol";
import {ZeroAddress, Unauthorized, NonSequentialVersion} from "../errors/L2ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
Expand Down Expand Up @@ -50,7 +50,7 @@ contract L2StandardERC20 is ERC20PermitUpgradeable, IL2StandardToken, ERC1967Upg
/// In this case, it is packed `name`/`symbol`/`decimals` of the L1 token.
function bridgeInitialize(address _l1Address, bytes calldata _data) external initializer {
if (_l1Address == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}
l1Address = _l1Address;

Expand Down Expand Up @@ -121,7 +121,7 @@ contract L2StandardERC20 is ERC20PermitUpgradeable, IL2StandardToken, ERC1967Upg
// allow the governor of the beacon to reinitialize the token.
address beaconAddress = _getBeacon();
if (msg.sender != UpgradeableBeacon(beaconAddress).owner()) {
revert Unauthorized();
revert Unauthorized(msg.sender);
}

__ERC20_init_unchained(_newName, _newSymbol);
Expand All @@ -133,7 +133,7 @@ contract L2StandardERC20 is ERC20PermitUpgradeable, IL2StandardToken, ERC1967Upg

modifier onlyBridge() {
if (msg.sender != l2Bridge) {
revert Unauthorized();
revert Unauthorized(msg.sender);
}
_;
}
Expand Down
8 changes: 4 additions & 4 deletions l2-contracts/contracts/bridge/L2WrappedBaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ERC20PermitUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/tok
import {IL2WrappedBaseToken} from "./interfaces/IL2WrappedBaseToken.sol";
import {IL2StandardToken} from "./interfaces/IL2StandardToken.sol";

import {EmptyAddress, Unauthorized, UnimplementedMessage, BRIDGE_MINT_NOT_IMPLEMENTED, WithdrawFailed} from "../errors/L2ContractErrors.sol";
import {ZeroAddress, Unauthorized, UnimplementedMessage, BRIDGE_MINT_NOT_IMPLEMENTED, WithdrawFailed} from "../errors/L2ContractErrors.sol";

/// @author Matter Labs
/// @custom:security-contact security@matterlabs.dev
Expand Down Expand Up @@ -50,11 +50,11 @@ contract L2WrappedBaseToken is ERC20PermitUpgradeable, IL2WrappedBaseToken, IL2S
address _l1Address
) external reinitializer(2) {
if (_l2Bridge == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}

if (_l1Address == address(0)) {
revert EmptyAddress();
revert ZeroAddress();
}
l2Bridge = _l2Bridge;
l1Address = _l1Address;
Expand All @@ -70,7 +70,7 @@ contract L2WrappedBaseToken is ERC20PermitUpgradeable, IL2WrappedBaseToken, IL2S

modifier onlyBridge() {
if (msg.sender != l2Bridge) {
revert Unauthorized();
revert Unauthorized(msg.sender);
}
_;
}
Expand Down
10 changes: 4 additions & 6 deletions l2-contracts/contracts/errors/L2ContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// We use a floating point pragma here so it can be used within other projects that interact with the zkSync ecosystem without using our exact pragma version.
pragma solidity ^0.8.20;

// 0xcbd9d2e0
error InvalidCaller(address);
// 0xb4fa3fb3
error InvalidInput();
// 0x2a1b2dd8
Expand All @@ -12,8 +10,8 @@ error InsufficientAllowance(uint256 providedAllowance, uint256 requiredAmount);
error FailedToTransferTokens(address tokenContract, address to, uint256 amount);
// 0xff15b069
error UnsupportedPaymasterFlow();
// 0x7138356f
error EmptyAddress();
// 0xd92e233d
error ZeroAddress();
// 0x1c25715b
error EmptyBytes32();
// 0x1f73225f
Expand All @@ -22,8 +20,8 @@ error AddressMismatch(address expected, address supplied);
error AmountMustBeGreaterThanZero();
// 0xb4f54111
error DeployFailed();
// 0x82b42900
error Unauthorized();
// 0x8e4a23d6
error Unauthorized(address);
// 0x0ac76f01
error NonSequentialVersion();
// 0x6e128399
Expand Down
14 changes: 7 additions & 7 deletions system-contracts/contracts/Compressor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Utils} from "./libraries/Utils.sol";
import {UnsafeBytesCalldata} from "./libraries/UnsafeBytesCalldata.sol";
import {EfficientCall} from "./libraries/EfficientCall.sol";
import {L1_MESSENGER_CONTRACT, STATE_DIFF_ENTRY_SIZE, KNOWN_CODE_STORAGE_CONTRACT} from "./Constants.sol";
import {DerivedKeyNotEqualToCompressedValue, EncodedAndRealBytecodeChunkNotEqual, DictionaryLengthNotFourTimesSmallerThanEncoded, EncodedLengthNotFourTimesSmallerThanOriginal, IndexOutOfBounds, IndexSizeError, ValuesNotEqual, UnsupportedOperation} from "./SystemContractErrors.sol";
import {DerivedKeyNotEqualToCompressedValue, EncodedAndRealBytecodeChunkNotEqual, DictionaryLengthNotFourTimesSmallerThanEncoded, EncodedLengthNotFourTimesSmallerThanOriginal, IndexOutOfBounds, IndexSizeError, ValueMismatch, UnsupportedOperation} from "./SystemContractErrors.sol";

/**
* @author Matter Labs
Expand Down Expand Up @@ -163,7 +163,7 @@ contract Compressor is ICompressor, ISystemContract {
}

if (numInitialWritesProcessed != numberOfInitialWrites) {
revert ValuesNotEqual(numberOfInitialWrites, numInitialWritesProcessed);
revert ValueMismatch(numberOfInitialWrites, numInitialWritesProcessed);
}

// Process repeated writes
Expand All @@ -180,7 +180,7 @@ contract Compressor is ICompressor, ISystemContract {
_compressedStateDiffs[stateDiffPtr:stateDiffPtr + _enumerationIndexSize]
);
if (enumIndex != compressedEnumIndex) {
revert ValuesNotEqual(enumIndex, compressedEnumIndex);
revert ValueMismatch(enumIndex, compressedEnumIndex);
}
stateDiffPtr += _enumerationIndexSize;

Expand All @@ -198,7 +198,7 @@ contract Compressor is ICompressor, ISystemContract {
}

if (stateDiffPtr != _compressedStateDiffs.length) {
revert ValuesNotEqual(stateDiffPtr, _compressedStateDiffs.length);
revert ValueMismatch(stateDiffPtr, _compressedStateDiffs.length);
}

stateDiffHash = EfficientCall.keccak(_stateDiffs);
Expand Down Expand Up @@ -243,15 +243,15 @@ contract Compressor is ICompressor, ISystemContract {
unchecked {
if (_operation == 0 || _operation == 3) {
if (convertedValue != _finalValue) {
revert ValuesNotEqual(_finalValue, convertedValue);
revert ValueMismatch(_finalValue, convertedValue);
}
} else if (_operation == 1) {
if (_initialValue + convertedValue != _finalValue) {
revert ValuesNotEqual(_finalValue, _initialValue + convertedValue);
revert ValueMismatch(_finalValue, _initialValue + convertedValue);
}
} else if (_operation == 2) {
if (_initialValue - convertedValue != _finalValue) {
revert ValuesNotEqual(_finalValue, _initialValue - convertedValue);
revert ValueMismatch(_finalValue, _initialValue - convertedValue);
}
} else {
revert UnsupportedOperation();
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/ContractDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Utils} from "./libraries/Utils.sol";
import {EfficientCall} from "./libraries/EfficientCall.sol";
import {SystemContractHelper} from "./libraries/SystemContractHelper.sol";
import {ISystemContract} from "./interfaces/ISystemContract.sol";
import {Unauthorized, InvalidNonceOrderingChange, ValuesNotEqual, EmptyBytes32, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol";
import {Unauthorized, InvalidNonceOrderingChange, ValueMismatch, EmptyBytes32, NotAllowedToDeployInKernelSpace, HashIsNonZero, NonEmptyAccount, UnknownCodeHash, NonEmptyMsgValue} from "./SystemContractErrors.sol";

/**
* @author Matter Labs
Expand Down Expand Up @@ -253,7 +253,7 @@ contract ContractDeployer is IContractDeployer, ISystemContract {
sumOfValues += _deployments[i].value;
}
if (msg.value != sumOfValues) {
revert ValuesNotEqual(sumOfValues, msg.value);
revert ValueMismatch(sumOfValues, msg.value);
}

for (uint256 i = 0; i < deploymentsLength; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/NonceHolder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {INonceHolder} from "./interfaces/INonceHolder.sol";
import {IContractDeployer} from "./interfaces/IContractDeployer.sol";
import {ISystemContract} from "./interfaces/ISystemContract.sol";
import {DEPLOYER_SYSTEM_CONTRACT} from "./Constants.sol";
import {NonceIncreaseError, ZeroNonceError, NonceJumpError, ValuesNotEqual, NonceAlreadyUsed, NonceNotUsed, Unauthorized} from "./SystemContractErrors.sol";
import {NonceIncreaseError, ZeroNonceError, NonceJumpError, ValueMismatch, NonceAlreadyUsed, NonceNotUsed, Unauthorized} from "./SystemContractErrors.sol";

/**
* @author Matter Labs
Expand Down Expand Up @@ -120,7 +120,7 @@ contract NonceHolder is INonceHolder, ISystemContract {

(, uint256 oldMinNonce) = _splitRawNonce(oldRawNonce);
if (oldMinNonce != _expectedNonce) {
revert ValuesNotEqual(_expectedNonce, oldMinNonce);
revert ValueMismatch(_expectedNonce, oldMinNonce);
}

unchecked {
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/SystemContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ error AddressHasNoCode(address);
error EncodingLengthMismatch();
// 0x4e23d035
error IndexOutOfBounds();
// 0x460b9939
error ValuesNotEqual(uint256 expected, uint256 actual);
// 0x626ade30
error ValueMismatch(uint256 expected, uint256 actual);
// 0x86302004
error HashMismatch(bytes32 expected, uint256 actual);
// 0x122e73e9
Expand Down

0 comments on commit dccc19d

Please sign in to comment.