From d154e9c8561a5940df8355d83f4c0d7c0dce7d87 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Wed, 15 Apr 2020 15:56:14 +0300 Subject: [PATCH 1/3] SKALE-2284 Remove minting from the token constructor --- VERSION | 2 +- contracts/SkaleToken.sol | 9 --------- migrations/1_deploy_skale_manager_system.js | 19 +++++++++---------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index 8cfbc905b..8428158dc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.1 \ No newline at end of file +1.1.2 \ No newline at end of file diff --git a/contracts/SkaleToken.sol b/contracts/SkaleToken.sol index cb62e452b..87503554c 100644 --- a/contracts/SkaleToken.sol +++ b/contracts/SkaleToken.sol @@ -45,15 +45,6 @@ contract SkaleToken is LockableERC777, Permissions, IDelegatableToken { LockableERC777("SKALE", "SKL", defOps) public { Permissions.initialize(contractsAddress); - - // TODO remove after testing - uint money = 5e9 * 10 ** DECIMALS; - _mint( - address(0), - address(msg.sender), - money, bytes(""), - bytes("") - ); } /** diff --git a/migrations/1_deploy_skale_manager_system.js b/migrations/1_deploy_skale_manager_system.js index a522755a4..6acd825af 100644 --- a/migrations/1_deploy_skale_manager_system.js +++ b/migrations/1_deploy_skale_manager_system.js @@ -150,11 +150,15 @@ async function deploy(deployer, networkName, accounts) { console.log("Contract Skale Token with address", SkaleToken.address, "registred in Contract Manager"); }); - // TODO: Remove after testing - const skaleToken = await SkaleToken.deployed(); - await skaleToken.transfer( - deployed.get("SkaleManager").address, - "1000000000000000000000000000"); + if (!production) { + // TODO: Remove after testing + const skaleToken = await SkaleToken.deployed(); + const money = "5000000000000000000000000000"; // 5e9 * 1e18 + await skaleToken.mint(deployAccount, deployAccount, money, "0x", "0x"); + await skaleToken.transfer( + deployed.get("SkaleManager").address, + "1000000000000000000000000000"); + } console.log('Deploy done, writing results...'); @@ -169,12 +173,7 @@ async function deploy(deployer, networkName, accounts) { } await fsPromises.writeFile(`data/${networkName}.json`, JSON.stringify(jsonObject)); - await sleep(10000); console.log(`Done, check ${networkName}.json file in data folder.`); } -function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); -} - module.exports = deploy; From f980a1322810f75dc9982adce0bb290bb6bd1f79 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Wed, 15 Apr 2020 18:53:29 +0300 Subject: [PATCH 2/3] SKALE-2284 Update tests --- test/SkaleManager.ts | 1 + test/SkaleToken.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/test/SkaleManager.ts b/test/SkaleManager.ts index 25e492d22..b24c69c76 100644 --- a/test/SkaleManager.ts +++ b/test/SkaleManager.ts @@ -58,6 +58,7 @@ contract("SkaleManager", ([owner, validator, developer, hacker, nodeAddress]) => const prefix = "0x000000000000000000000000"; const premined = "100000000000000000000000000"; await skaleToken.mint(owner, skaleManager.address, premined, "0x", "0x"); + await skaleToken.mint(owner, owner, premined, "0x", "0x"); await constantsHolder.setMSR(5); await constantsHolder.setLaunchTimestamp(0); // to allow bounty withdrawing }); diff --git a/test/SkaleToken.ts b/test/SkaleToken.ts index 9c8272473..3af3f46c3 100644 --- a/test/SkaleToken.ts +++ b/test/SkaleToken.ts @@ -29,6 +29,9 @@ contract("SkaleToken", ([owner, holder, receiver, nilAddress, accountWith99]) => contractManager = await deployContractManager(); skaleToken = await deploySkaleToken(contractManager); + + const premined = "5000000000000000000000000000"; // 5e9 * 1e18 + await skaleToken.mint(owner, owner, premined, "0x", "0x"); }); it("should have the correct name", async () => { From eeb3572a5ad075ca8a00e83e931fef2698be3e04 Mon Sep 17 00:00:00 2001 From: Dmytro Stebaiev Date: Thu, 16 Apr 2020 16:50:08 +0300 Subject: [PATCH 3/3] SKALE-2284 Fix gas usage test --- test/delegation/Delegation.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/delegation/Delegation.ts b/test/delegation/Delegation.ts index 902fa1017..6cc00ae25 100644 --- a/test/delegation/Delegation.ts +++ b/test/delegation/Delegation.ts @@ -414,7 +414,8 @@ contract("Delegation", ([owner, it("should not consume extra gas for slashing calculation if holder has never delegated", async () => { const amount = 100; await skaleToken.mint(owner, validator, amount, "0x", "0x"); - console.log(await skaleToken.balanceOf(validator)); + // make owner balance non zero to do not affect transfer costs + await skaleToken.mint(owner, owner, 1, "0x", "0x"); let tx = await skaleToken.transfer(owner, 1, {from: validator}); const gasUsedBeforeSlashing = tx.receipt.gasUsed; for (let i = 0; i < 10; ++i) {