The PR moves this line out of the loop. The problem now is that the variable blocks does not get updated after an attempt to submit block to the DA layer. This may lead to submit multiple times the same rollup block to the DA layer. See the following scenario:
The sequencer calls submitBlocksToDA.
The function reads pendingBlocks , which returns blocks A, B and C.
The function calls SubmitBlocks and is able to submit A and B.
By these lines, then submitted==false. Thus, the function tries to submit again A, B and C beacuse the variable blocks is not updated with the already published blocks.
It may be enough to change this line to something like blocks := blocks[:res.SubmittedCount] and the references to submittedBlocks accordingly. But the fix should be thought carefully, this is just a recommendation after a quick review.
The PR moves this line out of the loop. The problem now is that the variable blocks does not get updated after an attempt to submit block to the DA layer. This may lead to submit multiple times the same rollup block to the DA layer. See the following scenario:
The sequencer calls submitBlocksToDA.
The function reads pendingBlocks , which returns blocks A, B and C.
The function calls SubmitBlocks and is able to submit A and B.
By these lines, then
submitted==false. Thus, the function tries to submit again A, B and C beacuse the variable blocks is not updated with the already published blocks.It may be enough to change this line to something like blocks := blocks[:res.SubmittedCount] and the references to submittedBlocks accordingly. But the fix should be thought carefully, this is just a recommendation after a quick review.