mirror of
https://github.com/tornadocash/tornado-core.git
synced 2024-11-22 17:50:19 +01:00
add migration script
This commit is contained in:
parent
a6cda4a501
commit
656673b690
@ -38,4 +38,34 @@ contract ETHMixer is Mixer {
|
|||||||
require(success, "payment to _relayer did not go thru");
|
require(success, "payment to _relayer did not go thru");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
@dev Migrate state from old mixer to this one.
|
||||||
|
@param _commitments deposited commitments from previous contract
|
||||||
|
@param _nullifierHashes spent nullifiers from previous contract
|
||||||
|
*/
|
||||||
|
bool public isMigrated = false;
|
||||||
|
function migrateState(bytes32[] calldata _commitments, bytes32[] calldata _nullifierHashes) external onlyOperator {
|
||||||
|
require(!isMigrated, "Migration is disabled");
|
||||||
|
for (uint32 i = 0; i < _commitments.length; i++) {
|
||||||
|
commitments[_commitments[i]] = true;
|
||||||
|
emit Deposit(_commitments[i], nextIndex + i, block.timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextIndex += uint32(_commitments.length);
|
||||||
|
|
||||||
|
for (uint256 i = 0; i < _nullifierHashes.length; i++) {
|
||||||
|
nullifierHashes[_nullifierHashes[i]] = true;
|
||||||
|
emit Withdrawal(address(0), _nullifierHashes[i], address(0), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeTreeForMigration(bytes32[] calldata _filledSubtrees, bytes32 _root) external {
|
||||||
|
require(!isMigrated, "already migrated");
|
||||||
|
filledSubtrees = _filledSubtrees;
|
||||||
|
roots[0] = _root;
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishMigration() external onlyOperator {
|
||||||
|
isMigrated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
76
migrationDeposits.js
Normal file
76
migrationDeposits.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user