Compare commits

..

2 Commits

Author SHA1 Message Date
Ladd Hoffman f64eba070c allow VP with no fee
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 33s Details
2024-05-15 11:35:26 -05:00
Ladd Hoffman d9479152da only stake half available REP if an error was encountered when evaluating a VP 2024-05-15 11:34:54 -05:00
4 changed files with 19 additions and 10 deletions

View File

@ -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}`);

View File

@ -121,6 +121,7 @@ contract Rollup is Availability {
/// If the batch worker fails to submit the batch, a new batch worker may be selected
function resetBatchWorker() public {
// TODO: Grace period after the current batch is due and before the worker can be replaced
require(
block.timestamp - batchStart > batchInterval,
"Current batch interval has not yet elapsed"
@ -131,7 +132,8 @@ contract Rollup is Availability {
block.timestamp - lastWorkerReset >= minResetInterval,
"Mininum reset interval has not elapsed since last batch worker reset"
);
// TODO: Should the current batch worker's availability stakes be forfeit?
// TODO: Submit a validation pool targeting a null post, and send the worker's availability stake
// This gives the DAO an opportunity to police the failed work
// Select a new batch worker
batchWorkerStakeIndex = assignWork();
batchWorker = stakes[batchWorkerStakeIndex].worker;

View File

@ -97,7 +97,6 @@ contract Bench {
msg.sender == address(dao),
"Only DAO contract may call initiateValidationPool"
);
require(msg.value > 0, "Fee is required to initiate validation pool");
require(duration >= minDuration, "Duration is too short");
require(duration <= maxDuration, "Duration is too long");
require(
@ -124,7 +123,7 @@ contract Bench {
// We use our privilege as the DAO contract to mint reputation in proportion with the fee.
// Here we assume a minting ratio of 1
// TODO: Make minting ratio an adjustable parameter
dao.mint(address(dao), msg.value);
dao.mint(address(dao), pool.props.fee);
pool.props.minted = msg.value;
dao.emitValidationPoolInitiated(poolIndex);
}

View File

@ -52,9 +52,9 @@ describe('Validation Pools', () => {
});
describe('Initiate', () => {
it('should not be able to initiate a validation pool without a fee', async () => {
it('should be able to initiate a validation pool without a fee', async () => {
const init = () => initiateValidationPool({ fee: 0 });
await expect(init()).to.be.revertedWith('Fee is required to initiate validation pool');
await expect(init()).to.emit(dao, 'ValidationPoolInitiated');
});
it('should not be able to initiate a validation pool with a quorum below the minimum', async () => {