From 9132aeb6d5b557e4ed4ed2c52bdf1a6dea250fc4 Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 16 Sep 2019 13:07:14 +0300 Subject: [PATCH] max leaves count fix --- README.md | 6 +++--- contracts/MerkleTreeWithHistory.sol | 2 +- test/MerkleTreeWithHistory.test.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6920fc9..40ecc08 100644 --- a/README.md +++ b/README.md @@ -70,13 +70,13 @@ If you want, you can point the app to existing tornado contracts on Mainnet or K ## Deploy ETH Tornado Cash 1. `cp .env.example .env` 1. Tune all necessary params -1. `npx truffle migrate --f 2 --to 4` +1. `npx truffle migrate --network kovan --reset --f 2 --to 4` ## Deploy ERC20 Tornado Cash 1. `cp .env.example .env` 1. Tune all necessary params -1. `npx truffle migrate --f 2 --to 3` -1. `npx truffle migrate --f 5` +1. `npx truffle migrate --network kovan --reset --f 2 --to 3` +1. `npx truffle migrate --network kovan --reset --f 5` **Note**. If you want to reuse the same verifier for all the mixers, then after you deployed one of the mixers you should only run 4th or 5th migration for ETH or ERC20 mixers respectively (`--f 4 --to 4` or `--f 5`). diff --git a/contracts/MerkleTreeWithHistory.sol b/contracts/MerkleTreeWithHistory.sol index 68cea8a..f75311a 100644 --- a/contracts/MerkleTreeWithHistory.sol +++ b/contracts/MerkleTreeWithHistory.sol @@ -58,7 +58,7 @@ contract MerkleTreeWithHistory { function _insert(uint256 leaf) internal { uint32 current_index = next_index; - require(current_index != 2**(levels - 1), "Merkle tree is full. No more leafs can be added"); + require(current_index != 2**levels, "Merkle tree is full. No more leafs can be added"); next_index += 1; uint256 current_level_hash = leaf; uint256 left; diff --git a/test/MerkleTreeWithHistory.test.js b/test/MerkleTreeWithHistory.test.js index 82d8481..9b39516 100644 --- a/test/MerkleTreeWithHistory.test.js +++ b/test/MerkleTreeWithHistory.test.js @@ -180,7 +180,7 @@ contract('MerkleTreeWithHistory', accounts => { zeroValue = 1337 merkleTreeWithHistory = await MerkleTreeWithHistory.new(levels, zeroValue) - for (let i = 0; i < 2**(levels - 1); i++) { + for (let i = 0; i < 2**levels; i++) { await merkleTreeWithHistory.insert(i+42).should.be.fulfilled }