I've been thinking about how I would build a web app demo, so everyone running that app becomes part of a decentralised computation network. Perhaps implementing my old friend the genetic algorithm, but with the work being done by many nodes in parallel.
For now this is a thought experiment, but I'd quite like to code it or get together with others to work on it if it seems feasible.
c-node - an instance of the app running on a client computer. You could run multiple c-nodes by running more than one instance of the app on your computer, so this is not the same as a SAFE node.
It is relatively [ahem] simple if all c-nodes are assumed to be honest, which is fine for a simple demo, but I have enjoyed trying to figure out how to make this immune to dishonest c-nodes and this is what I want to explore in this topic.
Defending From Attacks
A typical attack might be to DDoS c-nodes or their communications, but I think SAFE network makes this all but impossible with no work needed in the app other than to make sensible use of shared data structures and so on. There might be holes in that reasoning but they won't be apparent until we get into more detail and so aren't relevant here.
Another attack would be for a group of c-nodes to collaborate to corner the rewards of such a system - a bit like centralised bitcoin mining.
I have thought of a reasonable solution to this, which would work well providing the number of c-nodes is large. This is unlikely for a demo app, so only worth bothering with if it was a serious app that could attract a lot of participants (not my aim for now - but that could grow out of this).
Could SAFE Provide The Defence?
Having noticed similarities between my solution and how SAFE network makes it difficult for SAFE-nodes to collaborate, I'm wondering if this aspect could be handled by using the low level SAFE API. For example, by ensuring a c-node submitting a problem to be worked on can't somehow favour workers controlled by the same person.
To clarify the question, here's an outline of how a Computation dApp might work.
Computation dApp Example
Every c-dApp instance can submit computation to be worked on. This role is called 'boss'.
Every c-dApp instance can compute the result of a computation and submit it to the 'boss' for a reward. This role is called 'worker'.
One way to keep c-nodes honest is to have them first gain reputation by submitting work, or doing work, and vouching for each other after working together correctly.
For worker reputation this means doing computations which a boss signs as correctly completed. Once a worker has sufficient boss points, it could then pass a threshold where it earns a reward when doing work for a boss, awarded/paid by the boss.
And vice versa, a boss can gain reputation for it's role by satisfied workers signing the job to indicate that the boss correctly acknowledge their work (by signing the results and giving any reward due).
Cheating To Gain Reputation
A dishonest participant could gain reputation by doing no work at all by having a bunch of c-nodes he's running all signing off on each other, and then have an unfair advantage over honest workers who will take longer to gain reputation, and may not gain it at all if other honest bosses prioritise work to workers who have a good reputation.
Once the cheat has reputation enough for his workers to get real rewards, he shifts his workers to doing real work for honest bosses, and has made it harder for any honest workers to compete for those rewards.
There's a lot of details left out of this, so no doubt there are other potential attacks, but they are not of interest here. The above example is just so I can propose a solution to this problem, and ask how or if that could be handed off to SAFE network using the low level API, instead of having to code it into the c-dApp (which is pointless for a demo).
One way to do this is to make it hard for a worker to end up working for a particular boss. SAFE network prevents collaboration by a combination of means. One is by ensuring that SAFE nodes (s-nodes) which collaborate are are chosen at random. On a large network the chances of two s-nodes owned by the same person being selected to work together becomes very low, which makes it very costly to try and cheat.
This is achieved by ensuring that each s-node is given a random address, and that nodes with similar addresses are chosen to collaborate.
So, I'm wondering if there's a way to tag onto SAFE, perhaps using the low level API to create custom messages that would be handled by the c-dApp and which exploit the s-node address to make it unlikely that any two c-nodes would end up working together as boss and worker.
Can this be done done with the existing API, and if so can you give me some hints?!
Also, would this also be possible with the safe-nodejs API and just a browser based web app? Or are we talking about something that would rely on in future additions to the API?
Tricky to answer sorry! I hope I've explained well enough. Gosh this is a long post - thank you for reading