mirror of
https://github.com/tornadocash/tornado-deploy.git
synced 2025-01-15 23:47:56 +01:00
arbitrum deployment
This commit is contained in:
parent
91975bc778
commit
0a93f131ca
69
instances.js
69
instances.js
@ -1,70 +1,9 @@
|
|||||||
module.exports = [
|
module.exports = [
|
||||||
{
|
{
|
||||||
tokenAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
isETH: true,
|
||||||
denomination: "10000000000000000000000",
|
denomination: "1000000000000000000",
|
||||||
domain: "dai-10000.tornadocash.eth",
|
domain: "eth-1.tornadocash.eth",
|
||||||
symbol: "DAI",
|
symbol: "ETH",
|
||||||
decimals: 18
|
decimals: 18
|
||||||
},
|
},
|
||||||
{
|
|
||||||
tokenAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
|
||||||
denomination: "100000000000000000000000",
|
|
||||||
domain: "dai-100000.tornadocash.eth",
|
|
||||||
symbol: "DAI",
|
|
||||||
decimals: 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isCToken: true,
|
|
||||||
tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
|
|
||||||
denomination: "5000000000000",
|
|
||||||
domain: "cdai-50000.tornadocash.eth",
|
|
||||||
symbol: "cDAI",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isCToken: true,
|
|
||||||
tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
|
|
||||||
denomination: "50000000000000",
|
|
||||||
domain: "cdai-500000.tornadocash.eth",
|
|
||||||
symbol: "cDAI",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
isCToken: true,
|
|
||||||
tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643",
|
|
||||||
denomination: "500000000000000",
|
|
||||||
domain: "cdai-5000000.tornadocash.eth",
|
|
||||||
symbol: "cDAI",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
||||||
denomination: "10000000",
|
|
||||||
domain: "wbtc-01.tornadocash.eth",
|
|
||||||
symbol: "wBTC",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
||||||
denomination: "100000000",
|
|
||||||
domain: "wbtc-1.tornadocash.eth",
|
|
||||||
symbol: "wBTC",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
||||||
denomination: "1000000000",
|
|
||||||
domain: "wbtc-10.tornadocash.eth",
|
|
||||||
symbol: "wBTC",
|
|
||||||
decimals: 8
|
|
||||||
},
|
|
||||||
// {
|
|
||||||
// isETH: false,
|
|
||||||
// isCToken: true,
|
|
||||||
// tokenAddress: "0xBA62BCfcAaFc6622853cca2BE6Ac7d845BC0f2Dc",
|
|
||||||
// denomination: "1000000000000000000",
|
|
||||||
// domain: "fau-2.tornadocash.eth",
|
|
||||||
// symbol: "FAU",
|
|
||||||
// decimals: 18
|
|
||||||
// },
|
|
||||||
]
|
]
|
||||||
|
@ -15,25 +15,52 @@ async function main() {
|
|||||||
const privateKey = process.env.PRIVATE_KEY
|
const privateKey = process.env.PRIVATE_KEY
|
||||||
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
|
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL)
|
||||||
const wallet = new ethers.Wallet(privateKey, provider)
|
const wallet = new ethers.Wallet(privateKey, provider)
|
||||||
const deployer = new ethers.Contract(actions.deployer, abi, wallet)
|
let deployer = new ethers.Contract(actions.deployer, abi, wallet)
|
||||||
|
|
||||||
|
let code = await provider.getCode(actions.eipDeployer.expectedAddress)
|
||||||
|
if (!code || code === '0x') {
|
||||||
|
console.log('Deploying EIP-2470 deployer')
|
||||||
|
const balance = await provider.getBalance(actions.eipDeployer.from)
|
||||||
|
if (balance < ethers.utils.parseEther('0.0247')) {
|
||||||
|
console.log('Insufficient balance on deploy address, sending some eth')
|
||||||
|
const tx = await wallet.sendTransaction({
|
||||||
|
to: actions.eipDeployer.from,
|
||||||
|
value: ethers.utils.parseEther('0.0247').sub(balance).toHexString(),
|
||||||
|
gasLimit: ethers.BigNumber.from(21000).toHexString(),
|
||||||
|
gasPrice: 1e6,
|
||||||
|
})
|
||||||
|
console.log('Tx hash:', tx.hash)
|
||||||
|
}
|
||||||
|
const serialized = ethers.utils.serializeTransaction(
|
||||||
|
actions.eipDeployer.tx,
|
||||||
|
actions.eipDeployer.signature,
|
||||||
|
)
|
||||||
|
const tx = await provider.sendTransaction(serialized)
|
||||||
|
console.log('Tx hash:', tx.hash)
|
||||||
|
}
|
||||||
|
|
||||||
for (const action of actions.actions) {
|
for (const action of actions.actions) {
|
||||||
let code = await provider.getCode(action.expectedAddress)
|
code = await provider.getCode(action.expectedAddress)
|
||||||
if (code && code !== '0x') {
|
if (code && code !== '0x') {
|
||||||
console.log(`${action.contract} is already deployed at ${explorer}/address/${action.expectedAddress}`)
|
console.log(`${action.contract} is already deployed at ${explorer}/address/${action.expectedAddress}`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
console.log(`Deploying ${action.contract} to ${action.domain} (${action.expectedAddress})`)
|
console.log(`Deploying ${action.contract} to ${action.domain} (${action.expectedAddress})`)
|
||||||
const tx = await deployer.deploy(action.bytecode, actions.salt, { gasLimit: 7e6, gasPrice: 1e6 })
|
const tx = await deployer.deploy(action.bytecode, actions.salt, { gasLimit: 7e7, gasPrice: 1e6 })
|
||||||
console.log(`TX hash ${explorer}/tx/${tx.hash}`)
|
console.log(`TX hash ${explorer}/tx/${tx.hash}`)
|
||||||
try {
|
try {
|
||||||
await tx.wait()
|
await tx.wait()
|
||||||
console.log(`Deployed ${action.contract} to ${explorer}/address/${action.expectedAddress}\n`)
|
console.log(`Deployed ${action.contract} to ${explorer}/address/${action.expectedAddress}\n`)
|
||||||
|
if (action.contract === 'Deployer.sol') {
|
||||||
|
deployer = deployer.attach(action.expectedAddress)
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`Failed to deploy ${action.contract}, sending debug tx`)
|
console.error(`Failed to deploy ${action.contract}, sending debug tx`)
|
||||||
const tx = await wallet.sendTransaction({ gasLimit: 8e6, data: action.bytecode })
|
// const trace = await provider.send('debug_traceTransaction', [ tx.hash ])
|
||||||
console.log(`TX hash ${explorer}/tx/${tx.hash}`)
|
// console.log(trace)
|
||||||
await tx.wait()
|
const tx2 = await wallet.sendTransaction({ gasLimit: 8e6, data: action.bytecode })
|
||||||
|
console.log(`TX hash ${explorer}/tx/${tx2.hash}`)
|
||||||
|
await tx2.wait()
|
||||||
console.log('Mined, check revert reason on etherscan')
|
console.log('Mined, check revert reason on etherscan')
|
||||||
return
|
return
|
||||||
// throw new Error(`Failed to deploy ${action.contract}`)
|
// throw new Error(`Failed to deploy ${action.contract}`)
|
||||||
|
113
src/generate.js
113
src/generate.js
@ -2,60 +2,82 @@ require('dotenv').config()
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const ethers = require('ethers')
|
const ethers = require('ethers')
|
||||||
const { formatUnits, commify } = ethers.utils
|
const { formatUnits, commify } = ethers.utils
|
||||||
const { deploy, getContractData } = require('./utils')
|
const { deploy, getContractData, expectedAddress } = require('./utils')
|
||||||
|
|
||||||
const { DEPLOYER, SALT, HASHER, VERIFIER, COMP_ADDRESS } = process.env
|
const { DEPLOYER, SALT, HASHER, VERIFIER, COMP_ADDRESS } = process.env
|
||||||
|
|
||||||
const instances = require('../instances')
|
const instances = require('../instances')
|
||||||
// const deployer = getContractData('../deployer/build/contracts/Deployer.json')
|
const deployer = getContractData('../deployer/build/contracts/Deployer.json')
|
||||||
// const verifier = getContractData('../tornado-core/build/contracts/Verifier.json')
|
const verifier = getContractData('../tornado-core/build/contracts/Verifier.json')
|
||||||
// const hasher = getContractData('../tornado-core/build/contracts/Hasher.json')
|
const hasher = getContractData('../tornado-core/build/contracts/Hasher.json')
|
||||||
const ethTornado = getContractData('../tornado-core/build/contracts/ETHTornado.json')
|
const ethTornado = getContractData('../tornado-core/build/contracts/ETHTornado.json')
|
||||||
const ercTornado = getContractData('../tornado-core/build/contracts/ERC20Tornado.json')
|
const ercTornado = getContractData('../tornado-core/build/contracts/ERC20Tornado.json')
|
||||||
const compTornado = getContractData('../tornado-core/build/contracts/cTornado.json')
|
const compTornado = getContractData('../tornado-core/build/contracts/cTornado.json')
|
||||||
|
|
||||||
const actions = []
|
const actions = []
|
||||||
|
|
||||||
|
// eip-2470
|
||||||
|
const eipDeployer = {
|
||||||
|
tx: {
|
||||||
|
nonce: 0,
|
||||||
|
gasPrice: 100000000000,
|
||||||
|
value: 0,
|
||||||
|
data:
|
||||||
|
'0x608060405234801561001057600080fd5b50610134806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80634af63f0214602d575b600080fd5b60cf60048036036040811015604157600080fd5b810190602081018135640100000000811115605b57600080fd5b820183602082011115606c57600080fd5b80359060200191846001830284011164010000000083111715608d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550509135925060eb915050565b604080516001600160a01b039092168252519081900360200190f35b6000818351602085016000f5939250505056fea26469706673582212206b44f8a82cb6b156bfcc3dc6aadd6df4eefd204bc928a4397fd15dacf6d5320564736f6c63430006020033',
|
||||||
|
gasLimit: 247000,
|
||||||
|
},
|
||||||
|
signature: {
|
||||||
|
v: 27,
|
||||||
|
r: '0x247000',
|
||||||
|
s: '0x2470',
|
||||||
|
},
|
||||||
|
from: '0xBb6e024b9cFFACB947A71991E386681B1Cd1477D', // needs to have 0.0247 ETH
|
||||||
|
expectedAddress: '0xce0042B868300000d44A59004Da54A005ffdcf9f',
|
||||||
|
}
|
||||||
|
|
||||||
// Actions needed for new blockchains
|
// Actions needed for new blockchains
|
||||||
// Assumes that EIP-2470 deployer is already present on the chain
|
// Assumes that EIP-2470 deployer is already present on the chain
|
||||||
// actions.push(
|
actions.push(
|
||||||
// deploy({
|
deploy({
|
||||||
// domain: config.deployer.address,
|
domain: 'deployer.contract.tornadocash.eth',
|
||||||
// contract: deployer,
|
contract: deployer,
|
||||||
// args: ['0x0000000000000000000000000000000000000000'],
|
args: ['0x0000000000000000000000000000000000000000'],
|
||||||
// dependsOn: [],
|
dependsOn: [],
|
||||||
// title: 'Deployment proxy',
|
title: 'Deployment proxy',
|
||||||
// description:
|
description:
|
||||||
// 'This a required contract to initialize all other contracts. It is simple wrapper around EIP-2470 Singleton Factory that emits an event of contract deployment. The wrapper also validates if the deployment was successful.',
|
'This a required contract to initialize all other contracts. It is simple wrapper around EIP-2470 Singleton Factory that emits an event of contract deployment. The wrapper also validates if the deployment was successful.',
|
||||||
// }),
|
}),
|
||||||
// )
|
)
|
||||||
//
|
|
||||||
// // Deploy Hasher
|
// Deploy Hasher
|
||||||
// actions.push(
|
actions.push(
|
||||||
// deploy({
|
deploy({
|
||||||
// domain: 'hasher.contract.tornadocash.eth',
|
domain: 'hasher.contract.tornadocash.eth',
|
||||||
// contract: hasher,
|
contract: hasher,
|
||||||
// title: 'Hasher',
|
title: 'Hasher',
|
||||||
// description: 'MiMC hasher contract',
|
description: 'MiMC hasher contract',
|
||||||
// dependsOn: [
|
dependsOn: [],
|
||||||
//
|
}),
|
||||||
// ]
|
)
|
||||||
// }),
|
|
||||||
// )
|
// Deploy verifier
|
||||||
//
|
actions.push(
|
||||||
// // Deploy verifier
|
deploy({
|
||||||
// actions.push(
|
domain: 'verifier.contract.tornadocash.eth',
|
||||||
// deploy({
|
contract: verifier,
|
||||||
// domain: 'verifier.contract.tornadocash.eth',
|
title: 'Verifier',
|
||||||
// contract: verifier,
|
description: 'zkSNARK verifier contract for withdrawals',
|
||||||
// title: 'Verifier',
|
}),
|
||||||
// description: 'zkSNARK verifier contract for withdrawals',
|
)
|
||||||
// }),
|
|
||||||
// )
|
|
||||||
|
|
||||||
// Deploy instances
|
// Deploy instances
|
||||||
for (const instance of instances) {
|
for (const instance of instances) {
|
||||||
const args = [VERIFIER, HASHER, instance.denomination, 20]
|
const args = [
|
||||||
|
expectedAddress(actions, 'verifier.contract.tornadocash.eth'),
|
||||||
|
expectedAddress(actions, 'hasher.contract.tornadocash.eth'),
|
||||||
|
instance.denomination,
|
||||||
|
20,
|
||||||
|
]
|
||||||
if (!instance.isETH) {
|
if (!instance.isETH) {
|
||||||
args.push(instance.tokenAddress)
|
args.push(instance.tokenAddress)
|
||||||
}
|
}
|
||||||
@ -67,18 +89,21 @@ for (const instance of instances) {
|
|||||||
domain: instance.domain,
|
domain: instance.domain,
|
||||||
contract: instance.isETH ? ethTornado : instance.isCToken ? compTornado : ercTornado,
|
contract: instance.isETH ? ethTornado : instance.isCToken ? compTornado : ercTornado,
|
||||||
args,
|
args,
|
||||||
title: `Tornado.cash instance for ${commify(formatUnits(instance.denomination, instance.decimals)).replace(/\.0$/, '')} of ${
|
title: `Tornado.cash instance for ${commify(
|
||||||
instance.symbol
|
formatUnits(instance.denomination, instance.decimals),
|
||||||
|
).replace(/\.0$/, '')} of ${instance.symbol}`,
|
||||||
|
description: `Tornado cash instance for ${commify(
|
||||||
|
formatUnits(instance.denomination, instance.decimals),
|
||||||
|
).replace(/\.0$/, '')} of ${instance.symbol}${
|
||||||
|
instance.isETH ? '' : ` at address ${instance.tokenAddress}`
|
||||||
}`,
|
}`,
|
||||||
description: `Tornado cash instance for ${commify(formatUnits(instance.denomination, instance.decimals)).replace(/\.0$/, '')} of ${
|
|
||||||
instance.symbol
|
|
||||||
}${instance.isETH ? '' : ` at address ${instance.tokenAddress}`}`,
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write output
|
// Write output
|
||||||
const result = {
|
const result = {
|
||||||
|
eipDeployer,
|
||||||
deployer: DEPLOYER,
|
deployer: DEPLOYER,
|
||||||
salt: SALT,
|
salt: SALT,
|
||||||
actions: actions,
|
actions: actions,
|
||||||
|
@ -51,7 +51,16 @@ function deploy({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expectedAddress(actions, action) {
|
||||||
|
const result = actions.find((a) => a.domain === action)
|
||||||
|
if (!result) {
|
||||||
|
throw new Error(`Address not found: ${action}`)
|
||||||
|
}
|
||||||
|
return result.expectedAddress
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
deploy,
|
deploy,
|
||||||
getContractData,
|
getContractData,
|
||||||
|
expectedAddress,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user