4 Commits

Author SHA1 Message Date
Alexey
6f42be6213 bump 2021-02-10 23:23:29 +03:00
Alexey
6a01ff9642 testing updates. minor 2021-02-10 23:22:46 +03:00
Alexey
592d3e112d bump version 2021-02-10 20:46:50 +03:00
Alexey
a4b98dd195 IVerifier ->IBatchTreeUpdateVerifier 2021-02-10 20:45:19 +03:00
5 changed files with 23 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
import "./interfaces/ITornadoTreesV1.sol";
import "./interfaces/IVerifier.sol";
import "./interfaces/IBatchTreeUpdateVerifier.sol";
contract TornadoTrees {
address public immutable governance;
@@ -13,7 +13,7 @@ contract TornadoTrees {
bytes32 public withdrawalRoot;
bytes32 public previousWithdrawalRoot;
address public tornadoProxy;
IVerifier public treeUpdateVerifier;
IBatchTreeUpdateVerifier public treeUpdateVerifier;
ITornadoTreesV1 public immutable tornadoTreesV1;
// make sure CHUNK_TREE_HEIGHT has the same value in BatchTreeUpdate.circom
@@ -70,7 +70,7 @@ contract TornadoTrees {
address _governance,
address _tornadoProxy,
ITornadoTreesV1 _tornadoTreesV1,
IVerifier _treeUpdateVerifier,
IBatchTreeUpdateVerifier _treeUpdateVerifier,
SearchParams memory _searchParams
) public {
governance = _governance;
@@ -110,6 +110,9 @@ contract TornadoTrees {
uint256 _from, // most likely array length after the proposal has passed
uint256 _step // optimal step size to find first match, approximately equals dispersion
) public view returns (uint256) {
if (_from == 0 && _step == 0) {
return 0; // for tests
}
// Find the segment with correct array length
bool direction = elementExists(_tornadoTreesV1, _type, _from);
do {
@@ -271,7 +274,7 @@ contract TornadoTrees {
tornadoProxy = _tornadoProxy;
}
function setVerifierContract(IVerifier _treeUpdateVerifier) external onlyGovernance {
function setVerifierContract(IBatchTreeUpdateVerifier _treeUpdateVerifier) external onlyGovernance {
treeUpdateVerifier = _treeUpdateVerifier;
}

View File

@@ -2,6 +2,6 @@
pragma solidity ^0.6.0;
interface IVerifier {
interface IBatchTreeUpdateVerifier {
function verifyProof(bytes calldata proof, uint256[1] calldata input) external view returns (bool);
}

View File

@@ -5,7 +5,7 @@ pragma experimental ABIEncoderV2;
import "../TornadoTrees.sol";
import "../interfaces/ITornadoTreesV1.sol";
import "../interfaces/IVerifier.sol";
import "../interfaces/IBatchTreeUpdateVerifier.sol";
contract TornadoTreesMock is TornadoTrees {
uint256 public currentBlock;
@@ -14,7 +14,7 @@ contract TornadoTreesMock is TornadoTrees {
address _governance,
address _tornadoProxy,
ITornadoTreesV1 _tornadoTreesV1,
IVerifier _treeUpdateVerifier,
IBatchTreeUpdateVerifier _treeUpdateVerifier,
SearchParams memory _searchParams
) public TornadoTrees(_governance, _tornadoProxy, _tornadoTreesV1, _treeUpdateVerifier, _searchParams) {}
@@ -40,6 +40,11 @@ contract TornadoTreesMock is TornadoTrees {
registerWithdrawal(_instance, _nullifier);
}
function updateRoots(bytes32 _depositRoot, bytes32 _withdrawalRoot) public {
depositRoot = _depositRoot;
withdrawalRoot = _withdrawalRoot;
}
function updateDepositTreeMock(
bytes32 _oldRoot,
bytes32 _newRoot,

View File

@@ -1,6 +1,6 @@
{
"name": "tornado-trees",
"version": "0.0.2",
"version": "0.0.4",
"main": "src/index.js",
"repository": "https://github.com/tornadocash/tornado-trees.git",
"author": "Tornadocash team <hello@tornado.cash>",

View File

@@ -37,6 +37,13 @@ describe('findArrayLength', () => {
expect(depositsLength).to.be.equal(depositsEven.length)
})
it('should work for empty array', async () => {
publicArray = await PublicArray.deploy()
// will throw out of gas if you pass non zero params
const depositsLength = await tornadoTrees.findArrayLength(publicArray.address, 'deposits(uint256)', 0, 0)
expect(depositsLength).to.be.equal(0)
})
it('should work for odd array', async () => {
publicArray = await PublicArray.deploy()
await publicArray.setDeposits(depositsOdd)