Rename `member` to `expert`

This commit is contained in:
Ladd Hoffman 2023-01-03 12:00:12 -06:00
parent f93aaf7373
commit f944d19728
7 changed files with 65 additions and 28 deletions

View File

@ -23,3 +23,31 @@ We're currently supporting anonymous voting.
With anonymous voting, we need to wait until the end of the vote duration, With anonymous voting, we need to wait until the end of the vote duration,
and then have a separate interval in which voters reveal their identities. and then have a separate interval in which voters reveal their identities.
For now, we can let anonymous voters reveal their identities at any time For now, we can let anonymous voters reveal their identities at any time
---
Bench.totalReputation is a very important quantity, isn't it? Basically determines inflation for reputation.
---
Should availability registration encumber reputation?
---
- Is a particular availability stake amount required?
Currently I support updating the staked amount.
Seems like a soft protocol thing.
A given DAO can have a formula for deciding appropriate amounts.
---
#
Implementing forum
Does the following make sense?
We will link the forum to the bench
An author of a forum post /_ ? is always? can be? _/ a reputation holder.
This is what we call a member. Let's update that terminology to be `reputationHolder`.
That's too long, though. Let's rename it to `expert`.

View File

@ -4,7 +4,7 @@ import { Action } from './action.js';
import { PostMessage } from './message.js'; import { PostMessage } from './message.js';
import { CryptoUtil } from './crypto.js'; import { CryptoUtil } from './crypto.js';
export class Member extends Actor { export class Expert extends Actor {
constructor(name, scene) { constructor(name, scene) {
super(name, scene); super(name, scene);
this.actions = { this.actions = {
@ -32,7 +32,6 @@ export class Member extends Actor {
async submitPostViaNetwork(forumNode, post, stake) { async submitPostViaNetwork(forumNode, post, stake) {
// TODO: Include fee // TODO: Include fee
const postMessage = new PostMessage({ post, stake }); const postMessage = new PostMessage({ post, stake });
console.log('submitPostViaNetwork', postMessage);
await postMessage.sign(this.reputationKey); await postMessage.sign(this.reputationKey);
this.actions.submitPostViaNetwork.log(this, forumNode, null, { id: post.id }); this.actions.submitPostViaNetwork.log(this, forumNode, null, { id: post.id });
// For now, directly call forumNode.receiveMessage(); // For now, directly call forumNode.receiveMessage();

View File

@ -72,7 +72,6 @@ export class ValidationPool extends Actor {
}; };
// tokens minted "for" the post go toward stake of author voting for their own post // tokens minted "for" the post go toward stake of author voting for their own post
// also, author can provide additional stakes, e.g. availability stakes for work evidence post // also, author can provide additional stakes, e.g. availability stakes for work evidence post
console.log('initiateValidationPool casting vote', { signingPublicKey });
this.castVote(signingPublicKey, { this.castVote(signingPublicKey, {
position: true, position: true,
stake: this.tokens.for + authorStake, stake: this.tokens.for + authorStake,
@ -83,9 +82,6 @@ export class ValidationPool extends Actor {
async castVote(signingPublicKey, { async castVote(signingPublicKey, {
position, stake, lockingTime = 0, anonymous = true, position, stake, lockingTime = 0, anonymous = true,
}) { }) {
console.log('castVote', {
signingPublicKey, position, stake, anonymous,
});
const vote = new Vote(position, stake, lockingTime); const vote = new Vote(position, stake, lockingTime);
if (this.state === ValidationPoolStates.CLOSED) { if (this.state === ValidationPoolStates.CLOSED) {
throw new Error(`Validation pool ${this.id} is closed`); throw new Error(`Validation pool ${this.id} is closed`);

View File

@ -9,7 +9,7 @@
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/classes/scene.js";
import { Member } from "/classes/member.js"; import { Expert } from "/classes/expert.js";
import { Bench } from "/classes/bench.js"; import { Bench } from "/classes/bench.js";
import { Business } from "/classes/business.js"; import { Business } from "/classes/business.js";
import { Availability } from "/classes/availability.js"; import { Availability } from "/classes/availability.js";
@ -27,17 +27,17 @@
)); ));
const members = (window.members = []); const members = (window.members = []);
const newMember = async () => { const newExpert = async () => {
const index = members.length; const index = members.length;
const name = `Member${index + 1}`; const name = `Expert${index + 1}`;
const member = await new Member(name, scene).initialize(); const member = await new Expert(name, scene).initialize();
members.push(member); members.push(member);
return member; return member;
}; };
const member1 = await newMember(); const member1 = await newExpert();
const member2 = await newMember(); const member2 = await newExpert();
await newMember(); await newExpert();
const bench = (window.bench = new Bench("Bench", scene)); const bench = (window.bench = new Bench("Bench", scene));
const forum = (window.forum = new Forum(bench, "Forum", scene)); const forum = (window.forum = new Forum(bench, "Forum", scene));
const availability = (window.bench = new Availability( const availability = (window.bench = new Availability(

View File

@ -10,7 +10,7 @@
import { Box } from "/classes/box.js"; import { Box } from "/classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/classes/scene.js";
import { PostContent } from "/classes/post.js"; import { PostContent } from "/classes/post.js";
import { Member } from "/classes/member.js"; import { Expert } from "/classes/expert.js";
import { ForumNode } from "/classes/forum-node.js"; import { ForumNode } from "/classes/forum-node.js";
import { ForumNetwork } from "/classes/forum-network.js"; import { ForumNetwork } from "/classes/forum-network.js";
import { CryptoUtil } from "/classes/crypto.js"; import { CryptoUtil } from "/classes/crypto.js";
@ -23,8 +23,8 @@
"sequenceDiagram" "sequenceDiagram"
); );
window.author1 = await new Member("author1", window.scene).initialize(); window.author1 = await new Expert("author1", window.scene).initialize();
window.author2 = await new Member("author2", window.scene).initialize(); window.author2 = await new Expert("author2", window.scene).initialize();
window.forumNetwork = new ForumNetwork(); window.forumNetwork = new ForumNetwork();

View File

@ -9,7 +9,7 @@
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/classes/scene.js";
import { Member } from "/classes/member.js"; import { Expert } from "/classes/expert.js";
import { Bench } from "/classes/bench.js"; import { Bench } from "/classes/bench.js";
import { Business } from "/classes/business.js"; import { Business } from "/classes/business.js";
import { Availability } from "/classes/availability.js"; import { Availability } from "/classes/availability.js";
@ -28,10 +28,10 @@
)); ));
const members = (window.members = []); const members = (window.members = []);
const newMember = async () => { const newExpert = async () => {
const index = members.length; const index = members.length;
const name = `Member${index + 1}`; const name = `Expert${index + 1}`;
const member = await new Member(name, scene).initialize(); const member = await new Expert(name, scene).initialize();
members.push(member); members.push(member);
return member; return member;
}; };
@ -43,9 +43,9 @@
return postId; return postId;
}; };
const member1 = await newMember(); const member1 = await newExpert();
const member2 = await newMember(); const member2 = await newExpert();
await newMember(); await newExpert();
const bench = (window.bench = new Bench("Bench", scene)); const bench = (window.bench = new Bench("Bench", scene));
const forum = (window.forum = new Forum(bench, "Forum", scene)); const forum = (window.forum = new Forum(bench, "Forum", scene));

View File

@ -9,7 +9,7 @@
<script type="module"> <script type="module">
import { Box } from "/classes/box.js"; import { Box } from "/classes/box.js";
import { Scene } from "/classes/scene.js"; import { Scene } from "/classes/scene.js";
import { Member } from "/classes/member.js"; import { Expert } from "/classes/expert.js";
import { Bench } from "/classes/bench.js"; import { Bench } from "/classes/bench.js";
import { delay } from "/util.js"; import { delay } from "/util.js";
@ -19,12 +19,12 @@
const scene = (window.scene = new Scene("Validation Pool test", rootBox).log( const scene = (window.scene = new Scene("Validation Pool test", rootBox).log(
"sequenceDiagram" "sequenceDiagram"
)); ));
const member1 = (window.member1 = await new Member( const member1 = (window.member1 = await new Expert(
"Member1", "Expert1",
scene scene
).initialize()); ).initialize());
const member2 = (window.member2 = await new Member( const member2 = (window.member2 = await new Expert(
"Member2", "Expert2",
scene scene
).initialize()); ).initialize());
const bench = (window.bench = new Bench("Bench", scene)); const bench = (window.bench = new Bench("Bench", scene));
@ -58,6 +58,20 @@
tokenLossRatio: 1, tokenLossRatio: 1,
}); });
await member1.revealIdentity(pool); await member1.revealIdentity(pool);
// Attempting to evaluate winning conditions before the duration has expired
// should result in an exception
try {
await pool.evaluateWinningConditions();
} catch (e) {
if (e.message.match(/Validation pool duration has not yet elapsed/)) {
console.log(
"Caught expected error: Validation pool duration has not yet elapsed"
);
} else {
console.error("Unexpected error");
throw e;
}
}
await delay(1000); await delay(1000);
await pool.evaluateWinningConditions(); // Vote passes await pool.evaluateWinningConditions(); // Vote passes
await updateDisplayValues(); await updateDisplayValues();