Incorrect Final Block Number Can Be Finalized
In the data finalization function `finalizeCompressedBlocksWithProof`, `finalizationData.finalBlockNumber` is the final block number of the compressed block data to be finalized. However, there is no check in the contract or the prover to ensure `finalBlockNumber` is correct when there is no new data submitted in the finalization, i.e., `submissionDataLength == 0` . The prover can submit an incorrect final block number and, as a result, the finalized block number (currentL2BlockNumber) would be incorrect. Consequently, the prover can skip block data in the finalization.\\n```\\ncurrentL2BlockNumber = \\_finalizationData.finalBlockNumber;\\n```\\n\\n```\\nif (stateRootHashes[currentL2BlockNumber] != \\_finalizationData.parentStateRootHash) {\\n revert StartingRootHashDoesNotMatch();\\n}\\n```\\n
Resolution\\nfixed by adding a recommended check of `finalBlockNumber` matching the last block number of the submitted data in `_finalizeCompressedBlocks` and a check in the prover and adding `finalBlockNumber` and `lastFinalizedBlockNumber` in the public input of the verifier in the finalization in PR-24\\nIn `_finalizeCompressedBlocks`, check if `finalBlockNumber` is equal to the last block number (finalBlockInData) of the last item of submitted block data. Another solution is to have the prover show that finalBlockNumberis correct in the proof by providing the last finalized block number (lastFinalizedBlockNumber) and verify it by adding `finalBlockNumber` and `lastFinalizedBlockNumber` in the public input of the verifier in the finalization.
```\\ncurrentL2BlockNumber = \\_finalizationData.finalBlockNumber;\\n```\\n