Closed b-tarczynski closed 3 years ago
Overall this solution sounds good to me. The only confusing part is that there may now be multiple DepositSubTreeReady
with the same args, but that can be pointed out/documented in SubtreeQueue
.
If we want to go with that approach then we should rename other SubtreeQueue functions, for example: enqueue -> pushBack(bytes32 subtreeRoot) dequeue -> popFront() returns (uint256 subtreeID, bytes32 subtreeRoot)
I could see the new function just being called requeue
to match original authors naming. If we wanted to follow ECMA/JS syntax which Solidity largely appears to, we would have push
, shift
, and unshift
. But frankly, they all get the intent across :)
@ChihChengLiang feel free to chime in if you have any additional thoughts on this.
The solution sounds good to me too. I like the pushBack
, pushFront
, and popFront
namings too.
Right now rollbacks of deposit batches call
reenqueue
function ondepositManager
that creates new subtree with different subtreeID than was used insubmitDeposits
and emits newDepositSubTreeReady
event with this ID. That is a problem in the case of syncing Deposits and DepositSubtrees from events. If we sync in commanderDepositQueued
events and add them to queue and we pop Deposits onDepositSubTreeReady
events in case of rollback we wouldn't know whichDepositQueued
events assign toDepositSubTreeReady
that was emitted forreenqueue
function.Way to fix that would be to implement the
pushFront(bytes32 subtreeRoot)
function that adds rollbacked Subtree at the beginning of the queue with the same SubtreeID. On the command side we would simply check if we already store subtree with this ID and in that case we would omit it. If we want to go with that approach then we should rename otherSubtreeQueue
functions, for example:Also it would make deposits stay in original order after rollback, because right now submitted deposits are added at the end of the queue.