You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
What if roots achieve ROOT_HISTORY_SIZE and rewrite roots[0]? #4
When roots[] achieve ROOT_HISTORY_SIZE and rewrite roots[0], does it means if there is a deposit in the original roots[0] had not been withdraw, it may be locked in the contract forever?
function _insert(bytes32_leaf) internalreturns (uint32index) {
uint32 currentIndex = nextIndex;
require(currentIndex <uint32(2)**levels, "Merkle tree is full. No more leaf can be added");
nextIndex +=1;
bytes32 currentLevelHash = _leaf;
bytes32 left;
bytes32 right;
for (uint32 i =0; i < levels; i++) {
if (currentIndex %2==0) {
left = currentLevelHash;
right = zeros[i];
filledSubtrees[i] = currentLevelHash;
} else {
left = filledSubtrees[i];
right = currentLevelHash;
}
currentLevelHash =hashLeftRight(left, right);
currentIndex /=2;
}
currentRootIndex = (currentRootIndex +1) % ROOT_HISTORY_SIZE; // this line
roots[currentRootIndex] = currentLevelHash;
return nextIndex -1;
}
If a deposit D in the leaf index 5566 hasn't been withdrawn since roots[0], D is still in the index leaf 5566 in the latest root. D is still withdrawable and is not locked in the contract forever.
Activity
ChihChengLiang commentedon Jun 21, 2021
If a deposit D in the leaf index 5566 hasn't been withdrawn since roots[0], D is still in the index leaf 5566 in the latest root. D is still withdrawable and is not locked in the contract forever.