numberOfRegisteredKnots length is increased before the all knots added . If (isKnotRegistered[blsPubKey]) true the current knot can't be added to syndicate since its already registered
Audit: 2022-11-stakehouse-findings
Severity: MEDIUM

# Lines of code

https://github.com/code-423n4/2022-11-stakehouse/blob/4b6828e9c807f2f7c569e6d721ca1289f7cf7112/contracts/syndicate/Syndicate.sol#L555-L580


# Vulnerability details

## Impact

   ### This may cause mismatch between number of knots registered and with actual knots in syndicate.

## Proof of Concept

       function _registerKnotsToSyndicate(bytes[] memory _blsPubKeysForSyndicateKnots) internal {
        uint256 knotsToRegister = _blsPubKeysForSyndicateKnots.length;
        if (knotsToRegister == 0) revert EmptyArray();

        numberOfRegisteredKnots += knotsToRegister; 

        for (uint256 i; i < knotsToRegister; ++i) {
            bytes memory blsPubKey = _blsPubKeysForSyndicateKnots[i];

            if (isKnotRegistered[blsPubKey]) revert KnotIsAlreadyRegistered();

            // incomming knot collateralized SLOT holders do not get historical earnings
            totalETHProcessedPerCollateralizedKnot[blsPubKey] = accumulatedETHPerCollateralizedSlotPerKnot;

            // Health check - if knot is inactive or slashed, should it really be part of the syndicate?
            // KNOTs closer to 32 effective at all times is the target
            (,,,,,bool isActive) = getStakeHouseUniverse().stakeHouseKnotInfo(blsPubKey);
            if (!isActive) revert InactiveKnot();

            uint256 numberOfCollateralisedSlotOwnersForKnot = getSlotRegistry().numberOfCollateralisedSlotOwnersForKnot(blsPubKey);
            if (numberOfCollateralisedSlotOwnersForKnot < 1) revert InvalidNumberOfCollateralizedOwners();
            if (getSlotRegistry().currentSlashedAmountOfSLOTForKnot(blsPubKey) != 0) revert InvalidNumberOfCollateralizedOwners();

            isKnotRegistered[blsPubKey] = true;
            emit KNOTRegistered(blsPubKey);
        }
    }

 ### For example [0x78erjkhwer,0x76ejhwej,0x7656ejrgwe] this array is passed to adding knots to syndicate. 

### Lets assume numberOfRegisteredKnots  is now 10. Now we need to added 3 new knots to syndicate. So after 3 knots assigned the numberOfRegisteredKnots  is 13.

### when enter to the For loop  we are fetching first value _blsPubKeysForSyndicateKnots[0] lets assume  if (isKnotRegistered[blsPubKey])  is false so the first knot  isKnotRegistered[blsPubKey]  is set to true . No problem the knot added successfully.

### In second knot _blsPubKeysForSyndicateKnots[1] we are checking if (isKnotRegistered[blsPubKey]) lets assume this return true. then it will revert KnotIsAlreadyRegistered() error. This knot can't be added to the syndicate since this knot is already registered . 

### Then the third knot _blsPubKeysForSyndicateKnots[1] no problem . this knot also added successfully.

### In this above scenario only two knots only added to syndicate. But we added the length is 3 . So the knots count now mismatch with numberOfRegisteredKnots . 

###  This cause the problem. the length is added 3 but actually we added only 2 knots to syndicate.

## Manual Audit with vscode

## Recommended