Byzantine Data Types - Final
Byzantine Data Types - Final
Santiago Bazerque
Application programming, computing & trust
Creating a replicable data structure and designing a BFT sync protocol per app is… challenging 😱
An open source, non-for-profit framework for working with Byzantine Data Types
Application
(Type definitions, UI, etc.)
set-up Mesh Network
read, write
message.save()
mutate(op: MutationOp) { // <- actual mutation, called from “add” and from sync
if (op instanceof AddOp) {
this._contents.add(op.elem);
} else if (op instanceof DeleteOp) {
Mutability
Objects that support mutations are operational. Each time they change, they create a new
operation object, that’s appended to the DAG. These objects are partially ordered using a special
field, prevOps.
AddOp
let s = new MutableSet(); orange
store.save(s);
AddOp
apple
s.add(‘apple’);
s.add(‘orange’);
MutableSet
store.save(s); Seed: a53af…
Op Commutativity (1)
If a second peer is modifying the set, history becomes non-linear. Notice how the DeleteOp
references the AddOps it’s removing, not the elements. This guarantees commutativity.
AddOp sync
grapes
let s = new MutableSet();
store.save(s); {}
AddOp DeleteOp
s.add(‘apple’); {‘apple’} orange
s.add(‘orange’); {‘apple’, ‘orange’}
store.save(s);
// sync runs {‘apple’, ‘bananas’} AddOp AddOp
apple bananas
s.add(‘grapes’);
store.save(s); {‘apple’, ‘bananas’,
’grapes’}
MutableSet
Seed: a53af…
Op Commutativity (2)
class ChatGroup
extends HashedObject {
owner : Identity; Alice, a moderator, Alice deletes a message
is removed from the from Bob, using her
moderators : MutableSet<Identity>;
members : MutableSet<Identity>; moderators set moderator rights.
messages : MutableSet<Message>;
…
Race condition 😭
Causal Composition (2)
We need to make inter-object causal dependencies explicit. HHS has a family of causal collections for that:
CausalSet, CausalArray, CausalReference, etc.
These causal collections have an extra operation, that attests something about the current state:
add(elem: T) { …
delete(elem: T) { …
Attestation ops exist in the history DAG of the set. When a DeleteOp is added, the system will automatically
invalidate any attestations that are not its predecessors according to the prevOps partial order using an
special Undo Op.
Causal Composition (3)
Now using moderator rights requires an attestation. The attestation creates an explicit causal link
between the operation deleting the message, and the one that added Alice to the moderator set:
moderators : CausalSet<Identity>;
messages : CausalSet<Message>;
AttestOp DeleteOp
AddOp AddOp
alice m by Bob
Moderators Messages
Seed: 43c3f… Seed: ad113…
Causal Composition: Race & cascaded undos
Here Alice’s deletion from the moderator set and the attestation used to exert her moderation
rights are concurrent. The system detects an untimely causal dependency, and generates a
cascade of undos to resolve it.
sync UndoOp UndoOp
partial ordering
op target
DeleteOp AttestOp DeleteOp
AddOp AddOp
alice m by Bob
Moderators Messages
Seed: 43c3f… Seed: ad113…
Causal Composition Summary
In these cases, individual types can incorporate forking and a fork choice rule.
class NonNegativeCounter
extends ForkableObject<CounterChangeOp, CounterSettlementOp> {
Take aways
- Local state + byzantine data sync seems feasible for some applications.
(we could replace most if not all of slack, for example, vis-a-vis)
https://www.hyperhyperspace.org/
https://github.com/hyperhyperspace/hyperhyperspace-core
https://www.hyperhyperspace.org/whitepaper/