Executor.sol#L291 : Malicious operator can delete the `l2SystemContractsUpgradeTxHash` and `l2SystemContractsUpgradeBatchNumber` without executing any batches
Audit: 2023-10-zksync-findings
Severity: HIGH

# Lines of code

https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/contracts/ethereum/contracts/zksync/facets/Executor.sol#L291


# Vulnerability details

## Impact

Upgrade transaction can not be done on time due to this deletion of upgrade transaction data.

## Proof of Concept

Validators can execute the batches once they are confirmed.

This will be done either as single batch or as array of batches. For array of batch, following function [executeBatches](https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/contracts/ethereum/contracts/zksync/facets/Executor.sol#L291) is called.

https://github.com/code-423n4/2023-10-zksync/blob/1fb4649b612fac7b4ee613df6f6b7d921ddd6b0d/code/contracts/ethereum/contracts/zksync/facets/Executor.sol#L291-L307

```solidity
    function executeBatches(StoredBatchInfo[] calldata _batchesData) external nonReentrant onlyValidator {
        uint256 nBatches = _batchesData.length; ----------------->> this can be provided as empty array
        for (uint256 i = 0; i < nBatches; i = i.uncheckedInc()) {
            _executeOneBatch(_batchesData[i], i);
            emit BlockExecution(_batchesData[i].batchNumber, _batchesData[i].batchHash, _batchesData[i].commitment);
        }


        uint256 newTotalBatchesExecuted = s.totalBatchesExecuted + nBatches;
        s.totalBatchesExecuted = newTotalBatchesExecuted;
        require(newTotalBatchesExecuted <= s.totalBatchesVerified, "n"); // Can't execute batches more than committed and proven currently.


        uint256 batchWhenUpgradeHappened = s.l2SystemContractsUpgradeBatchNumber;
        if (batchWhenUpgradeHappened != 0 && batchWhenUpgradeHappened <= newTotalBatchesExecuted) {
            delete s.l2SystemContractsUpgradeTxHash;
            delete s.l2SystemContractsUpgradeBatchNumber;
        }
    }
```

In above function, the malicious validator can provide the input argument `_batchesData` as empty array.

If that is the case, no transaction will be executed. At the end of the function both the `l2SystemContractsUpgradeTxHash` and `l2SystemContractsUpgradeBatchNumber` are deleted.

Since anyone can become as validators, they can not be trusted.

Since upgrade is an important event which save the protocol from unexpected incident, causing DOS in executing is very serious issue. So, we are flagging this issue as High.

## Tools Used

Manual review.

## Recommended Mitigation Steps

Update the `executeBatches` as shown below so that at least one transaction must be executed.

```solidity
    function executeBatches(StoredBatchInfo[] calldata _batchesData) external nonReentrant onlyValidator {
        uint256 nBatches = _batchesData.length;
        require(nBatches >0,"invalid input");------------------------>> update from audit.
        for (uint256 i = 0; i < nBatches; i = i.uncheckedInc()) {
            _executeOneBatch(_batchesData[i], i);
            emit BlockExecution(_batches