Skip to content

Commit

Permalink
v1.0.0 Mainnet Deployment (#161)
Browse files Browse the repository at this point in the history
* add mainnet deployment scripts

* typo renounceOperator, complete coverage Operated

* complete coverage for Registry.sol

* copy over test for transferOperator/renounceOperator

* fix deployment scripts

* deploy to mainnet

* add fixed commit
  • Loading branch information
Stephane Gosselin authored Aug 24, 2019
1 parent 3434043 commit e22b159
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 46 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@

### Erasure Fractal

#### Rinkeby v2
| Contract | Address |
#### v1.0.0
| Contract | Rinkeby | Mainnet |
| - | - | - |
| [MockNMR](https://github.com/erasureprotocol/erasure-next-contracts/blob/2c14b52b95c15e686d006b8d34411d1321fcfc81/Fractal/contracts/helpers/mock/MockNMR.sol) | [0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9](https://rinkeby.etherscan.io/address/0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9) |
| [Erasure_Posts](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/registries/Erasure_Posts.sol) | [0x036bd70228F7909b5Ef051D5f29f93018e8466f9](https://rinkeby.etherscan.io/address/0x036bd70228F7909b5Ef051D5f29f93018e8466f9) | [0x348FA9DcFf507B81C7A1d7981244eA92E8c6Af29](https://rinkeby.etherscan.io/address/0x348FA9DcFf507B81C7A1d7981244eA92E8c6Af29) |
| [Erasure_Agreements](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/registries/Erasure_Agreements.sol) | [0x3318D98E4CFf8bA162752de3D140640c72D462E9](https://rinkeby.etherscan.io/address/0x3318D98E4CFf8bA162752de3D140640c72D462E9) | [0xa6cf4Bf00feF8866e9F3f61C972bA7C687C6eDbF](https://rinkeby.etherscan.io/address/0xa6cf4Bf00feF8866e9F3f61C972bA7C687C6eDbF) |
| [Erasure_Users](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/registries/Erasure_Users.sol) | [0xc065f32bF6648BBecEBBf683BEAb35a60b93F75D](https://rinkeby.etherscan.io/address/0xc065f32bF6648BBecEBBf683BEAb35a60b93F75D) | [0x789D0082B20A929D6fB64EB4c10c68e827AAB7aB](https://rinkeby.etherscan.io/address/0x789D0082B20A929D6fB64EB4c10c68e827AAB7aB) |
| [Post_Factory](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/posts/Post_Factory.sol) | [0x0611DFe481Ca6D22BEb04cB8b4a5a4001CeBeEa7](https://rinkeby.etherscan.io/address/0x0611DFe481Ca6D22BEb04cB8b4a5a4001CeBeEa7) | [0x480b8d6b5C184C0E34AE66036cC5B4e0390EcA8A](https://rinkeby.etherscan.io/address/0x480b8d6b5C184C0E34AE66036cC5B4e0390EcA8A) |
| [Feed_Factory](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/posts/Feed_Factory.sol) | [0xDCa2Af551f6d7F0Fad5769f5EE8C81eA0a9AE494](https://rinkeby.etherscan.io/address/0xDCa2Af551f6d7F0Fad5769f5EE8C81eA0a9AE494) | [0x1f09dDa453941c2536b9dE8c4382807D1FC603A9](https://rinkeby.etherscan.io/address/0x1f09dDa453941c2536b9dE8c4382807D1FC603A9) |
| [OneWayGriefing_Factory](https://github.com/erasureprotocol/erasure-next-contracts/blob/f2f280a5bf5c9e18a645f4aa24e117099643a8ce/contracts/agreements/OneWayGriefing_Factory.sol) | [0x3Fd3C12F33F5993E2E7cbBEE480aebF71C830C95](https://rinkeby.etherscan.io/address/0x3Fd3C12F33F5993E2E7cbBEE480aebF71C830C95) | [0xF06eA7e3D791D88C7F7A88CE1280F36a823A7A62](https://rinkeby.etherscan.io/address/0xF06eA7e3D791D88C7F7A88CE1280F36a823A7A62) |

#### v0.2.2
| Contract | Rinkeby |
| - | - |
| [MockNMR](https://github.com/erasureprotocol/erasure-next-contracts/blob/2c14b52b95c15e686d006b8d34411d1321fcfc81/Fractal/contracts/helpers/mock/MockNMR.sol) | [0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9](https://rinkeby.etherscan.io/address/0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9) |
| [Erasure_Posts](https://github.com/erasureprotocol/erasure-next-contracts/blob/master/contracts/registries/Erasure_Posts.sol) | [0xEd11206a7d07601985DCC4FeD7B3284a928D022B](https://rinkeby.etherscan.io/address/0xEd11206a7d07601985DCC4FeD7B3284a928D022B) |
Expand All @@ -15,8 +26,9 @@
| [Feed_Factory](https://github.com/erasureprotocol/erasure-next-contracts/blob/master/contracts/posts/Feed_Factory.sol) | [0xabFe46E50D7A72e17688b44ce4f8B95545020560](https://rinkeby.etherscan.io/address/0xabFe46E50D7A72e17688b44ce4f8B95545020560) |
| [OneWayGriefing_Factory](https://github.com/erasureprotocol/erasure-next-contracts/blob/master/contracts/agreements/OneWayGriefing_Factory.sol) | [0x91b052E4800DB77d4d0BFE9fe2bE48352695F282](https://rinkeby.etherscan.io/address/0x91b052E4800DB77d4d0BFE9fe2bE48352695F282) |

#### Rinkeby v1
| Contract | Address |

#### v0.1.0
| Contract | Rinkeby |
| - | - |
| [MockNMR](https://github.com/erasureprotocol/erasure-next-contracts/blob/2c14b52b95c15e686d006b8d34411d1321fcfc81/Fractal/contracts/helpers/mock/MockNMR.sol) | [0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9](https://rinkeby.etherscan.io/address/0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9) |
| [Erasure_Posts](https://github.com/erasureprotocol/erasure-next-contracts/blob/2c14b52b95c15e686d006b8d34411d1321fcfc81/Fractal/contracts/registries/Erasure_Posts.sol) | [0x35433De02F91fec112c91e472869b5A210B0E1Bb](https://rinkeby.etherscan.io/address/0x35433De02F91fec112c91e472869b5A210B0E1Bb) |
Expand Down
4 changes: 2 additions & 2 deletions contracts/agreements/OneWayGriefing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ contract OneWayGriefing is Countdown, Griefing, Metadata, Operated, Template {
Operated._transferOperator(operator);
}

function renouceOperator() public {
function renounceOperator() public {
// restrict access
require(Operated.isActiveOperator(msg.sender), "only active operator");

// transfer operator
Operated._renouceOperator();
Operated._renounceOperator();
}

// view functions
Expand Down
4 changes: 3 additions & 1 deletion contracts/modules/Operated.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ contract Operated {
}

function _transferOperator(address operator) internal {
// transferring operator-ship implies there was an operator set before this
require(_operator != address(0), "operator not set");
_setOperator(operator);
}

function _renouceOperator() internal {
function _renounceOperator() internal {
require(hasActiveOperator(), "only when operator active");
_operator = address(0);
_status = false;
Expand Down
8 changes: 8 additions & 0 deletions contracts/test-contracts/TestOperated.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ contract TestOperated is Operated {
// backdoor function to deactivate Operator for testing
Operated._deactivateOperator();
}

function renounceOperator() public {
Operated._renounceOperator();
}

function transferOperator(address newOperator) public {
Operated._transferOperator(newOperator);
}
}
139 changes: 111 additions & 28 deletions deployment/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ const ethers = require("ethers");
const { createMultihashSha256 } = require("../test/helpers/utils");
require("dotenv").config();

const tokenAddress = "0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9";

const deploy = async (network, secret) => {
let contracts = {
MockNMR: {artifact: require('../build/MockNMR.json')},
Erasure_Agreements: { artifact: require("../build/Erasure_Agreements.json") },
Erasure_Escrows: { artifact: require("../build/Erasure_Escrows.json") },
Erasure_Posts: { artifact: require("../build/Erasure_Posts.json") },
Expand All @@ -19,12 +18,19 @@ const deploy = async (network, secret) => {
Post: { artifact: require("../build/Post.json") }
};

let tokenAddress;
let deployer;
let wallet = new ethers.Wallet(process.env.DEPLOYMENT_PRIV_KEY);
let multisig;
console.log(`Deployment Wallet: ${wallet.address}`);

let defaultGas = ethers.utils.parseUnits('10', 'gwei');

if (network == "rinkeby") {

tokenAddress = "0x1eBf22785bffb6B44fEbBc8a41056b1aD43401f9";
multisig = "0x6087555A70E2F96B7838806e7743041E035a37e5";

// connect to rinkeby
wallet = await wallet.connect(ethers.getDefaultProvider('rinkeby'));

Expand All @@ -39,59 +45,134 @@ const deploy = async (network, secret) => {
// contracts.Erasure_Posts.instance = await new ethers.Contract('0xEd11206a7d07601985DCC4FeD7B3284a928D022B', contracts.Erasure_Posts.artifact.abi, wallet);

// deploy registries
contracts.Erasure_Posts.instance = await deployer.deployAndVerify(contracts.Erasure_Posts.artifact, false);
contracts.Erasure_Agreements.instance = await deployer.deployAndVerify(contracts.Erasure_Agreements.artifact, false);
contracts.Erasure_Users.instance = await deployer.deployAndVerify(contracts.Erasure_Users.artifact, false);
contracts.Erasure_Posts.instance = await deployer.deployAndVerify(contracts.Erasure_Posts.artifact);
contracts.Erasure_Agreements.instance = await deployer.deployAndVerify(contracts.Erasure_Agreements.artifact);
contracts.Erasure_Users.instance = await deployer.deployAndVerify(contracts.Erasure_Users.artifact);

// deploy factories
contracts.Post_Factory.instance = await deployer.deployAndVerify(contracts.Post_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.Feed_Factory.instance = await deployer.deployAndVerify(contracts.Feed_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.OneWayGriefing_Factory.instance = await deployer.deployAndVerify(contracts.OneWayGriefing_Factory.artifact, false, contracts.Erasure_Agreements.instance.contractAddress);

} else if (network == "mainnet") {

tokenAddress = "0x1776e1F26f98b1A5dF9cD347953a26dd3Cb46671";
multisig = "0x0000000000377d181a0ebd08590c6b399b272000";

// connect to rinkeby
wallet = await wallet.connect(ethers.getDefaultProvider('homestead'));

// initialize deployer
deployer = await new etherlime.InfuraPrivateKeyDeployer(
wallet.privateKey,
"mainnet",
process.env.INFURA_API_KEY,
{ gasPrice: defaultGas }
);
deployer.setVerifierApiKey(process.env.ETHERSCAN_API_KEY);

// contracts.Erasure_Posts.instance = await new ethers.Contract('0xF9F79CEe69175B51E4aB2b2D231460B61Ebb2688', contracts.Erasure_Posts.artifact.abi, wallet);
// contracts.Erasure_Agreements.instance = await new ethers.Contract('0xF9F79CEe69175B51E4aB2b2D231460B61Ebb2688', contracts.Erasure_Agreements.artifact.abi, wallet);
// contracts.Erasure_Users.instance = await new ethers.Contract('0xD5fa2751A560b6ca47219224Bc231c56a9849492', contracts.Erasure_Users.artifact.abi, wallet);
// contracts.Post_Factory.instance = await new ethers.Contract('0x750EC6138205Cf1C36b446Dd540E0464E9C0e6Cd', contracts.Post_Factory.artifact.abi, wallet);
// contracts.Feed_Factory.instance = await new ethers.Contract('0x276e1fdB65951B8c1d1c16C5B69a72bE3060E7AA', contracts.Feed_Factory.artifact.abi, wallet);
// contracts.OneWayGriefing_Factory.instance = await new ethers.Contract('0x3A1a3EfeDf5C3932Bac1b637EA8Ac2D904C58480', contracts.OneWayGriefing_Factory.artifact.abi, wallet);

// deploy registries
contracts.Erasure_Posts.instance = await deployer.deployAndVerify(contracts.Erasure_Posts.artifact);
contracts.Erasure_Agreements.instance = await deployer.deployAndVerify(contracts.Erasure_Agreements.artifact);
contracts.Erasure_Users.instance = await deployer.deployAndVerify(contracts.Erasure_Users.artifact);

// deploy factories
contracts.Post_Factory.instance = await deployer.deployAndVerify(contracts.Post_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.Feed_Factory.instance = await deployer.deployAndVerify(contracts.Feed_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.OneWayGriefing_Factory.instance = await deployer.deployAndVerify(contracts.OneWayGriefing_Factory.artifact, false, contracts.Erasure_Agreements.instance.contractAddress);

} else if (network == "ganache") {

multisig = wallet.address;

// initialize deployer
deployer = new etherlime.EtherlimeGanacheDeployer();

// deploy mock NMR
contracts.MockNMR.instance = await deployer.deploy(contracts.MockNMR.artifact);
tokenAddress = contracts.MockNMR.instance.contractAddress;

// deploy registries
contracts.Erasure_Posts.instance = await deployer.deploy(contracts.Erasure_Posts.artifact, false);
contracts.Erasure_Agreements.instance = await deployer.deploy(contracts.Erasure_Agreements.artifact, false);
contracts.Erasure_Users.instance = await deployer.deploy(contracts.Erasure_Users.artifact, false);
contracts.Erasure_Posts.instance = await deployer.deploy(contracts.Erasure_Posts.artifact);
contracts.Erasure_Agreements.instance = await deployer.deploy(contracts.Erasure_Agreements.artifact);
contracts.Erasure_Users.instance = await deployer.deploy(contracts.Erasure_Users.artifact);

// deploy factories
contracts.Post_Factory.instance = await deployer.deploy(contracts.Post_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.Feed_Factory.instance = await deployer.deploy(contracts.Feed_Factory.artifact, false, contracts.Erasure_Posts.instance.contractAddress);
contracts.OneWayGriefing_Factory.instance = await deployer.deploy(contracts.OneWayGriefing_Factory.artifact, false, contracts.Erasure_Agreements.instance.contractAddress);
}

// register factories
console.log(`
Register Factories
`);

await contracts.Erasure_Posts.instance.addFactory(
contracts.Post_Factory.instance.contractAddress,
ethers.utils.hexlify(0x0)
);
console.log('Post_Factory is registered');
).then(async txn => {
console.log(`addFactory() | Post_Factory => Erasure_Posts`);
const receipt = await contracts.Erasure_Posts.instance.verboseWaitForTransaction(txn);
});

await contracts.Erasure_Posts.instance.addFactory(
contracts.Feed_Factory.instance.contractAddress,
ethers.utils.hexlify(0x0)
);
console.log('Feed_Factory is registered');
ethers.utils.hexlify(0x0),
{ gasPrice: defaultGas }
).then(async txn => {
console.log(`addFactory() | Feed_Factory => Erasure_Posts`);
const receipt = await contracts.Erasure_Posts.instance.verboseWaitForTransaction(txn);
});

await contracts.Erasure_Agreements.instance.addFactory(
contracts.OneWayGriefing_Factory.instance.contractAddress,
ethers.utils.hexlify(0x0)
);
console.log('OneWayGriefing_Factory is registered');
ethers.utils.hexlify(0x0),
{ gasPrice: defaultGas }
).then(async txn => {
console.log(`addFactory() | OneWayGriefing_Factory => Erasure_Agreements`);
const receipt = await contracts.Erasure_Agreements.instance.verboseWaitForTransaction(txn);
});

// attempt to create instances
console.log(`
Transfer Registry Ownership
`);

await contracts.Erasure_Posts.instance.transferOwnership(
multisig,
{ gasPrice: defaultGas }
).then(async txn => {
console.log(`transferOwnership() | Erasure_Posts => ${multisig}`);
const receipt = await contracts.Erasure_Posts.instance.verboseWaitForTransaction(txn);
});
await contracts.Erasure_Agreements.instance.transferOwnership(
multisig,
{ gasPrice: defaultGas }
).then(async txn => {
console.log(`transferOwnership() | Erasure_Agreements => ${multisig}`);
const receipt = await contracts.Erasure_Agreements.instance.verboseWaitForTransaction(txn);
});

console.log(`
Create test instances from factories
`);

const userAddress = '0x6087555A70E2F96B7838806e7743041E035a37e5';
const proofHash = createMultihashSha256("proofHash");
console.log(proofHash);
console.log(`multihash: ${proofHash}`);

await contracts.Post_Factory.instance.createExplicit(
userAddress,
proofHash,
'0x0',
'0x0'
'0x0',
{ gasPrice: defaultGas }
).then(async txn => {
const receipt = await contracts.Post_Factory.instance.verboseWaitForTransaction(txn);
const expectedEvent = "InstanceCreated";
Expand All @@ -100,13 +181,14 @@ const deploy = async (network, secret) => {
"There is no such event"
);
contracts.Post.instance = new ethers.Contract(eventFound.args.instance, contracts.Post.artifact.abi, deployer.provider);
console.log(`Post instance created at ${eventFound.args.instance} by ${await contracts.Post.instance.getCreator()}`);
console.log(`createExplicit() | Post_Factory => ${eventFound.args.instance}`);
});

await contracts.Feed_Factory.instance.createExplicit(
userAddress,
contracts.Erasure_Posts.instance.contractAddress,
'0x0'
'0x0',
{ gasPrice: defaultGas }
).then(async txn => {
const receipt = await contracts.Feed_Factory.instance.verboseWaitForTransaction(txn);
const expectedEvent = "InstanceCreated";
Expand All @@ -115,7 +197,7 @@ const deploy = async (network, secret) => {
"There is no such event"
);
contracts.Feed.instance = new ethers.Contract(eventFound.args.instance, contracts.Feed.artifact.abi, deployer.provider);
console.log(`Feed instance created at ${eventFound.args.instance} by ${await contracts.Feed.instance.getCreator()}`);
console.log(`createExplicit() | Feed_Factory => ${eventFound.args.instance}`);
});

await contracts.OneWayGriefing_Factory.instance.createExplicit(
Expand All @@ -126,7 +208,8 @@ const deploy = async (network, secret) => {
1,
2,
100000000,
'0x0'
'0x0',
{ gasPrice: defaultGas }
).then(async txn => {
const receipt = await contracts.OneWayGriefing_Factory.instance.verboseWaitForTransaction(txn);
const expectedEvent = "InstanceCreated";
Expand All @@ -135,11 +218,11 @@ const deploy = async (network, secret) => {
"There is no such event"
);
contracts.OneWayGriefing.instance = new ethers.Contract(eventFound.args.instance, contracts.OneWayGriefing.artifact.abi, deployer.provider);
console.log(`OneWayGriefing instance created at ${eventFound.args.instance} by ${await contracts.OneWayGriefing.instance.getCreator()}`);
console.log(`createExplicit() | OneWayGriefing_Factory => ${eventFound.args.instance}`);
});

};
console.log(``);

module.exports = {
deploy
};

module.exports = { deploy };
Loading

0 comments on commit e22b159

Please sign in to comment.