Skip to content

Commit

Permalink
Merge pull request #1153 from JoinColony/maint/metatx-timeout
Browse files Browse the repository at this point in the history
Fix Metatransaction broadcaster timeouts
  • Loading branch information
area authored Aug 10, 2023
2 parents f9d09ed + e1d68bb commit a5c2d9b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
19 changes: 15 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/metatransaction-broadcaster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 25 additions & 13 deletions packages/metatransaction-broadcaster/MetatransactionBroadcaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit a5c2d9b

Please sign in to comment.