Continuing on from a couple of recent threads, I was musing about distributed computing and smart contracts and how they could work on Safe Network.
At first, I felt like there was a hurdle of these apps not being able to run within the network, rather than by users outside of the network. Now I’m not so sure.
When an app can be ran by a user outside of the network, we have certain advantages. Key management becomes easier, as the user has their own private keys for writing data. The user can also run the app anywhere, whether on their mobile, their laptop, in the cloud, etc. Any device which is capable of executing the code, which has connectivity, is capable.
The down side is that the network can’t guarantee that the apps are run. Users may or may not run them. However, they can be given incentives to run them, such as rewards on completion. Given the users may be anonymous (but may still have reputation built up), fear of running a controversial app should also be minimised.
So, given an ‘object’ in programming terms is data + code, we could define such an object in message format. It could contain a link to the code and links to data sources (both XOR-URLs to immutable data). E.g. something like this:
object safe://abc:
{
"app": "safe://def",
"input": [
"safe://ghi"
],
"output": "safe://xyz"
}
The object at safe://abc would define an application at safe://def that would take input from safe://ghi then output to safe://xyz when it fulfils a criteria defined in the app. The entire ‘object’ message would be immutable, as would each XOR-URL defined within.
Obviously, this is just a crude outline at this stage, but these could be picked up and executed by anyone with permission to read and/or write to the dependencies. The apps could also point to other objects, allowing a nest of objects to be executed, each with their own dependencies. Perhaps these dependencies could be provided by the parent too. Running them in a sandbox (WASM, perhaps?)
If this sort of approach could be wrapped by a mechanism/process to ‘offer’ these objects to users to execute, then validate and reward based on them, we start to form a distributed compute. The apps could be doing simple smart contract related tasks or CPU intensive compute.
Just early thoughts about this, but I wanted to dump my thoughts here. Maybe others have thought about this more?