From 790f049719fc0e798a55be3719e65101badab942 Mon Sep 17 00:00:00 2001 From: poma Date: Mon, 22 Mar 2021 20:25:42 +0300 Subject: [PATCH] fix CVF-7 --- contracts/TornadoTrees.sol | 5 +---- contracts/mocks/TornadoTreesMock.sol | 12 ++++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/contracts/TornadoTrees.sol b/contracts/TornadoTrees.sol index d550513..6e23475 100644 --- a/contracts/TornadoTrees.sol +++ b/contracts/TornadoTrees.sol @@ -235,10 +235,7 @@ contract TornadoTrees is Initializable { string memory _type, uint256 _from, // most likely array length after the proposal has passed uint256 _step // optimal step size to find first match, approximately equals dispersion - ) internal view returns (uint256) { - if (_from == 0 && _step == 0) { - return 0; // for tests - } + ) internal view virtual returns (uint256) { // Find the segment with correct array length bool direction = elementExists(_tornadoTreesV1, _type, _from); do { diff --git a/contracts/mocks/TornadoTreesMock.sol b/contracts/mocks/TornadoTreesMock.sol index cb65be3..adcd073 100644 --- a/contracts/mocks/TornadoTreesMock.sol +++ b/contracts/mocks/TornadoTreesMock.sol @@ -113,4 +113,16 @@ contract TornadoTreesMock is TornadoTrees { _withdrawals[i] = withdrawals[lastProcessedWithdrawalLeaf + i]; } } + + function findArrayLength( + ITornadoTreesV1 _tornadoTreesV1, + string memory _type, + uint256 _from, // most likely array length after the proposal has passed + uint256 _step // optimal step size to find first match, approximately equals dispersion + ) internal view override returns (uint256) { + if (_from == 0 && _step == 0) { + return 0; + } + return super.findArrayLength(_tornadoTreesV1, _type, _from, _step); + } }