deploy update
This commit is contained in:
parent
285324595b
commit
7f508d450f
@ -41,6 +41,22 @@ contract TornadoTreesV1Mock {
|
|||||||
withdrawals.push(keccak256(abi.encode(_instance, _nullifier, blockNumber())));
|
withdrawals.push(keccak256(abi.encode(_instance, _nullifier, blockNumber())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRegisteredDeposits() external view returns (bytes32[] memory _deposits) {
|
||||||
|
uint256 count = deposits.length - lastProcessedDepositLeaf;
|
||||||
|
_deposits = new bytes32[](count);
|
||||||
|
for (uint256 i = 0; i < count; i++) {
|
||||||
|
_deposits[i] = deposits[lastProcessedDepositLeaf + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRegisteredWithdrawals() external view returns (bytes32[] memory _withdrawals) {
|
||||||
|
uint256 count = withdrawals.length - lastProcessedWithdrawalLeaf;
|
||||||
|
_withdrawals = new bytes32[](count);
|
||||||
|
for (uint256 i = 0; i < count; i++) {
|
||||||
|
_withdrawals[i] = withdrawals[lastProcessedWithdrawalLeaf + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setLastProcessedDepositLeaf(uint256 _lastProcessedDepositLeaf) public {
|
function setLastProcessedDepositLeaf(uint256 _lastProcessedDepositLeaf) public {
|
||||||
lastProcessedDepositLeaf = _lastProcessedDepositLeaf;
|
lastProcessedDepositLeaf = _lastProcessedDepositLeaf;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
const hre = require('hardhat')
|
const hre = require('hardhat')
|
||||||
const { toFixedHex, poseidonHash2, randomBN } = require('../src/utils')
|
const { toFixedHex, poseidonHash2, randomBN } = require('../src/utils')
|
||||||
const MerkleTree = require('fixed-merkle-tree')
|
const MerkleTree = require('fixed-merkle-tree')
|
||||||
|
const abi = new hre.ethers.utils.AbiCoder()
|
||||||
const instances = [
|
const instances = [
|
||||||
'0x1111000000000000000000000000000000001111',
|
'0x1111000000000000000000000000000000001111',
|
||||||
'0x2222000000000000000000000000000000002222',
|
'0x2222000000000000000000000000000000002222',
|
||||||
@ -17,6 +18,9 @@ const blocks = ['0xaaaaaaaa', '0xbbbbbbbb', '0xcccccccc', '0xdddddddd']
|
|||||||
const CHUNK_TREE_HEIGHT = 2
|
const CHUNK_TREE_HEIGHT = 2
|
||||||
const levels = 20
|
const levels = 20
|
||||||
|
|
||||||
|
const nonRandomBN = (nonce = 0) =>
|
||||||
|
hre.ethers.BigNumber.from('0x004d51bffaafdb3eed0661c1cfd76c8cd6ec1456b80b24bbb855f3a141ebf0be').sub(nonce)
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const governance = '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce'
|
const governance = '0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce'
|
||||||
const [tornadoProxy] = await hre.ethers.getSigners()
|
const [tornadoProxy] = await hre.ethers.getSigners()
|
||||||
@ -29,33 +33,46 @@ async function main() {
|
|||||||
console.log('tornadoTreesV1Mock deployed to:', tornadoTreesV1Mock.address)
|
console.log('tornadoTreesV1Mock deployed to:', tornadoTreesV1Mock.address)
|
||||||
|
|
||||||
const notes = []
|
const notes = []
|
||||||
const depositEvents = []
|
const depositEvents = {}
|
||||||
const withdrawalEvents = []
|
const withdrawalEvents = {}
|
||||||
for (let i = 0; i < 2 ** CHUNK_TREE_HEIGHT; i++) {
|
for (let i = 0; i < 2 ** CHUNK_TREE_HEIGHT; i++) {
|
||||||
notes[i] = {
|
const note = {
|
||||||
instance: instances[i % instances.length],
|
instance: instances[i % instances.length],
|
||||||
depositBlock: blocks[i % blocks.length],
|
depositBlock: blocks[i % blocks.length],
|
||||||
withdrawalBlock: 2 + i + i * 4 * 60 * 24,
|
withdrawalBlock: 2 + i + i * 4 * 60 * 24,
|
||||||
commitment: randomBN(),
|
commitment: nonRandomBN(i),
|
||||||
nullifierHash: randomBN(),
|
nullifierHash: nonRandomBN(i + instances.length),
|
||||||
}
|
}
|
||||||
|
|
||||||
await tornadoTreesV1Mock.register(
|
await tornadoTreesV1Mock.register(
|
||||||
notes[i].instance,
|
note.instance,
|
||||||
toFixedHex(notes[i].commitment),
|
toFixedHex(note.commitment),
|
||||||
toFixedHex(notes[i].nullifierHash),
|
toFixedHex(note.nullifierHash),
|
||||||
notes[i].depositBlock,
|
note.depositBlock,
|
||||||
notes[i].withdrawalBlock,
|
note.withdrawalBlock,
|
||||||
|
{ gasLimit: 200000 },
|
||||||
)
|
)
|
||||||
depositEvents[i] = {
|
const encodedData = abi.encode(
|
||||||
hash: toFixedHex(notes[i].commitment),
|
['address', 'bytes32', 'uint256'],
|
||||||
instance: toFixedHex(notes[i].instance, 20),
|
[note.instance, toFixedHex(note.commitment), note.depositBlock],
|
||||||
block: toFixedHex(notes[i].depositBlock, 4),
|
)
|
||||||
|
const leaf = hre.ethers.utils.keccak256(encodedData)
|
||||||
|
depositEvents[leaf] = {
|
||||||
|
hash: toFixedHex(note.commitment),
|
||||||
|
instance: toFixedHex(note.instance, 20),
|
||||||
|
block: toFixedHex(note.depositBlock, 4),
|
||||||
}
|
}
|
||||||
withdrawalEvents[i] = {
|
const encodedDataW = abi.encode(
|
||||||
hash: toFixedHex(notes[i].nullifierHash),
|
['address', 'bytes32', 'uint256'],
|
||||||
instance: toFixedHex(notes[i].instance, 20),
|
[note.instance, toFixedHex(note.nullifierHash), note.withdrawalBlock],
|
||||||
block: toFixedHex(notes[i].withdrawalBlock, 4),
|
)
|
||||||
|
const leafW = hre.ethers.utils.keccak256(encodedDataW)
|
||||||
|
withdrawalEvents[leafW] = {
|
||||||
|
hash: toFixedHex(note.nullifierHash),
|
||||||
|
instance: toFixedHex(note.instance, 20),
|
||||||
|
block: toFixedHex(note.withdrawalBlock, 4),
|
||||||
}
|
}
|
||||||
|
notes[i] = note
|
||||||
}
|
}
|
||||||
console.log(`Registered ${notes.length} new deposits and withdrawals in tornadoTreesV1Mock`)
|
console.log(`Registered ${notes.length} new deposits and withdrawals in tornadoTreesV1Mock`)
|
||||||
console.log(JSON.stringify(depositEvents, null, 2))
|
console.log(JSON.stringify(depositEvents, null, 2))
|
||||||
@ -82,6 +99,9 @@ async function main() {
|
|||||||
await tornadoTrees.deployed()
|
await tornadoTrees.deployed()
|
||||||
console.log('tornadoTrees deployed to:', tornadoTrees.address)
|
console.log('tornadoTrees deployed to:', tornadoTrees.address)
|
||||||
console.log('You can use the same private key to register new deposits in the tornadoTrees')
|
console.log('You can use the same private key to register new deposits in the tornadoTrees')
|
||||||
|
|
||||||
|
console.log(`\nTORNADO_TREES_V1=${tornadoTreesV1Mock.address}`)
|
||||||
|
console.log(`TORNADO_TREES=${tornadoTrees.address}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We recommend this pattern to be able to use async/await everywhere
|
// We recommend this pattern to be able to use async/await everywhere
|
||||||
|
Loading…
Reference in New Issue
Block a user