Settings {
chainTicker: 'eth'
tokenAddress: '0x...'
// don't store votes for a sub unless it has at least 1 vote with 1bil tokens or more, prevents people spamming votes for subs that dont exist
minBalanceToProposeVote: 1bil
// only store the last 100 votes per address, prevents people spamming votes for subs that dont exist
maxVotesPerAddress: 100
// we can't fetch some address' balance at block 100 and another at block 101, we must use the same block for everyone
// 25min at 15 secs per block on eth
blocksPerBucket: 100
}
(put all the settings in the pubsub topic so the network can validate without any intermediaries)
pubsubTopic = /default-subplebbits/<settings.chainTicker>/<settings.tokenAddress>/<settings.minBalanceToProposeVote>/<settings.maxVotesPerAddress>/<settings.blocksPerBucket>
steps to get votes:
join pubsub <pubsubTopic>
fetch key /last-votes/<pubsubTopic> using libp2p fetch protocol
and/or listen on pubsub for new values
the value received is Votes[] (1 Votes[] per author)
Votes {
author: Author
signature: Signature
votes: Vote[] // length must be smaller than maxVotesPerAddress
blockNumber: number
}
Vote {
subplebbitAddress: string
vote: 1 | -1
}
fetch Votes.author.wallets[chainTicker].address balance at current block number bucket (Math.floor(currentBlockNumber / settings.blocksPerBucket)) and add all balances
potential problems:
Votes.votes isn't deterministic so attacker can spam permutations of valid Vote[]. Can be mitigated by only storing 1 Votes[] per wallet.address, the Votes with the highest Votes.blockNumber.
One problem with this is there's no way to revoke a wallet.signature, so if your plebbit address gets hacked, you need to move your pleb token to another eth address or the hacker will always be able to vote with your pleb (not steal them, just vote with them). Can be somewhat mitigated by storing the author.wallet.timestamp and not accepting lower timestamps.
steps to publish votes
the user sees a feed of subplebbits, he can vote +1 or -1 on them
or the user adds a new subplebbit that isn't listed via some +add [__] input
every blocksPerBucket, the user republishes his Votes as
Votes {
author: Author
signature: Signature
votes: Vote[] // length must be smaller than maxVotesPerAddress
blockNumber: number
}
Vote {
subplebbitAddress: string
vote: 1 | -1
}
notes:
when receiving a fetch protocol /last-votes/... dont send all the known Votes, only send the highest balance and/or the votes similar to your own, not sure what the max should be, maybe 100kb or something. possibly we could send only the closest k peers of the eth address (like DHT does), or just send random ones.
in the UI, if the user is voting for more subs than settings.maxVotesPerAddress warn him that he must stop voting for some subs to vote for new ones
(put all the settings in the pubsub topic so the network can validate without any intermediaries) pubsubTopic =
/default-subplebbits/<settings.chainTicker>/<settings.tokenAddress>/<settings.minBalanceToProposeVote>/<settings.maxVotesPerAddress>/<settings.blocksPerBucket>
steps to get votes:
join pubsub
<pubsubTopic>
/last-votes/<pubsubTopic>
using libp2p fetch protocolthe value received is
Votes[]
(1 Votes[] per author)how to verify:
Votes.signature
matchesVotes.author.address
Votes.author.wallets[chainTicker].signature
matchesVotes.author.address
Votes.author.wallets[chainTicker].address
balance at current block number bucket (Math.floor(currentBlockNumber / settings.blocksPerBucket)
) and add all balancespotential problems:
Votes.votes
isn't deterministic so attacker can spam permutations of validVote[]
. Can be mitigated by only storing 1Votes[]
perwallet.address
, theVotes
with the highestVotes.blockNumber
.wallet.signature
, so if your plebbit address gets hacked, you need to move your pleb token to another eth address or the hacker will always be able to vote with your pleb (not steal them, just vote with them). Can be somewhat mitigated by storing theauthor.wallet.timestamp
and not accepting lower timestamps.steps to publish votes
the user sees a feed of subplebbits, he can vote +1 or -1 on them
or the user adds a new subplebbit that isn't listed via some +add [__] input
every
blocksPerBucket
, the user republishes hisVotes
asnotes:
when receiving a fetch protocol
/last-votes/...
dont send all the known Votes, only send the highest balance and/or the votes similar to your own, not sure what the max should be, maybe 100kb or something. possibly we could send only the closest k peers of the eth address (like DHT does), or just send random ones.in the UI, if the user is voting for more subs than
settings.maxVotesPerAddress
warn him that he must stop voting for some subs to vote for new ones