From 589d81e5b033600f4dd56a070b2edf406d91d79c Mon Sep 17 00:00:00 2001 From: kokialgo Date: Thu, 28 Aug 2025 12:49:56 -0300 Subject: [PATCH 1/2] fix: add more logs --- src/bots/kleros-liquid.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/bots/kleros-liquid.js b/src/bots/kleros-liquid.js index 4fe4bc7..36aac03 100644 --- a/src/bots/kleros-liquid.js +++ b/src/bots/kleros-liquid.js @@ -34,12 +34,15 @@ module.exports = async (web3, batchedSend) => { try { let disputeID = process.env.STARTING_DISPUTE_ID || 0; while (true) { + console.debug(`Processing dispute ${disputeID}`); if (!executedDisputeIDs[disputeID]) { let dispute; try { dispute = await klerosLiquid.methods.disputes(disputeID).call(); - } catch (_) { - //console.log(e); + } catch (e) { + console.error( + `Error trying to read dispute ${disputeID}: ${e.message}` + ); break; } const dispute2 = await klerosLiquid.methods @@ -55,6 +58,9 @@ module.exports = async (web3, batchedSend) => { .call(); } catch (_) { // Look it up manually if numberOfChoices is too high for loop + console.debug( + `Looking up vote counter manually for dispute ${disputeID}, choice ${i}` + ); let tied = true; let winningChoice = "0"; const _voteCounters = {}; @@ -95,6 +101,7 @@ module.exports = async (web3, batchedSend) => { return voteCounter; }) ); + console.debug(`Vote counter has ${voteCounters.length} entries`); const notTieAndNoOneCoherent = voteCounters.map( (v) => @@ -102,6 +109,9 @@ module.exports = async (web3, batchedSend) => { v.counts[voteCounters[voteCounters.length - 1].winningChoice] === "0" ); + console.debug( + `No tie and no coherent votes for dispute ${disputeID}: ${notTieAndNoOneCoherent}` + ); if ( !dispute.ruled || dispute2.votesLengths.some( @@ -148,6 +158,8 @@ module.exports = async (web3, batchedSend) => { executedDisputeIDs[disputeID] = true; // The dispute is finalized, cache it. console.log("Dispute %s is finalized, caching it.", disputeID); } + } else { + console.debug(`Dispute ${disputeID} is already executed.`); } disputeID++; } @@ -163,15 +175,18 @@ module.exports = async (web3, batchedSend) => { const disputesWithoutJurors = await klerosLiquid.methods .disputesWithoutJurors() .call(); + console.log(`Checking if reay to move phase`); if (phase == PhaseEnum.staking) { const minStakingTime = await klerosLiquid.methods.minStakingTime().call(); if ( Date.now() - lastPhaseChange * 1000 >= minStakingTime * 1000 && disputesWithoutJurors > 0 ) { + console.debug(`Ready to move from staking to generating`); readyForNextPhase = true; } } else if (phase == PhaseEnum.generating) { + console.debug(`Ready to move from generating to drawing`); readyForNextPhase = true; } else if (phase == PhaseEnum.drawing) { const maxDrawingTime = await klerosLiquid.methods.maxDrawingTime().call(); @@ -179,6 +194,7 @@ module.exports = async (web3, batchedSend) => { Date.now() - lastPhaseChange * 1000 >= maxDrawingTime * 1000 || disputesWithoutJurors == 0 ) { + console.debug(`Ready to move from drawing to staking`); readyForNextPhase = true; } } From 3ee3719c6db6e00ec25bdf458b11e66aee102753 Mon Sep 17 00:00:00 2001 From: kokialgo Date: Thu, 28 Aug 2025 13:30:12 -0300 Subject: [PATCH 2/2] fix: do not log error if disputeID doesn't exist --- src/bots/kleros-liquid.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bots/kleros-liquid.js b/src/bots/kleros-liquid.js index 36aac03..e41b4a3 100644 --- a/src/bots/kleros-liquid.js +++ b/src/bots/kleros-liquid.js @@ -40,9 +40,10 @@ module.exports = async (web3, batchedSend) => { try { dispute = await klerosLiquid.methods.disputes(disputeID).call(); } catch (e) { - console.error( - `Error trying to read dispute ${disputeID}: ${e.message}` - ); + // We are in a disputeID that doesn't exist. + // console.error( + // `Error trying to read dispute ${disputeID}: ${e.message}` + // ); break; } const dispute2 = await klerosLiquid.methods @@ -71,6 +72,11 @@ module.exports = async (web3, batchedSend) => { i, j ); + console.debug( + `Vote for dispute ${disputeID}, choice ${i}, index ${j}: ${JSON.stringify( + vote + )}` + ); if (vote.voted) { // increment vote count _voteCounters[vote.choice] = _voteCounters[vote.choice]