With a little help from my friends…

Jade Meskill
computes
Published in
2 min readJun 21, 2018

Consensus building in Computes.

Sometimes you want to make sure your tasks create a consistent result before trusting the outcome. We’ve added a simple consensus mechanism in Computes. When used, you can set a threshold of how many matches are required. Let’s look at an example task with a consensus threshold of 2. This means 2 tasks would have to agree on the results before they become visible in your dataset.

Consensus Task 1

{
"input": {
"dataset": 2
},
"taskDefinition": {
"runner": {
"type": "docker-json-runner",
"manifest": {
"*": {
"image": "computes/fibonacci-sum-split:latest"
}
}
},
"result": {
"action": "set",
"destination": {
"dataset": { "/": "zdpuAyMuiJxSwrpuDuwdXckFpjDNrzURXxtsayfFhxuiJ9ZEt" },
"path": "split/results"
},
"consensus": {
"threshold": 2
}
}
},
"status": {
"/": "zdpuAwmC7rqGDaLm8rPhFgNbBoSqUXMGgi478TLuDTGohhP3q"
},
"id": 1
}

If I run this task and check for the results, they will not be visible, even though they are stored internally in the Computes network.

$ computes-cli dataset dumplatest \
zdpuAo2koQJUuh4ixPiJ9jfUicCWPTEL2Rhg7r3WUYuGsbEt2
{
"__meta__": {
"computes": {
"seed": "d5f0f8c7-46c0-434e-a676-5699d7287da9",
"tasks": {
"related": [
"zdpuAtRc9P6piSvmJbxfxrSA24P6ATbsXzCFTFzPF3DmkwjVT"
]
}
}
},
"split": {}
}

Consensus Task 2

{
"input": {
"dataset": 2
},
"taskDefinition": {
"runner": {
"type": "docker-json-runner",
"manifest": {
"*": {
"image": "computes/fibonacci-sum-split:latest"
}
}
},
"result": {
"action": "set",
"destination": {
"dataset": { "/": "zdpuAyMuiJxSwrpuDuwdXckFpjDNrzURXxtsayfFhxuiJ9ZEt" },
"path": "split/results"
},
"consensus": {
"threshold": 2
}
}
},
"status": {
"/": "zdpuAwmC7rqGDaLm8rPhFgNbBoSqUXMGgi478TLuDTGohhP3q"
},
"id": 2
}

If we look at task #2, there is only one small difference, which is the id property. This isn’t an official property of Computes, but allows the task to be different enough to generate a new task hash. Computes requires each attempt at consensus to be a different task, running the same task over and over again will not create consensus.

After running task #2, let’s see what the results show now.

$ computes-cli dataset dumplatest \
zdpuAo2koQJUuh4ixPiJ9jfUicCWPTEL2Rhg7r3WUYuGsbEt2
{
"__meta__": {
"computes": {
"seed": "d5f0f8c7-46c0-434e-a676-5699d7287da9",
"tasks": {
"related": [
"zdpuAtRc9P6piSvmJbxfxrSA24P6ATbsXzCFTFzPF3DmkwjVT",
"zdpuB15gD5xC8gf6NVEWCnYXosWSagzhYqWYCMT4NUQh1mQDM"
]
}
}
},
"split": {
"results": [
1,
2
]
}
}

What’s next?

We’d like to give nodes the ability to sign and verify results, offering some level of trust across the Computes network in a potentially trustless environment.

--

--

Jade Meskill
computes

Boring Human. Making Music. Creating Code. Making a mess of things… Magic Leaper, Co-founder of Gangplank