From d9479152da5b957901e7d404f382d21bfdae4cd9 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Wed, 15 May 2024 11:34:54 -0500 Subject: [PATCH] only stake half available REP if an error was encountered when evaluating a VP --- backend/src/event-handlers/validation-pools.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/src/event-handlers/validation-pools.js b/backend/src/event-handlers/validation-pools.js index 2d4ae35..beb8571 100644 --- a/backend/src/event-handlers/validation-pools.js +++ b/backend/src/event-handlers/validation-pools.js @@ -50,17 +50,25 @@ const start = async () => { const decisions = await Promise.mapSeries(deciders, (decider) => decider(pool, post)); const inFavor = decisions.some((x) => x === true); const nullResult = decisions.some((x) => x === null); + const currentRep = await dao.balanceOf(await wallet.getAddress()); + let stakeAmount = currentRep; if (!inFavor && nullResult) { - console.log(`Obtained a NULL RESULT for pool ${poolIndex}. Abstaining from the vote.`); + console.log(`Obtained a NULL RESULT for pool ${poolIndex}.`); // TODO: Retry? // TODO: Notify - return; + // Calculate the minimum stake S against the post, such that if the honest actors + // each stake S, the result will be enough to meet the win ratio. + // This way, we combat the threat of a truly invalid post, + // while reducing our exposure in the case that the error is unique to us. + // Assume 2/3 honest actors. + // S * (2/3) = 1/3 + // S = 1/2; + stakeAmount = Math.ceil(currentRep / 2); } // Stake all available reputation - const currentRep = await dao.balanceOf(await wallet.getAddress()); - console.log(`STAKING ${currentRep} ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`); + console.log(`STAKING ${stakeAmount} ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`); try { - await dao.stakeOnValidationPool(poolIndex, currentRep, inFavor); + await dao.stakeOnValidationPool(poolIndex, stakeAmount, inFavor); } catch (e) { // Maybe the end time passed? console.error(`STAKING failed, reason: ${e.reason}`);