diff --git a/.circleci/config.yml b/.circleci/config.yml index ad83126e9a..7ae00833e3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,7 +68,18 @@ jobs: sudo apt-get install lsof - run: name: "Running reputation system unit tests" - command: npm run test:reputation + command: npm run test:reputation:1 + environment: + NODE_OPTIONS: --max-old-space-size=6144 + - run: + name: "Reset chains" + command: | + sudo apt-get update + sudo apt-get install lsof + npm run stop:blockchain:client && rm -rf ganache-chain-db* + - run: + name: "Running reputation system unit tests" + command: npm run test:reputation:2 environment: NODE_OPTIONS: --max-old-space-size=6144 - run: @@ -85,7 +96,7 @@ jobs: - <<: *step_setup_global_packages - run: name: "Download parity" - command: wget https://releases.parity.io/ethereum/v2.3.8/x86_64-unknown-linux-gnu/parity + command: wget https://releases.parity.io/ethereum/v2.7.2/x86_64-unknown-linux-gnu/parity - run: name: "Setup parity" command: | @@ -308,7 +319,7 @@ jobs: command: | sudo apt-get update sudo apt-get install lsof - npm run stop:blockchain:client + npm run stop:blockchain:client && rm -rf ganache-chain-db* - run: name: "Running coverage tests for foreign-side of bridge" command: npm run test:contracts:bridging:2:coverage @@ -326,7 +337,7 @@ jobs: - <<: *step_restore_cache - run: name: "Install packages" - command: | + command: | sudo npm install -g npm@8.5.5 npm ci - attach_workspace: diff --git a/package.json b/package.json index 050e4adf09..c67957cd0e 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,8 @@ "fork:goerli": "ganache --fork https://goerli.infura.io/v3/e21146aa267845a2b7b4da025178196d --port 8605", "fork:mainnet": "ganache --fork https://mainnet.infura.io/v3/e21146aa267845a2b7b4da025178196d --port 8601", "flatten:contracts": "mkdir -p ./build/flattened/ && steamroller contracts/colonyNetwork/IColonyNetwork.sol > build/flattened/flatIColonyNetwork.sol && steamroller contracts/colony/IColony.sol > build/flattened/flatIColony.sol && steamroller contracts/reputationMiningCycle/IReputationMiningCycle.sol > build/flattened/flatIReputationMiningCycle.sol && steamroller contracts/colony/IMetaColony.sol > build/flattened/flatIMetaColony.sol && steamroller contracts/common/IRecovery.sol > build/flattened/flatIRecovery.sol && steamroller contracts/common/IEtherRouter.sol > build/flattened/flatIEtherRouter.sol", - "test:reputation": "npm run start:blockchain:client & truffle migrate --reset --compile-all && nyc truffle test ./test/reputation-system/* ./test/reputation-system/reputation-mining-client/* --network development", + "test:reputation:1": "npm run start:blockchain:client & truffle migrate --reset --compile-all && nyc truffle test ./test/reputation-system/* --network development", + "test:reputation:2": "npm run start:blockchain:client & truffle migrate --reset --compile-all && nyc truffle test ./test/reputation-system/reputation-mining-client/* --network development", "test:reputation:coverage": "SOLIDITY_COVERAGE=1 truffle run coverage --solcoverjs ./.solcover.reputation.js --network coverage --temp build-coverage --file='./test/reputation-system/**/*'", "test:contracts": "npm run start:blockchain:client & truffle migrate --reset --compile-all && truffle test ./test/contracts-network/* ./test/packages/* --network development", "test:contracts:bridging:1": "npm run start:blockchain:client & npm run start:blockchain:client:2 & truffle migrate --reset --compile-all && TRUFFLE_FOREIGN=false truffle test ./test/cross-chain/* --network development", diff --git a/packages/metatransaction-broadcaster/Dockerfile b/packages/metatransaction-broadcaster/Dockerfile index b71a813c2b..2ec973f8cf 100644 --- a/packages/metatransaction-broadcaster/Dockerfile +++ b/packages/metatransaction-broadcaster/Dockerfile @@ -3,7 +3,7 @@ COPY ./packages ./packages COPY ./package.json ./ COPY ./package-lock.json ./ COPY ./build ./build -RUN yarn +RUN npm i RUN cd ./packages/metatransaction-broadcaster/ && npm i RUN cd ./packages/package-utils/ && npm i EXPOSE 3000 diff --git a/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js b/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js index d2869939ba..8460cb1d78 100644 --- a/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js +++ b/packages/metatransaction-broadcaster/MetatransactionBroadcaster.js @@ -295,20 +295,32 @@ class MetatransactionBroadcaster { } async isValidSetAuthorityTransaction(tx, userAddress) { + let logs = []; // Get the most recent metatx this user sent on colonyNetwork - let logs = await this.provider.getLogs({ - address: this.colonyNetwork.address, - topics: [ethers.utils.id("MetaTransactionExecuted(address,address,bytes)")], - fromBlock: 0, - }); - const data = logs - .map((l) => { - return { - log: l, - event: this.colonyNetwork.interface.parseLog(l), - }; - }) - .filter((x) => ethers.utils.getAddress(x.event.args.userAddress) === ethers.utils.getAddress(userAddress)); + const stepSize = 10000; + let toBlock = await this.provider.getBlockNumber(); + let fromBlock = toBlock - stepSize; + let data = []; + while (data.length === 0) { + logs = await this.provider.getLogs({ + address: this.colonyNetwork.address, + topics: [ethers.utils.id("MetaTransactionExecuted(address,address,bytes)")], + fromBlock, + toBlock, + }); + + data = logs + .map((l) => { + return { + log: l, + event: this.colonyNetwork.interface.parseLog(l), + }; + }) + .filter((x) => ethers.utils.getAddress(x.event.args.userAddress) === ethers.utils.getAddress(userAddress)); + + fromBlock -= stepSize; + toBlock -= stepSize; + } // Get the TokenAuthorityDeployed event const receipt = await this.provider.getTransactionReceipt(data[data.length - 1].log.transactionHash); logs = receipt.logs.map((l) => this.colonyNetwork.interface.parseLog(l)).filter((e) => e.name === "TokenAuthorityDeployed");