Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Metatransaction broadcaster timeouts #1153

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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