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

Dispute relayer bot and dockerization #1024

Merged
merged 11 commits into from
Aug 3, 2023
11 changes: 6 additions & 5 deletions contracts/scripts/disputeRelayerBot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import env from "./utils/env";
import loggerFactory from "./utils/logger";
import { BigNumber } from "ethers";
import hre = require("hardhat");
import {
KlerosCore,
@@ -63,17 +62,19 @@ export default async function main(
logger.info(
`CrossChainDisputeOutgoing: ${foreignBlockHash} ${foreignArbitrable} ${foreignDisputeID} ${choices} ${extraData}`
);
// logger.info(`tx receipt: ${JSON.stringify(txReceipt)}`);
logger.debug(`tx receipt: ${JSON.stringify(txReceipt)}`);

// txReceipt is missing the full logs for this tx so we need to request it here
const fullTxReceipt = await foreignChainProvider.getTransactionReceipt(txReceipt.transactionHash);

// Retrieve the DisputeRequest event
const disputeRequest = fullTxReceipt.logs
const disputeRequests: DisputeRequestEventObject[] = fullTxReceipt.logs
.filter((log) => log.topics[0] === arbitrableInterface.getEventTopic("DisputeRequest"))
.map((log) => arbitrableInterface.parseLog(log).args as unknown as DisputeRequestEventObject)[0];
.map((log) => arbitrableInterface.parseLog(log).args as unknown as DisputeRequestEventObject);
logger.warn(`More than 1 DisputeRequest event: not supported yet, skipping the others events.`);

const disputeRequest = disputeRequests[0];
logger.info(`tx events DisputeRequest: ${JSON.stringify(disputeRequest)}`);
// TODO: log a warning if there are multiple DisputeRequest events

const relayCreateDisputeParams = {
foreignBlockHash: foreignBlockHash,
4 changes: 2 additions & 2 deletions contracts/scripts/keeperBot.ts
Original file line number Diff line number Diff line change
@@ -581,9 +581,9 @@ async function main() {
});
// Remove duplicates which may have a different contribution amount for the same round, choice and beneficiary
contributions = [...new Set(contributions)];
for (var contribution of contributions) {
for (let contribution of contributions) {
// Could be improved by pinpointing exactly which round requires a withdrawal, just try all of them for now.
for (var round = BigNumber.from(dispute.currentRoundIndex); round.gte(0); round = round.sub(1)) {
for (let round = BigNumber.from(dispute.currentRoundIndex); round.gte(0); round = round.sub(1)) {
await withdrawAppealContribution(dispute.id, round.toString(), contribution);
await delay(ITERATIONS_COOLDOWN_PERIOD); // To avoid spiking the gas price
}
2 changes: 1 addition & 1 deletion services/bots/Dockerfile
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ FROM node:16-alpine

WORKDIR /usr/src/app

RUN npm install -g pm2
RUN npm install --ignore-scripts -g pm2

COPY --chown=node:node "./contracts" "./contracts"
COPY --chown=node:node "./eslint-config" "./eslint-config"