Compare commits

..

No commits in common. "f64eba070c1313123abeffd072d0ce57f2a36c9e" and "72e16651fba196dd8b40f581e3499c3ddd216056" have entirely different histories.

4 changed files with 10 additions and 19 deletions

View File

@ -50,25 +50,17 @@ 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}.`);
console.log(`Obtained a NULL RESULT for pool ${poolIndex}. Abstaining from the vote.`);
// TODO: Retry?
// TODO: Notify
// 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);
return;
}
// Stake all available reputation
console.log(`STAKING ${stakeAmount} ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`);
const currentRep = await dao.balanceOf(await wallet.getAddress());
console.log(`STAKING ${currentRep} ${inFavor ? 'in favor of' : 'against'} pool ${poolIndex}`);
try {
await dao.stakeOnValidationPool(poolIndex, stakeAmount, inFavor);
await dao.stakeOnValidationPool(poolIndex, currentRep, inFavor);
} catch (e) {
// Maybe the end time passed?
console.error(`STAKING failed, reason: ${e.reason}`);

View File

@ -121,7 +121,6 @@ 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"
@ -132,8 +131,7 @@ contract Rollup is Availability {
block.timestamp - lastWorkerReset >= minResetInterval,
"Mininum reset interval has not elapsed since last batch worker reset"
);
// 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
// TODO: Should the current batch worker's availability stakes be forfeit?
// Select a new batch worker
batchWorkerStakeIndex = assignWork();
batchWorker = stakes[batchWorkerStakeIndex].worker;

View File

@ -97,6 +97,7 @@ 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(
@ -123,7 +124,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), pool.props.fee);
dao.mint(address(dao), msg.value);
pool.props.minted = msg.value;
dao.emitValidationPoolInitiated(poolIndex);
}

View File

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