fixes for withdrawal function

This commit is contained in:
poma 2021-03-03 12:47:31 +03:00
parent 6f497e495e
commit b871d1e49f
No known key found for this signature in database
GPG Key ID: BA20CB01FE165657
1 changed files with 3 additions and 5 deletions

View File

@ -167,7 +167,7 @@ contract TornadoTrees is Initializable {
uint256 offset = lastProcessedDepositLeaf; uint256 offset = lastProcessedDepositLeaf;
require(_newRoot != previousDepositRoot, "Outdated deposit root"); require(_newRoot != previousDepositRoot, "Outdated deposit root");
require(_currentRoot == depositRoot, "Proposed deposit root is invalid"); require(_currentRoot == depositRoot, "Proposed deposit root is invalid");
require(_pathIndices == offset >> CHUNK_TREE_HEIGHT, "Incorrect insert index"); require(_pathIndices == offset >> CHUNK_TREE_HEIGHT, "Incorrect deposit insert index");
bytes memory data = new bytes(BYTES_SIZE); bytes memory data = new bytes(BYTES_SIZE);
assembly { assembly {
@ -206,14 +206,13 @@ contract TornadoTrees is Initializable {
bytes32 _argsHash, bytes32 _argsHash,
bytes32 _currentRoot, bytes32 _currentRoot,
bytes32 _newRoot, bytes32 _newRoot,
uint256 _pathIndices, uint32 _pathIndices,
TreeLeaf[CHUNK_SIZE] calldata _events TreeLeaf[CHUNK_SIZE] calldata _events
) public { ) public {
uint256 offset = lastProcessedWithdrawalLeaf; uint256 offset = lastProcessedWithdrawalLeaf;
require(_newRoot != previousWithdrawalRoot, "Outdated withdrawal root"); require(_newRoot != previousWithdrawalRoot, "Outdated withdrawal root");
require(_currentRoot == withdrawalRoot, "Proposed withdrawal root is invalid"); require(_currentRoot == withdrawalRoot, "Proposed withdrawal root is invalid");
require(_pathIndices == offset >> CHUNK_TREE_HEIGHT, "Incorrect insert index"); require(_pathIndices == offset >> CHUNK_TREE_HEIGHT, "Incorrect withdrawal insert index");
require(uint256(_newRoot) < SNARK_FIELD, "Proposed root is out of range");
bytes memory data = new bytes(BYTES_SIZE); bytes memory data = new bytes(BYTES_SIZE);
assembly { assembly {
@ -226,7 +225,6 @@ contract TornadoTrees is Initializable {
bytes32 leafHash = keccak256(abi.encode(instance, hash, blockNumber)); bytes32 leafHash = keccak256(abi.encode(instance, hash, blockNumber));
bytes32 withdrawal = offset + i >= withdrawalsV1Length ? withdrawals[offset + i] : tornadoTreesV1.withdrawals(offset + i); bytes32 withdrawal = offset + i >= withdrawalsV1Length ? withdrawals[offset + i] : tornadoTreesV1.withdrawals(offset + i);
require(leafHash == withdrawal, "Incorrect withdrawal"); require(leafHash == withdrawal, "Incorrect withdrawal");
require(uint256(hash) < SNARK_FIELD, "Hash out of range");
assembly { assembly {
mstore(add(add(data, mul(ITEM_SIZE, i)), 0x7c), blockNumber) mstore(add(add(data, mul(ITEM_SIZE, i)), 0x7c), blockNumber)
mstore(add(add(data, mul(ITEM_SIZE, i)), 0x78), instance) mstore(add(add(data, mul(ITEM_SIZE, i)), 0x78), instance)