diff --git a/.circleci/config.yml b/.circleci/config.yml index f947b19577..e859b2614b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -102,7 +102,7 @@ jobs: docker: - image: circleci/node:lts - image: trufflesuite/ganache-cli - command: ganache-cli -i 1234 -l 6720000 + command: ganache-cli -i 1234 -l 9000000 working_directory: ~/protocol steps: - restore_cache: @@ -149,7 +149,7 @@ jobs: docker: - image: circleci/node:lts - image: trufflesuite/ganache-cli - command: ganache-cli -i 1234 -l 6720000 -p 9545 -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" + command: ganache-cli -i 1234 -l 9000000 -p 9545 -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" working_directory: ~/protocol steps: - restore_cache: diff --git a/common/globalTruffleConfig.js b/common/globalTruffleConfig.js index 1df4836946..80ce7949c2 100644 --- a/common/globalTruffleConfig.js +++ b/common/globalTruffleConfig.js @@ -21,7 +21,7 @@ const infuraApiKey = process.env.INFURA_API_KEY ? process.env.INFURA_API_KEY : " // Default options const gasPx = 20000000000; // 20 gwei -const gas = 6720000; // Conservative estimate of the block gas limit. +const gas = 9000000; // Conservative estimate of the block gas limit. // Adds a public network. // Note: All public networks can be accessed using keys from GCS using the ManagedSecretProvider or using a mnemonic in the @@ -143,7 +143,7 @@ module.exports = { settings: { optimizer: { enabled: true, - runs: 500 + runs: 200 } } } diff --git a/core/contracts/financial-templates/implementation/ExpiringMultiPartyCreator.sol b/core/contracts/financial-templates/implementation/ExpiringMultiPartyCreator.sol index 97ec5bef03..d2de00ed91 100644 --- a/core/contracts/financial-templates/implementation/ExpiringMultiPartyCreator.sol +++ b/core/contracts/financial-templates/implementation/ExpiringMultiPartyCreator.sol @@ -4,7 +4,7 @@ pragma experimental ABIEncoderV2; import "../../oracle/implementation/ContractCreator.sol"; import "../../common/implementation/Testable.sol"; import "../../common/implementation/AddressWhitelist.sol"; -import "./ExpiringMultiParty.sol"; +import "./ExpiringMultiPartyLib.sol"; /** @@ -115,7 +115,7 @@ contract ExpiringMultiPartyCreator is ContractCreator, Testable { * @return address of the deployed ExpiringMultiParty contract */ function createExpiringMultiParty(Params memory params) public returns (address) { - ExpiringMultiParty derivative = new ExpiringMultiParty(_convertParams(params)); + address derivative = ExpiringMultiPartyLib.deploy(_convertParams(params)); address[] memory parties = new address[](1); parties[0] = msg.sender; diff --git a/core/contracts/financial-templates/implementation/ExpiringMultiPartyLib.sol b/core/contracts/financial-templates/implementation/ExpiringMultiPartyLib.sol new file mode 100644 index 0000000000..6d15cc0dc7 --- /dev/null +++ b/core/contracts/financial-templates/implementation/ExpiringMultiPartyLib.sol @@ -0,0 +1,23 @@ +pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; + +import "./ExpiringMultiParty.sol"; + + +/** + * @title Provides convenient Expiring Multi Party contract utilities. + * @dev Using this library to deploy EMP's allows calling contracts to avoid importing the full EMP bytecode. + */ +library ExpiringMultiPartyLib { + /** + * @notice Returns address of new EMP deployed with given `params` configuration. + * @dev Caller will need to register new EMP with the Registry to begin requesting prices. Caller is also + * responsible for enforcing constraints on `params`. + * @param params is a `ConstructorParams` object from ExpiringMultiParty. + * @return address of the deployed ExpiringMultiParty contract + */ + function deploy(ExpiringMultiParty.ConstructorParams memory params) public returns (address) { + ExpiringMultiParty derivative = new ExpiringMultiParty(params); + return address(derivative); + } +} diff --git a/core/migrations/14_deploy_expiring_multi_party_creator.js b/core/migrations/14_deploy_expiring_multi_party_creator.js index 4459afd371..2383a192b1 100644 --- a/core/migrations/14_deploy_expiring_multi_party_creator.js +++ b/core/migrations/14_deploy_expiring_multi_party_creator.js @@ -1,5 +1,6 @@ const Finder = artifacts.require("Finder"); const ExpiringMultiPartyCreator = artifacts.require("ExpiringMultiPartyCreator"); +const ExpiringMultiPartyLib = artifacts.require("ExpiringMultiPartyLib"); const AddressWhitelist = artifacts.require("AddressWhitelist"); const TokenFactory = artifacts.require("TokenFactory"); const { getKeysForNetwork, deploy, enableControllableTiming } = require("../../common/MigrationUtils.js"); @@ -17,6 +18,10 @@ module.exports = async function(deployer, network, accounts) { const finder = await Finder.deployed(); const tokenFactory = await TokenFactory.deployed(); + // Deploy EMPLib and link to EMPCreator. + await deploy(deployer, network, ExpiringMultiPartyLib); + await deployer.link(ExpiringMultiPartyLib, ExpiringMultiPartyCreator); + await deploy( deployer, network, diff --git a/core/scripts/local/CalculateContractBytecode.js b/core/scripts/local/CalculateContractBytecode.js index bbcb148e2b..f73b0caba9 100644 --- a/core/scripts/local/CalculateContractBytecode.js +++ b/core/scripts/local/CalculateContractBytecode.js @@ -16,7 +16,7 @@ module.exports = async function(callback) { // Load contracts into script and output info. console.log("loading", argv.contract + ".json"); let obj = require("./../../build/contracts/" + argv.contract + ".json"); - const byteCodeSize = (obj.bytecode.length - 2) / 2; + const byteCodeSize = (obj.deployedBytecode.length - 2) / 2; const remainingSize = 2 ** 14 + 2 ** 13 - byteCodeSize; console.log("Contract is", byteCodeSize, "bytes in size."); console.log("This leaves a total of", remainingSize, "bytes within the EIP170 limit.");