Front Running finalizeBlocks When Sequencers Are Decentralized
When sequencer is decentralized in the future, one sequencer could front run another sequencer's `finalizeBlocks` transaction, without doing the actual proving and sequencing, and steal the reward for sequencing if there is one. Once the frontrunner's `finalizeBlocks` is executed, the original sequencer's transaction would fail as `currentL2BlockNumber` would increment by one and state root hash won't match, as a result the original sequencer's sequencing and proving work will be wasted.\\n```\\nfunction finalizeBlocks(\\n BlockData[] calldata \\_blocksData,\\n bytes calldata \\_proof,\\n uint256 \\_proofType,\\n bytes32 \\_parentStateRootHash\\n)\\n external\\n whenTypeNotPaused(PROVING\\_SYSTEM\\_PAUSE\\_TYPE)\\n whenTypeNotPaused(GENERAL\\_PAUSE\\_TYPE)\\n onlyRole(OPERATOR\\_ROLE)\\n{\\n if (stateRootHashes[currentL2BlockNumber] != \\_parentStateRootHash) {\\n revert StartingRootHashDoesNotMatch();\\n }\\n\\n \\_finalizeBlocks(\\_blocksData, \\_proof, \\_proofType, \\_parentStateRootHash, true);\\n}\\n```\\n
Add the sequencer's address as one parameters in `_finalizeBlocks` function, and include the sequencer's address in the public input hash of the proof in verification function `_verifyProof`.\\n```\\nfunction _finalizeBlocks(\\n   BlockData[] calldata _blocksData,\\n   bytes memory _proof,\\n   uint256 _proofType,\\n   bytes32 _parentStateRootHash,\\n   bool _shouldProve,\\n   address _sequencer\\n )\\n```\\n\\n```\\n_verifyProof(\\n        uint256(\\n          keccak256(\\n            abi.encode(\\n              keccak256(abi.encodePacked(blockHashes)),\\n              firstBlockNumber,\\n              keccak256(abi.encodePacked(timestampHashes)),\\n              keccak256(abi.encodePacked(hashOfRootHashes)),\\n              keccak256(abi.encodePacked(_sequencer)\\n            )\\n          )\\n        ) % MODULO_R,\\n        _proofType,\\n        _proof,\\n        _parentStateRootHash\\n      );\\n```\\n
```\\nfunction finalizeBlocks(\\n BlockData[] calldata \\_blocksData,\\n bytes calldata \\_proof,\\n uint256 \\_proofType,\\n bytes32 \\_parentStateRootHash\\n)\\n external\\n whenTypeNotPaused(PROVING\\_SYSTEM\\_PAUSE\\_TYPE)\\n whenTypeNotPaused(GENERAL\\_PAUSE\\_TYPE)\\n onlyRole(OPERATOR\\_ROLE)\\n{\\n if (stateRootHashes[currentL2BlockNumber] != \\_parentStateRootHash) {\\n revert StartingRootHashDoesNotMatch();\\n }\\n\\n \\_finalizeBlocks(\\_blocksData, \\_proof, \\_proofType, \\_parentStateRootHash, true);\\n}\\n```\\n