move factory deploy

This commit is contained in:
Drygin 2022-01-29 23:38:21 +03:00
parent 61cc980055
commit 1dc13e68e5
8 changed files with 25 additions and 109 deletions

View File

@ -2,8 +2,5 @@
"novaProxy": "0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696",
"newNovaImpl": "TODO",
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
"gasLimit": 200000,
"singletonFactory": "0xce0042B868300000d44A59004Da54A005ffdcf9f",
"singletonFactoryVerboseWrapper": "0xCEe71753C9820f063b38FDbE4cFDAf1d3D928A80",
"salt": "0x746f726e61646f00000000000000000000000000000000000000000000000000"
"gasLimit": 200000
}

View File

@ -3,8 +3,6 @@
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import { ImmutableGovernanceInformation } from "tornado-governance/contracts/v2-vault-and-gas/ImmutableGovernanceInformation.sol";
interface IUpgradeableProxy {
function upgradeTo(address newImplementation) external;
}
@ -17,7 +15,7 @@ interface IAMB {
) external returns (bytes32);
}
contract NovaUpgradeProposal is ImmutableGovernanceInformation {
contract NovaUpgradeProposal {
event MessagePassed(bytes32 msgId);
address public immutable novaProxy;

View File

@ -5,10 +5,6 @@ pragma experimental ABIEncoderV2;
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) {}
function test() public pure returns (int256) {
return 231;
}
}

View File

@ -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

View File

@ -1,23 +1,22 @@
const { ethers } = require('hardhat')
const { generate } = require('../src/0_generateAddresses')
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() {
const singletonFactory = await ethers.getContractAt(
'SingletonFactory',
config.singletonFactoryVerboseWrapper,
const [deployer] = await ethers.getSigners()
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()

View File

@ -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,
}

View File

@ -2,8 +2,7 @@ const { ethers } = require('hardhat')
const { expect } = require('chai')
const config = require('./test.config.json')
const { getSignerFromAddress, takeSnapshot, revertSnapshot } = require('./utils')
const { generate } = require('../src/0_generateAddresses')
const { getSignerFromAddress } = require('./utils')
const ambPath = 'omnibridge/contracts/interfaces/IAMB.sol:IAMB'
@ -18,8 +17,6 @@ const ProposalState = {
}
describe('General functionality tests', () => {
let snapshotId
let torn = config.tokenAddresses.torn
let gov
let tornWhale
@ -39,17 +36,14 @@ describe('General functionality tests', () => {
tornWhale = await getSignerFromAddress(config.whales.torn)
// deploy proposal
const singletonFactory = await ethers.getContractAt(
'SingletonFactory',
config.singletonFactoryVerboseWrapper,
const Proposal = await ethers.getContractFactory('NovaUpgradeProposal')
const [deployer] = await ethers.getSigners()
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', () => {
@ -109,9 +103,4 @@ describe('General functionality tests', () => {
expect(state).to.be.equal(ProposalState.Executed)
})
})
afterEach(async () => {
await revertSnapshot(snapshotId)
snapshotId = await takeSnapshot()
})
})

View File

@ -6,9 +6,6 @@
"ethAmbBridge": "0x4C36d2919e407f0Cc2Ee3c993ccF8ac26d9CE64e",
"xdaiAmbBridge": "0x75df5af045d91108662d8080fd1fefad6aa0bb59",
"gasLimit": 200000,
"singletonFactory": "0xce0042B868300000d44A59004Da54A005ffdcf9f",
"singletonFactoryVerboseWrapper": "0xCEe71753C9820f063b38FDbE4cFDAf1d3D928A80",
"salt": "0x746f726e61646f00000000000000000000000000000000000000000000000000",
"tokenAddresses": {
"torn": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C"
},