mirror of
https://github.com/tornadocash/nova-upgrade-proposal.git
synced 2024-11-22 01:26:50 +01:00
move factory deploy
This commit is contained in:
parent
61cc980055
commit
1dc13e68e5
@ -2,8 +2,5 @@
|
|||||||
"novaProxy": "0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696",
|
"novaProxy": "0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696",
|
||||||
"newNovaImpl": "TODO",
|
"newNovaImpl": "TODO",
|
||||||
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
|
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
|
||||||
"gasLimit": 200000,
|
"gasLimit": 200000
|
||||||
"singletonFactory": "0xce0042B868300000d44A59004Da54A005ffdcf9f",
|
|
||||||
"singletonFactoryVerboseWrapper": "0xCEe71753C9820f063b38FDbE4cFDAf1d3D928A80",
|
|
||||||
"salt": "0x746f726e61646f00000000000000000000000000000000000000000000000000"
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
pragma solidity ^0.6.12;
|
pragma solidity ^0.6.12;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import { ImmutableGovernanceInformation } from "tornado-governance/contracts/v2-vault-and-gas/ImmutableGovernanceInformation.sol";
|
|
||||||
|
|
||||||
interface IUpgradeableProxy {
|
interface IUpgradeableProxy {
|
||||||
function upgradeTo(address newImplementation) external;
|
function upgradeTo(address newImplementation) external;
|
||||||
}
|
}
|
||||||
@ -17,7 +15,7 @@ interface IAMB {
|
|||||||
) external returns (bytes32);
|
) external returns (bytes32);
|
||||||
}
|
}
|
||||||
|
|
||||||
contract NovaUpgradeProposal is ImmutableGovernanceInformation {
|
contract NovaUpgradeProposal {
|
||||||
event MessagePassed(bytes32 msgId);
|
event MessagePassed(bytes32 msgId);
|
||||||
|
|
||||||
address public immutable novaProxy;
|
address public immutable novaProxy;
|
||||||
|
@ -5,10 +5,6 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import { GovernanceGasUpgrade } from "tornado-governance/contracts/v2-vault-and-gas/gas/GovernanceGasUpgrade.sol";
|
import { GovernanceGasUpgrade } from "tornado-governance/contracts/v2-vault-and-gas/gas/GovernanceGasUpgrade.sol";
|
||||||
|
|
||||||
contract TestGovernanceUpgrade is GovernanceGasUpgrade {
|
contract MockGovernance is GovernanceGasUpgrade {
|
||||||
constructor(address gasCompLogic, address userVaultAddress) public GovernanceGasUpgrade(gasCompLogic, userVaultAddress) {}
|
constructor(address gasCompLogic, address userVaultAddress) public GovernanceGasUpgrade(gasCompLogic, userVaultAddress) {}
|
||||||
|
|
||||||
function test() public pure returns (int256) {
|
|
||||||
return 231;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,28 +0,0 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
/**
|
|
||||||
*Submitted for verification at Etherscan.io on 2020-03-30
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.6.2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @title Singleton Factory (EIP-2470)
|
|
||||||
* @notice Exposes CREATE2 (EIP-1014) to deploy bytecode on deterministic addresses based on initialization code and salt.
|
|
||||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
|
||||||
*/
|
|
||||||
contract SingletonFactory {
|
|
||||||
/**
|
|
||||||
* @notice Deploys `_initCode` using `_salt` for defining the deterministic address.
|
|
||||||
* @param _initCode Initialization code.
|
|
||||||
* @param _salt Arbitrary value to modify resulting address.
|
|
||||||
* @return createdContract Created contract address.
|
|
||||||
*/
|
|
||||||
function deploy(bytes memory _initCode, bytes32 _salt) public returns (address payable createdContract) {
|
|
||||||
assembly {
|
|
||||||
createdContract := create2(0, add(_initCode, 0x20), mload(_initCode), _salt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// IV is a value changed to generate the vanity address.
|
|
||||||
// IV: 6583047
|
|
@ -1,23 +1,22 @@
|
|||||||
const { ethers } = require('hardhat')
|
const { ethers } = require('hardhat')
|
||||||
const { generate } = require('../src/0_generateAddresses')
|
|
||||||
const config = require('../config')
|
const config = require('../config')
|
||||||
|
|
||||||
async function deploy({ address, bytecode, singletonFactory }) {
|
|
||||||
const contractCode = await ethers.provider.getCode(address)
|
|
||||||
if (contractCode !== '0x') {
|
|
||||||
console.log(`Contract ${address} already deployed. Skipping...`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await singletonFactory.deploy(bytecode, config.salt)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const singletonFactory = await ethers.getContractAt(
|
const [deployer] = await ethers.getSigners()
|
||||||
'SingletonFactory',
|
|
||||||
config.singletonFactoryVerboseWrapper,
|
console.log('Deploying contracts with the account:', deployer.address)
|
||||||
|
|
||||||
|
console.log('Account balance:', (await deployer.getBalance()).toString())
|
||||||
|
|
||||||
|
const Proposal = await ethers.getContractFactory('NovaUpgradeProposal')
|
||||||
|
const proposal = await Proposal.deploy(
|
||||||
|
config.novaProxy,
|
||||||
|
config.newNovaImpl,
|
||||||
|
config.ethAmbBridge,
|
||||||
|
config.gasLimit,
|
||||||
)
|
)
|
||||||
const contract = await generate(config)
|
|
||||||
await deploy({ ...contract, singletonFactory })
|
console.log('Proposal address:', proposal.address)
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
const { ethers } = require('hardhat')
|
|
||||||
|
|
||||||
async function generate(config) {
|
|
||||||
const singletonFactory = await ethers.getContractAt('SingletonFactory', config.singletonFactory)
|
|
||||||
|
|
||||||
const ProposalFactory = await ethers.getContractFactory('NovaUpgradeProposal')
|
|
||||||
const deploymentBytecodeProposal =
|
|
||||||
ProposalFactory.bytecode +
|
|
||||||
ProposalFactory.interface
|
|
||||||
.encodeDeploy([config.novaProxy, config.newNovaImpl, config.ethAmbBridge, config.gasLimit])
|
|
||||||
.slice(2)
|
|
||||||
|
|
||||||
const proposalAddress = ethers.utils.getCreate2Address(
|
|
||||||
singletonFactory.address,
|
|
||||||
config.salt,
|
|
||||||
ethers.utils.keccak256(deploymentBytecodeProposal),
|
|
||||||
)
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
proposalContract: {
|
|
||||||
address: proposalAddress,
|
|
||||||
bytecode: deploymentBytecodeProposal,
|
|
||||||
isProxy: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
generate,
|
|
||||||
}
|
|
@ -2,8 +2,7 @@ const { ethers } = require('hardhat')
|
|||||||
const { expect } = require('chai')
|
const { expect } = require('chai')
|
||||||
|
|
||||||
const config = require('./test.config.json')
|
const config = require('./test.config.json')
|
||||||
const { getSignerFromAddress, takeSnapshot, revertSnapshot } = require('./utils')
|
const { getSignerFromAddress } = require('./utils')
|
||||||
const { generate } = require('../src/0_generateAddresses')
|
|
||||||
|
|
||||||
const ambPath = 'omnibridge/contracts/interfaces/IAMB.sol:IAMB'
|
const ambPath = 'omnibridge/contracts/interfaces/IAMB.sol:IAMB'
|
||||||
|
|
||||||
@ -18,8 +17,6 @@ const ProposalState = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('General functionality tests', () => {
|
describe('General functionality tests', () => {
|
||||||
let snapshotId
|
|
||||||
|
|
||||||
let torn = config.tokenAddresses.torn
|
let torn = config.tokenAddresses.torn
|
||||||
let gov
|
let gov
|
||||||
let tornWhale
|
let tornWhale
|
||||||
@ -39,17 +36,14 @@ describe('General functionality tests', () => {
|
|||||||
tornWhale = await getSignerFromAddress(config.whales.torn)
|
tornWhale = await getSignerFromAddress(config.whales.torn)
|
||||||
|
|
||||||
// deploy proposal
|
// deploy proposal
|
||||||
const singletonFactory = await ethers.getContractAt(
|
const Proposal = await ethers.getContractFactory('NovaUpgradeProposal')
|
||||||
'SingletonFactory',
|
const [deployer] = await ethers.getSigners()
|
||||||
config.singletonFactoryVerboseWrapper,
|
proposal = await Proposal.connect(deployer).deploy(
|
||||||
|
config.novaProxy,
|
||||||
|
config.newNovaImpl,
|
||||||
|
config.ethAmbBridge,
|
||||||
|
config.gasLimit,
|
||||||
)
|
)
|
||||||
|
|
||||||
const contracts = await generate(config)
|
|
||||||
|
|
||||||
await singletonFactory.deploy(contracts.proposalContract.bytecode, config.salt, { gasLimit: 50000000 })
|
|
||||||
proposal = await ethers.getContractAt('NovaUpgradeProposal', contracts.proposalContract.address)
|
|
||||||
|
|
||||||
snapshotId = await takeSnapshot()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Proposal execution', () => {
|
describe('Proposal execution', () => {
|
||||||
@ -109,9 +103,4 @@ describe('General functionality tests', () => {
|
|||||||
expect(state).to.be.equal(ProposalState.Executed)
|
expect(state).to.be.equal(ProposalState.Executed)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
|
||||||
await revertSnapshot(snapshotId)
|
|
||||||
snapshotId = await takeSnapshot()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
|
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
|
||||||
"xdaiAmbBridge": "0x75df5af045d91108662d8080fd1fefad6aa0bb59",
|
"xdaiAmbBridge": "0x75df5af045d91108662d8080fd1fefad6aa0bb59",
|
||||||
"gasLimit": 200000,
|
"gasLimit": 200000,
|
||||||
"singletonFactory": "0xce0042B868300000d44A59004Da54A005ffdcf9f",
|
|
||||||
"singletonFactoryVerboseWrapper": "0xCEe71753C9820f063b38FDbE4cFDAf1d3D928A80",
|
|
||||||
"salt": "0x746f726e61646f00000000000000000000000000000000000000000000000000",
|
|
||||||
"tokenAddresses": {
|
"tokenAddresses": {
|
||||||
"torn": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C"
|
"torn": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user