From 6b313ddc6f1ad92716ab7c26e9d7b38e0883ea47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Tue, 1 Oct 2019 12:25:33 +0300 Subject: [PATCH 1/9] determine block number from events --- .../src/e2e-tests/governance_tests.ts | 109 +++++++++++------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index afcedd01adf..c32eceff8d6 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -201,6 +201,23 @@ const validatorsAbi = [ stateMutability: 'view', type: 'function', }, + { + anonymous: false, + inputs: [ + { + indexed: true, + name: 'previousOwner', + type: 'address', + }, + { + indexed: true, + name: 'newOwner', + type: 'address', + }, + ], + name: 'OwnershipTransferred', + type: 'event', + }, ] describe('governance tests', () => { @@ -323,6 +340,55 @@ describe('governance tests', () => { return tx.send({ from: account, ...txOptions, gas }) } + describe('when adding any block', () => { + let goldGenesisSupply: any + const addressesWithBalance: string[] = [] + beforeEach(async function(this: any) { + this.timeout(0) // Disable test timeout + await restart() + const genesis = await importGenesis() + goldGenesisSupply = new BigNumber(0) + Object.keys(genesis.alloc).forEach((validator) => { + addressesWithBalance.push(validator) + goldGenesisSupply = goldGenesisSupply.plus(genesis.alloc[validator].balance) + }) + // Block rewards are paid to governance and Locked Gold. + // Governance also receives a portion of transaction fees. + addressesWithBalance.push(await getContractAddress('GovernanceProxy')) + addressesWithBalance.push(await getContractAddress('LockedGoldProxy')) + // Some gold is sent to the reserve and exchange during migrations. + addressesWithBalance.push(await getContractAddress('ReserveProxy')) + addressesWithBalance.push(await getContractAddress('ExchangeProxy')) + }) + + it('should update the Celo Gold total supply correctly', async function(this: any) { + // To register a validator group, we send gold to a new address not included in + // `addressesWithBalance`. Therefore, we check the gold total supply at a block before + // that gold is sent. + // We don't set the total supply until block rewards are paid out, which can happen once + // either LockedGold or Governance are registered. + const validators = new web3.eth.Contract( + validatorsAbi, + await getContractAddress('ValidatorsProxy') + ) + let events = await validators.getPastEvents('OwnershipTransferred', { fromBlock: 0 }) + + const blockNumber = events[events.length - 1].blockNumber + 1 + const goldTotalSupply = await goldToken.methods.totalSupply().call({}, blockNumber) + const balances = await Promise.all( + addressesWithBalance.map( + async (a: string) => new BigNumber(await web3.eth.getBalance(a, blockNumber)) + ) + ) + const expectedGoldTotalSupply = balances.reduce((total: BigNumber, b: BigNumber) => + b.plus(total) + ) + assert.isAtLeast(expectedGoldTotalSupply.toNumber(), goldGenesisSupply.toNumber()) + // + assert.equal(goldTotalSupply.toString(), expectedGoldTotalSupply.toString()) + }) + }) + describe('Validators.numberValidatorsInCurrentSet()', () => { before(async function() { this.timeout(0) @@ -565,47 +631,4 @@ describe('governance tests', () => { assert.isAtLeast(await web3.eth.getBalance(delegate), 1) }) }) - - describe('when adding any block', () => { - let goldGenesisSupply: any - const addressesWithBalance: string[] = [] - beforeEach(async function(this: any) { - this.timeout(0) // Disable test timeout - await restart() - const genesis = await importGenesis() - goldGenesisSupply = new BigNumber(0) - Object.keys(genesis.alloc).forEach((validator) => { - addressesWithBalance.push(validator) - goldGenesisSupply = goldGenesisSupply.plus(genesis.alloc[validator].balance) - }) - // Block rewards are paid to governance and Locked Gold. - // Governance also receives a portion of transaction fees. - addressesWithBalance.push(await getContractAddress('GovernanceProxy')) - addressesWithBalance.push(await getContractAddress('LockedGoldProxy')) - // Some gold is sent to the reserve and exchange during migrations. - addressesWithBalance.push(await getContractAddress('ReserveProxy')) - addressesWithBalance.push(await getContractAddress('ExchangeProxy')) - }) - - it('should update the Celo Gold total supply correctly', async function(this: any) { - // To register a validator group, we send gold to a new address not included in - // `addressesWithBalance`. Therefore, we check the gold total supply at a block before - // that gold is sent. - // We don't set the total supply until block rewards are paid out, which can happen once - // either LockedGold or Governance are registered. - const blockNumber = 175 - const goldTotalSupply = await goldToken.methods.totalSupply().call({}, blockNumber) - const balances = await Promise.all( - addressesWithBalance.map( - async (a: string) => new BigNumber(await web3.eth.getBalance(a, blockNumber)) - ) - ) - const expectedGoldTotalSupply = balances.reduce((total: BigNumber, b: BigNumber) => - b.plus(total) - ) - assert.isAtLeast(expectedGoldTotalSupply.toNumber(), goldGenesisSupply.toNumber()) - // - assert.equal(goldTotalSupply.toString(), expectedGoldTotalSupply.toString()) - }) - }) }) From 7189be03d791b263d6eb606e071c38c9fbda7e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Tue, 1 Oct 2019 12:53:25 +0300 Subject: [PATCH 2/9] fixed lint --- packages/celotool/src/e2e-tests/governance_tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index c32eceff8d6..217986ee3bc 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -367,11 +367,11 @@ describe('governance tests', () => { // that gold is sent. // We don't set the total supply until block rewards are paid out, which can happen once // either LockedGold or Governance are registered. - const validators = new web3.eth.Contract( + const _validators = new web3.eth.Contract( validatorsAbi, await getContractAddress('ValidatorsProxy') ) - let events = await validators.getPastEvents('OwnershipTransferred', { fromBlock: 0 }) + const events = await _validators.getPastEvents('OwnershipTransferred', { fromBlock: 0 }) const blockNumber = events[events.length - 1].blockNumber + 1 const goldTotalSupply = await goldToken.methods.totalSupply().call({}, blockNumber) From 83b24e92af029f34e144778c189da7467698999c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Wed, 2 Oct 2019 21:27:11 +0300 Subject: [PATCH 3/9] moving back to original place --- .../src/e2e-tests/governance_tests.ts | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 217986ee3bc..cccd2048795 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -340,55 +340,6 @@ describe('governance tests', () => { return tx.send({ from: account, ...txOptions, gas }) } - describe('when adding any block', () => { - let goldGenesisSupply: any - const addressesWithBalance: string[] = [] - beforeEach(async function(this: any) { - this.timeout(0) // Disable test timeout - await restart() - const genesis = await importGenesis() - goldGenesisSupply = new BigNumber(0) - Object.keys(genesis.alloc).forEach((validator) => { - addressesWithBalance.push(validator) - goldGenesisSupply = goldGenesisSupply.plus(genesis.alloc[validator].balance) - }) - // Block rewards are paid to governance and Locked Gold. - // Governance also receives a portion of transaction fees. - addressesWithBalance.push(await getContractAddress('GovernanceProxy')) - addressesWithBalance.push(await getContractAddress('LockedGoldProxy')) - // Some gold is sent to the reserve and exchange during migrations. - addressesWithBalance.push(await getContractAddress('ReserveProxy')) - addressesWithBalance.push(await getContractAddress('ExchangeProxy')) - }) - - it('should update the Celo Gold total supply correctly', async function(this: any) { - // To register a validator group, we send gold to a new address not included in - // `addressesWithBalance`. Therefore, we check the gold total supply at a block before - // that gold is sent. - // We don't set the total supply until block rewards are paid out, which can happen once - // either LockedGold or Governance are registered. - const _validators = new web3.eth.Contract( - validatorsAbi, - await getContractAddress('ValidatorsProxy') - ) - const events = await _validators.getPastEvents('OwnershipTransferred', { fromBlock: 0 }) - - const blockNumber = events[events.length - 1].blockNumber + 1 - const goldTotalSupply = await goldToken.methods.totalSupply().call({}, blockNumber) - const balances = await Promise.all( - addressesWithBalance.map( - async (a: string) => new BigNumber(await web3.eth.getBalance(a, blockNumber)) - ) - ) - const expectedGoldTotalSupply = balances.reduce((total: BigNumber, b: BigNumber) => - b.plus(total) - ) - assert.isAtLeast(expectedGoldTotalSupply.toNumber(), goldGenesisSupply.toNumber()) - // - assert.equal(goldTotalSupply.toString(), expectedGoldTotalSupply.toString()) - }) - }) - describe('Validators.numberValidatorsInCurrentSet()', () => { before(async function() { this.timeout(0) @@ -631,4 +582,53 @@ describe('governance tests', () => { assert.isAtLeast(await web3.eth.getBalance(delegate), 1) }) }) + + describe('when adding any block', () => { + let goldGenesisSupply: any + const addressesWithBalance: string[] = [] + beforeEach(async function(this: any) { + this.timeout(0) // Disable test timeout + await restart() + const genesis = await importGenesis() + goldGenesisSupply = new BigNumber(0) + Object.keys(genesis.alloc).forEach((validator) => { + addressesWithBalance.push(validator) + goldGenesisSupply = goldGenesisSupply.plus(genesis.alloc[validator].balance) + }) + // Block rewards are paid to governance and Locked Gold. + // Governance also receives a portion of transaction fees. + addressesWithBalance.push(await getContractAddress('GovernanceProxy')) + addressesWithBalance.push(await getContractAddress('LockedGoldProxy')) + // Some gold is sent to the reserve and exchange during migrations. + addressesWithBalance.push(await getContractAddress('ReserveProxy')) + addressesWithBalance.push(await getContractAddress('ExchangeProxy')) + }) + + it('should update the Celo Gold total supply correctly', async function(this: any) { + // To register a validator group, we send gold to a new address not included in + // `addressesWithBalance`. Therefore, we check the gold total supply at a block before + // that gold is sent. + // We don't set the total supply until block rewards are paid out, which can happen once + // either LockedGold or Governance are registered. + const _validators = new web3.eth.Contract( + validatorsAbi, + await getContractAddress('ValidatorsProxy') + ) + const events = await _validators.getPastEvents('OwnershipTransferred', { fromBlock: 0 }) + + const blockNumber = events[events.length - 1].blockNumber + 1 + const goldTotalSupply = await goldToken.methods.totalSupply().call({}, blockNumber) + const balances = await Promise.all( + addressesWithBalance.map( + async (a: string) => new BigNumber(await web3.eth.getBalance(a, blockNumber)) + ) + ) + const expectedGoldTotalSupply = balances.reduce((total: BigNumber, b: BigNumber) => + b.plus(total) + ) + assert.isAtLeast(expectedGoldTotalSupply.toNumber(), goldGenesisSupply.toNumber()) + // + assert.equal(goldTotalSupply.toString(), expectedGoldTotalSupply.toString()) + }) + }) }) From 16f950f30ffe343ee9f0c50aeaa1f7eb1a15437b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2019 16:15:30 +0300 Subject: [PATCH 4/9] added debug messages --- packages/celotool/src/e2e-tests/governance_tests.ts | 5 +++++ packages/celotool/src/e2e-tests/utils.ts | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index cccd2048795..10345caf574 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -246,7 +246,9 @@ describe('governance tests', () => { after(context.hooks.after) const restart = async () => { + console.log('restarting', new Date()) await context.hooks.restart() + console.log('restarted', new Date()) web3 = new Web3('http://localhost:8545') lockedGold = new web3.eth.Contract(lockedGoldAbi, await getContractAddress('LockedGoldProxy')) goldToken = new web3.eth.Contract(erc20Abi, await getContractAddress('GoldTokenProxy')) @@ -375,6 +377,7 @@ describe('governance tests', () => { validatorsAbi, await getContractAddress('ValidatorsProxy') ) + console.log('Waiting', new Date()) // Give the node time to sync. await sleep(15) const members = await getValidatorGroupMembers() @@ -446,6 +449,8 @@ describe('governance tests', () => { validatorsAbi, await getContractAddress('ValidatorsProxy') ) + + console.log('Waiting', new Date()) // Give the node time to sync. await sleep(15) const members = await getValidatorGroupMembers() diff --git a/packages/celotool/src/e2e-tests/utils.ts b/packages/celotool/src/e2e-tests/utils.ts index ed830beb8e5..05a8a77ac93 100644 --- a/packages/celotool/src/e2e-tests/utils.ts +++ b/packages/celotool/src/e2e-tests/utils.ts @@ -81,6 +81,7 @@ export async function execCmdWithExitOnFailure( ) { const code = await execCmd(cmd, args, options) if (code !== 0) { + console.error(`Failed to execute ${cmd} ${args}`) process.exit(1) } } @@ -377,6 +378,7 @@ export async function initAndStartGeth(gethBinaryPath: string, instance: GethIns const datadir = getDatadir(instance) console.info(`geth:${instance.name}: init datadir ${datadir}`) await init(gethBinaryPath, datadir, GENESIS_PATH) + console.log('Inited geth', new Date()) if (instance.privateKey) { await importPrivateKey(gethBinaryPath, instance) } @@ -434,7 +436,9 @@ export function getContext(gethConfig: GethTestConfig) { } const restart = async () => { + console.log('killing geth', new Date()) await killGeth() + console.log('killed geth', new Date()) let validatorIndex = 0 for (const instance of gethConfig.instances) { await restoreDatadir(instance) From 28db5c619637ff07b9d0657a4a80dc401e570e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2019 16:32:43 +0300 Subject: [PATCH 5/9] fixed lint --- packages/celotool/src/e2e-tests/governance_tests.ts | 8 ++++---- packages/celotool/src/e2e-tests/utils.ts | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 10345caf574..6047d4000b7 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -246,9 +246,9 @@ describe('governance tests', () => { after(context.hooks.after) const restart = async () => { - console.log('restarting', new Date()) + console.debug('restarting', new Date()) await context.hooks.restart() - console.log('restarted', new Date()) + console.debug('restarted', new Date()) web3 = new Web3('http://localhost:8545') lockedGold = new web3.eth.Contract(lockedGoldAbi, await getContractAddress('LockedGoldProxy')) goldToken = new web3.eth.Contract(erc20Abi, await getContractAddress('GoldTokenProxy')) @@ -377,7 +377,7 @@ describe('governance tests', () => { validatorsAbi, await getContractAddress('ValidatorsProxy') ) - console.log('Waiting', new Date()) + console.debug('Waiting', new Date()) // Give the node time to sync. await sleep(15) const members = await getValidatorGroupMembers() @@ -450,7 +450,7 @@ describe('governance tests', () => { await getContractAddress('ValidatorsProxy') ) - console.log('Waiting', new Date()) + console.debug('Waiting', new Date()) // Give the node time to sync. await sleep(15) const members = await getValidatorGroupMembers() diff --git a/packages/celotool/src/e2e-tests/utils.ts b/packages/celotool/src/e2e-tests/utils.ts index 05a8a77ac93..6907701d131 100644 --- a/packages/celotool/src/e2e-tests/utils.ts +++ b/packages/celotool/src/e2e-tests/utils.ts @@ -79,6 +79,10 @@ export async function execCmdWithExitOnFailure( args: string[], options?: SpawnOptions & { silent?: boolean } ) { + // debug, remember to remove + if (options) { + options.silent = false + } const code = await execCmd(cmd, args, options) if (code !== 0) { console.error(`Failed to execute ${cmd} ${args}`) @@ -378,7 +382,7 @@ export async function initAndStartGeth(gethBinaryPath: string, instance: GethIns const datadir = getDatadir(instance) console.info(`geth:${instance.name}: init datadir ${datadir}`) await init(gethBinaryPath, datadir, GENESIS_PATH) - console.log('Inited geth', new Date()) + console.debug('Inited geth', new Date()) if (instance.privateKey) { await importPrivateKey(gethBinaryPath, instance) } @@ -436,9 +440,9 @@ export function getContext(gethConfig: GethTestConfig) { } const restart = async () => { - console.log('killing geth', new Date()) + console.debug('killing geth', new Date()) await killGeth() - console.log('killed geth', new Date()) + console.debug('killed geth', new Date()) let validatorIndex = 0 for (const instance of gethConfig.instances) { await restoreDatadir(instance) From 581ff07217bfeb5af6a0db018287089a6857af02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2019 17:07:05 +0300 Subject: [PATCH 6/9] adding even more debug messages --- .../src/e2e-tests/governance_tests.ts | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 6047d4000b7..82ab891d01d 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -1,5 +1,6 @@ import BigNumber from 'bignumber.js' import { assert } from 'chai' +import fs from 'fs' import Web3 from 'web3' import { strip0x } from '../lib/utils' import { @@ -257,6 +258,7 @@ describe('governance tests', () => { const unlockAccount = async (address: string, theWeb3: any) => { // Assuming empty password + console.debug('unlocking account', new Date()) await theWeb3.eth.personal.unlockAccount(address, '', 1000) } @@ -272,8 +274,11 @@ describe('governance tests', () => { } const getValidatorGroupMembers = async () => { + console.debug('get group members 1', new Date()) const [groupAddress] = await validators.methods.getRegisteredValidatorGroups().call() + console.debug('get group members 2', new Date()) const groupInfo = await validators.methods.getValidatorGroup(groupAddress).call() + console.debug('get group members 3', new Date()) return groupInfo[3] } @@ -379,10 +384,15 @@ describe('governance tests', () => { ) console.debug('Waiting', new Date()) // Give the node time to sync. - await sleep(15) - const members = await getValidatorGroupMembers() - await removeMember(groupWeb3, groupAddress, members[0]) + try { + await sleep(15) + const members = await getValidatorGroupMembers() + await removeMember(groupWeb3, groupAddress, members[0]) + } catch (err) { + console.error('got error', err) + } await sleep(epoch * 2) + console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) }) it('should return the reduced validator set size', async () => { @@ -452,10 +462,15 @@ describe('governance tests', () => { console.debug('Waiting', new Date()) // Give the node time to sync. - await sleep(15) - const members = await getValidatorGroupMembers() - await removeMember(groupWeb3, groupAddress, members[0]) + try { + await sleep(15) + const members = await getValidatorGroupMembers() + await removeMember(groupWeb3, groupAddress, members[0]) + } catch (err) { + console.error('got error', err) + } await sleep(epoch * 2) + console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) validators = new web3.eth.Contract( validatorsAbi, @@ -510,11 +525,18 @@ describe('governance tests', () => { await getContractAddress('ValidatorsProxy') ) // Give the node time to sync. + let membersToSwap: string[] + try { + await sleep(15) + const members = await getValidatorGroupMembers() + membersToSwap = [members[0], members[1]] + // Start with 10 nodes + await removeMember(groupWeb3, groupAddress, membersToSwap[0]) + } catch (err) { + console.error('got error', err) + } await sleep(15) - const members = await getValidatorGroupMembers() - const membersToSwap = [members[0], members[1]] - // Start with 10 nodes - await removeMember(groupWeb3, groupAddress, membersToSwap[0]) + console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) const changeValidatorSet = async (header: any) => { // At the start of epoch N, swap members so the validator set is different for epoch N + 1. From 33e5fe22f45df7a5e380113d1fbeb344a306c90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2019 18:42:55 +0300 Subject: [PATCH 7/9] Revert "added debug messages" This reverts commit 16f950f30ffe343ee9f0c50aeaa1f7eb1a15437b. --- .../src/e2e-tests/governance_tests.ts | 47 ++++--------------- packages/celotool/src/e2e-tests/utils.ts | 8 ---- 2 files changed, 10 insertions(+), 45 deletions(-) diff --git a/packages/celotool/src/e2e-tests/governance_tests.ts b/packages/celotool/src/e2e-tests/governance_tests.ts index 82ab891d01d..cccd2048795 100644 --- a/packages/celotool/src/e2e-tests/governance_tests.ts +++ b/packages/celotool/src/e2e-tests/governance_tests.ts @@ -1,6 +1,5 @@ import BigNumber from 'bignumber.js' import { assert } from 'chai' -import fs from 'fs' import Web3 from 'web3' import { strip0x } from '../lib/utils' import { @@ -247,9 +246,7 @@ describe('governance tests', () => { after(context.hooks.after) const restart = async () => { - console.debug('restarting', new Date()) await context.hooks.restart() - console.debug('restarted', new Date()) web3 = new Web3('http://localhost:8545') lockedGold = new web3.eth.Contract(lockedGoldAbi, await getContractAddress('LockedGoldProxy')) goldToken = new web3.eth.Contract(erc20Abi, await getContractAddress('GoldTokenProxy')) @@ -258,7 +255,6 @@ describe('governance tests', () => { const unlockAccount = async (address: string, theWeb3: any) => { // Assuming empty password - console.debug('unlocking account', new Date()) await theWeb3.eth.personal.unlockAccount(address, '', 1000) } @@ -274,11 +270,8 @@ describe('governance tests', () => { } const getValidatorGroupMembers = async () => { - console.debug('get group members 1', new Date()) const [groupAddress] = await validators.methods.getRegisteredValidatorGroups().call() - console.debug('get group members 2', new Date()) const groupInfo = await validators.methods.getValidatorGroup(groupAddress).call() - console.debug('get group members 3', new Date()) return groupInfo[3] } @@ -382,17 +375,11 @@ describe('governance tests', () => { validatorsAbi, await getContractAddress('ValidatorsProxy') ) - console.debug('Waiting', new Date()) // Give the node time to sync. - try { - await sleep(15) - const members = await getValidatorGroupMembers() - await removeMember(groupWeb3, groupAddress, members[0]) - } catch (err) { - console.error('got error', err) - } + await sleep(15) + const members = await getValidatorGroupMembers() + await removeMember(groupWeb3, groupAddress, members[0]) await sleep(epoch * 2) - console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) }) it('should return the reduced validator set size', async () => { @@ -459,18 +446,11 @@ describe('governance tests', () => { validatorsAbi, await getContractAddress('ValidatorsProxy') ) - - console.debug('Waiting', new Date()) // Give the node time to sync. - try { - await sleep(15) - const members = await getValidatorGroupMembers() - await removeMember(groupWeb3, groupAddress, members[0]) - } catch (err) { - console.error('got error', err) - } + await sleep(15) + const members = await getValidatorGroupMembers() + await removeMember(groupWeb3, groupAddress, members[0]) await sleep(epoch * 2) - console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) validators = new web3.eth.Contract( validatorsAbi, @@ -525,18 +505,11 @@ describe('governance tests', () => { await getContractAddress('ValidatorsProxy') ) // Give the node time to sync. - let membersToSwap: string[] - try { - await sleep(15) - const members = await getValidatorGroupMembers() - membersToSwap = [members[0], members[1]] - // Start with 10 nodes - await removeMember(groupWeb3, groupAddress, membersToSwap[0]) - } catch (err) { - console.error('got error', err) - } await sleep(15) - console.debug(fs.readFileSync('/tmp/e2e/validatorGroup/datadir/logs.txt')) + const members = await getValidatorGroupMembers() + const membersToSwap = [members[0], members[1]] + // Start with 10 nodes + await removeMember(groupWeb3, groupAddress, membersToSwap[0]) const changeValidatorSet = async (header: any) => { // At the start of epoch N, swap members so the validator set is different for epoch N + 1. diff --git a/packages/celotool/src/e2e-tests/utils.ts b/packages/celotool/src/e2e-tests/utils.ts index 6907701d131..ed830beb8e5 100644 --- a/packages/celotool/src/e2e-tests/utils.ts +++ b/packages/celotool/src/e2e-tests/utils.ts @@ -79,13 +79,8 @@ export async function execCmdWithExitOnFailure( args: string[], options?: SpawnOptions & { silent?: boolean } ) { - // debug, remember to remove - if (options) { - options.silent = false - } const code = await execCmd(cmd, args, options) if (code !== 0) { - console.error(`Failed to execute ${cmd} ${args}`) process.exit(1) } } @@ -382,7 +377,6 @@ export async function initAndStartGeth(gethBinaryPath: string, instance: GethIns const datadir = getDatadir(instance) console.info(`geth:${instance.name}: init datadir ${datadir}`) await init(gethBinaryPath, datadir, GENESIS_PATH) - console.debug('Inited geth', new Date()) if (instance.privateKey) { await importPrivateKey(gethBinaryPath, instance) } @@ -440,9 +434,7 @@ export function getContext(gethConfig: GethTestConfig) { } const restart = async () => { - console.debug('killing geth', new Date()) await killGeth() - console.debug('killed geth', new Date()) let validatorIndex = 0 for (const instance of gethConfig.instances) { await restoreDatadir(instance) From ca16b9e2de2ef264093b3939832ed05cfb044205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2019 19:38:17 +0300 Subject: [PATCH 8/9] added patch for websocket --- patches/websocket+1.0.24.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 patches/websocket+1.0.24.patch diff --git a/patches/websocket+1.0.24.patch b/patches/websocket+1.0.24.patch new file mode 100644 index 00000000000..d0ff02090d1 --- /dev/null +++ b/patches/websocket+1.0.24.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/websocket/lib/WebSocketFrame.js b/node_modules/websocket/lib/WebSocketFrame.js +index 859e879..92d0bbb 100644 +--- a/node_modules/websocket/lib/WebSocketFrame.js ++++ b/node_modules/websocket/lib/WebSocketFrame.js +@@ -253,7 +253,7 @@ WebSocketFrame.prototype.toBuffer = function(nullMask) { + } + + if (this.mask) { +- maskKey = nullMask ? 0 : (Math.random()*0xFFFFFFFF) | 0; ++ maskKey = nullMask ? 0 : (Math.random()*0xFFFFFFFF) >>> 0; + this.maskBytes.writeUInt32BE(maskKey, 0, true); + + // write the mask key From 2a6ed66e9c70c2def2c633e2480013109f756044 Mon Sep 17 00:00:00 2001 From: Mariano Cortesi Date: Sat, 5 Oct 2019 22:30:39 -0300 Subject: [PATCH 9/9] Restore CI branch --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bba537c014e..915d91ae163 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -326,7 +326,7 @@ jobs: go version cd packages/celotool mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config - ./ci_test_transfers.sh checkout mc/proposer-fees + ./ci_test_transfers.sh checkout master end-to-end-geth-governance-test: <<: *defaults @@ -367,7 +367,7 @@ jobs: go version cd packages/celotool mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config - ./ci_test_governance.sh checkout mc/proposer-fees + ./ci_test_governance.sh checkout master end-to-end-geth-sync-test: <<: *defaults @@ -407,7 +407,7 @@ jobs: go version cd packages/celotool mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config - ./ci_test_sync.sh checkout mc/proposer-fees + ./ci_test_sync.sh checkout master end-to-end-geth-integration-sync-test: <<: *defaults @@ -440,7 +440,7 @@ jobs: go version cd packages/celotool mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config - ./ci_test_sync_with_network.sh checkout mc/proposer-fees + ./ci_test_sync_with_network.sh checkout master web: working_directory: ~/app