1 of 105

Blockchain Scaling

...in the CBC Casper Framework

A talk by Vlad Zamfir

EthCC 2019

2 of 105

Outline

  • Primer
    • Consensus protocols
    • Sharding
  • Sharded Consensus Protocols, in Theory
    • Decisions in sharded consensus protocols
    • Sharding clients as light clients
  • Sharded (Blockchain) Consensus Values
    • Block structure
  • Sharded CBC Casper (Blockchain) Consensus Client
    • Abstract CBC Casper Light Client spec
    • Sharded Blockchain Client spec
  • Sharded (Blockchain) Fork Choice Rule
  • Relevant work, Future Directions, Conclusion, Q&A

3 of 105

Primer: Consensus Protocols

4 of 105

Primer: Consensus Protocols

Consensus protocols are all about…

... making consistent decisions in a distributed system�

Normally we want:

  • Safety: “Nodes” can’t make inconsistent decisions
  • Liveness: Nodes are guaranteed to eventually decide

And there are some other things we may want (e.g. non-triviality, validity)

5 of 105

Primer: What are decisions?

Consensus protocols decide on either:

  • Consensus values, or
  • Predicates/properties of consensus values

Examples:

  • Binary consensus protocols decide on “0” or “1”
  • Blockchain consensus on predicates “the chain has this block at height 110”

�They are usually taken to be “output” or “committed” by the nodes in the protocol

6 of 105

Primer: What are consistent decisions?

Decisions on values are consistent if they are the same values

  • A decision on value “110” is consistent only with decisions on value “110”

Decisions on predicates or properties of values are consistent if there are values that jointly satisfy the predicates

  • A decision that “the binary 3-string starts with 1” is consistent with a decision that “the binary 3-string ends with 0”.
  • A decision that “the chain has this block at height 110” and one that “the chain has this other block at height 111” might be consistent

7 of 105

Primer: Consensus Protocols

Consensus protocols are all about distributed systems making consistent decisions about a predefined domain of consensus values

8 of 105

Primer: Sharding

9 of 105

Primer: Sharding

10 of 105

Primer: Sharding

Sharding is all about…

...splitting up work in a distributed system in order to scale its capacity

11 of 105

Primer: Sharding

Sharding came from

“Computer Corporation of America's [1988] "A System for Highly Available Replicated Data"”

Or

“the critically acclaimed 1997 MMORPG video game Ultima Online”

12 of 105

Primer: Sharding

“Sharded” means …

…has more than one component

13 of 105

Primer: Sharding

Ergo...

A bit is not sharded

14 of 105

Primer: Sharding

Ergo...

A binary consensus protocol is not sharded

15 of 105

Sharded Consensus Protocols, in Theory

16 of 105

Sharded Consensus Protocols, in Theory

As we just learned...

...there cannot be a sharded binary consensus protocol.

17 of 105

Sharded Consensus Protocols, in Theory

The takeaway is:

To shard consensus, we need sharded consensus values!

18 of 105

Decisions in Sharded Consensus Protocols

19 of 105

Decisions in Sharded Consensus Protocols

Remember:

Decisions are on consensus values or their predicates

20 of 105

Decisions in Sharded Consensus Protocols

Because the goal of sharding is to scale the throughput of the consensus protocol…

… we want to assume that nodes make decisions on predicates that describe some but not all of the “shards” of the consensus value.

21 of 105

Decisions in Sharded Consensus Protocols

These decisions are consistent if…�

… there is a (sharded) consensus value that � jointly satisfies all of their decisions

22 of 105

Sharding Clients as Light Clients

23 of 105

Sharding Clients as Light Clients

We will imagine that…�

… sharding clients are light clients

24 of 105

Sharding Clients as Light Clients

There are two kinds of light clients:

  • Clients that don’t look at all of the consensus value
  • Clients that don’t look at all of the protocol messages

25 of 105

Sharding Clients as Light Clients

“Consensus value” light clients are all about…�

...Using the commitments of (crypto) proof systems as consensus values

Commitments (like merkle root hashes) can allow for the verification of (cryptographic) proofs of predicates of “full” consensus values

26 of 105

Sharding Clients as Light Clients

“Consensus value” light client examples:

  • Blockchain header chains as consensus values
  • Sharding solutions where a “root shard” has headers for blocks that affect changes on each shard

27 of 105

Sharding Clients as Light Clients

“Protocol message” light clients are all about…

… only receiving the messages that are relevant to their interests

Imagine that clients interested in a decision only need to receive protocol messages that are relevant to that decision, in some sense.

28 of 105

Sharding Clients as Light Clients

“Protocol message” light client examples:

  • Only receiving dogecoin blocks when interested in doge
  • Sharding solutions where different validator sets are responsible for consensus on different shards

29 of 105

Sharded (Blockchain) Consensus Values

30 of 105

Sharded (Blockchain) Consensus Values

We begin by specifying sharded consensus values…

… a blockchain for every shard

… sent and received message queues between neighbor shards

… so that shards can represent “threads” of communicating EVM executions

31 of 105

Sharded (Blockchain) Consensus Values

A block has:

A shard ID, out of a set of shard names

32 of 105

Sharded (Blockchain) Consensus Values

A block has:

A previous block (with the same shard ID)

Or it’s a genesis block (which have no prev blocks)

33 of 105

Sharded (Blockchain) Consensus Values

A block has:

A transaction list and an EVM “Post State

Or it’s a genesis block (which have no tx lists)

34 of 105

Sharded (Blockchain) Consensus Values

A block has:

A source block for each of its neighbor shards

This is where incoming XShard messages will be drawn

35 of 105

Sharded (Blockchain) Consensus Values

A block has:

A list of sent messages for each of its neighbors

36 of 105

Sharded (Blockchain) Consensus Values

A block has:

A list of received messages for each of its neighbors

37 of 105

Sharded (Blockchain) Consensus Values

A cross-shard message has:

A message payload

(can think of this as call data, gaslimit, eth balance)

38 of 105

Sharded (Blockchain) Consensus Values

A cross-shard message has:

A Time To Live (TTL)

Which is used to identify when messages cannot be received, and to force messages to be received by expiry

39 of 105

Sharded (Blockchain) Consensus Values

A cross-shard message has:

A “base” or “target” block

(The block from which cross-shard messages must be received by the TTL)

40 of 105

Sharded (Blockchain) Consensus Values

In summary, a Block has:

  • Shard ID
  • Previous block (or not)
  • Transaction list (or not)
  • EVM state
  • Source blocks for its neighbors
  • Sent/received cross-shard message lists for its neighbors

41 of 105

Sharded (Blockchain) Consensus Values

And a cross-shard message has:

  • Payload
  • Time To Live
  • “Base” or “Target” Block

42 of 105

Sharded (Blockchain) Consensus Values

BUT

We have a bunch of additional constraints on the definition of blocks, to guarantee that from the point of view of any block, “things have gone well”

43 of 105

Validity Condition: Monotonic Sources

VS

44 of 105

Validity Condition: Receive Messaged by Expiry

VS

45 of 105

Validity Condition: Source-Source Consistency

46 of 105

Sharded (Blockchain) Consensus Values

Blocks on the same shard are inconsistent when they aren’t in the same blockchain�

47 of 105

Sharded (Blockchain) Consensus Values

��Blocks on different shards are inconsistent when they either disagree with the others’ sources or fail to receive each others’ messages by expiry.

48 of 105

Sharded (Blockchain) Consensus Values

A “decision on a block” represents a decision on a property of the consensus values, which are a collection that includes a blockchain for every shard

49 of 105

Sharded (Blockchain) Consensus Values

A “decision on a block” represents a decision that a block will be part of the multi-threaded execution of the EVM (with communiation)

50 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

51 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Recall that to achieve scalability we need to have light clients

And there are two kinds of light clients:

  • Consensus value light clients
  • Protocol message light clients

52 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

To use consensus value light clients, we will redefine our consensus values to use hashes instead of nesting

53 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

A (new, light client friendly) block (header) has:

  • Shard IDs
  • Previous block hash (or not)
  • Merkle root of a transaction lists (or not)
  • Merkle trie root of an EVM state
  • Hashes of source blocks for its neighbors
  • Merkle root hashes of sent/received cross-shard message lists for its neighbors

54 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

A (new, light client friendly) cross-shard message has:

  • The hash of a payload
  • Time To Live
  • The hash of a “Base” or “Target” Block

55 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

To use consensus protocol message light clients, we will need to modify our Minimal CBC Casper specification

56 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

The “Minimal” CBC Casper spec describes “full node” consensus protocols:��If you have a message in your protocol state, then you must also have the messages in its justification in your state

57 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

�In a “Light Client” CBC Casper spec, we will need to allow nodes to selectively download the messages in the justifications of protocol messages.

58 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

�In a “Light Client” CBC Casper spec, we need to replace message nesting with reference by cryptographic hash,���as we just did for our sharded (blockchain) consensus values

59 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

But in a “Light Client” CBC Casper spec, we still need to satisfy the same proof of consensus safety.

60 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

The consensus safety result relies on the following theorem:

�If there are less than t (weighted) equivocation faults observable in the union of nodes’ protocol states, then they have a common future protocol state.

61 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Recall that in CBC Casper, protocol states are sets of messages, and the state transition corresponds to receiving messages (superset)

62 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Recall that, in the CBC Casper full node specification,

two distinct messages from the same validator are an equivocation if they do not include one another in their justification

63 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

64 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Now, in the light client spec, we must modify the definition:

two distinct messages from the same validator are an equivocation if they do not include one another’s hash in their justification

65 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

66 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

67 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Now, in the light client spec, we are able to detect the weight of equivocation faults from a protocol state (which is now allowed to be any* set of consensus protocol messages).

68 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Now, in the light client spec, we can restrict protocol states to only exhibit not more than t weight of equivocation faults.

As we do in the full node CBC Casper protocol

69 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Now, we can show that �

if light nodes have not more than t weight of equivocation faults in the union of their states, they have a common future state (witness: the union itself)

70 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

Furthermore, if the client do not have a common future state, then it must be that the union of their states exhibit more than t weight of equivocation faults.

71 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

After establishing that nodes have a common future state if there aren’t too many faults, the consensus safety result describes decisions on properties of consensus values

72 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

The decisions on properties of the consensus are defined by the “estimator”, something that takes a slightly more generic role than the traditional fork choice rule.

73 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

The estimator maps protocol states to the possible “valid” choices of consensus values that a consensus client can “estimate” from that state

74 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

A property of consensus values is called decided if for all future protocol states, the estimator only returns values that satisfy this property.

75 of 105

Sharded (Blockchain) �CBC Casper Consensus Client

�Decisions between nodes are thereby guaranteed to be consistent if they have a common future protocol state�

Which is guaranteed if the union of their states does not exhibit too many equivocation faults!

76 of 105

Sharded (Blockchain) Fork Choice Rule

77 of 105

Sharded (Blockchain) Fork Choice rule

The role of the fork choice rule is to map protocol states to choices of consensus values.

In our context, our consensus values are blocks from the sharded blockchain, and our protocol states are the CBC Casper light client states just described

78 of 105

Sharded (Blockchain) Fork Choice rule

���For clients to make decisions, they must be able to understand which consensus messages they need to see.

79 of 105

Sharded (Blockchain) Fork Choice rule

We will therefore structure the fork choice rule in order to create a clear connection between decisions and subsets of the validator set that are responsible for that decision.

80 of 105

Sharded (Blockchain) Fork Choice rule

We will assign different (mutually exclusive) subsets of the validator set to each shard.

This way clients know which validators are on what shards.

81 of 105

Sharded (Blockchain) Fork Choice rule

And we will insist that shard “neighbors” are of one of two types:

  • Parent
  • Child�

And that every shard has at most one parent, and that only one shard has no parents. Setting up a tree structure

82 of 105

Sharded (Blockchain) Fork Choice rule

���Furthermore, we will make the fork choice rule of a shard independent of the fork choice rule of its children.

83 of 105

Sharded (Blockchain) Fork Choice rule

This tree structure achieves a few important things:

  • It lets a client determine what validators they need messages from in order to make decisions
  • They need to hear from less than the global validator set, for any decision
  • Decisions made on any two shards are not necessarily independent, no matter where on the tree they are.

84 of 105

Sharded (Blockchain) Fork Choice rule

��Recall that blocks on different shards are inconsistent when they either disagree with each others’ sources or fail to receive each others’ messages by expiry

Which is why the “non-independence” property is critical

85 of 105

Sharded (Blockchain) Fork Choice rule

�We will now give a concrete example of a sharded fork choice rule that fits these constraints and guarantees that cross-shard communication atomicity won’t fail.

86 of 105

Sharded (Blockchain) Fork Choice rule

The root shard executes latest message driven GHOST completely independently of any other shards�

87 of 105

Sharded (Blockchain) Fork Choice rule

All other shards execute the latest message driven GHOST fork choice rule, while additionally orphaning any blocks that fail to synchronize with the parent shard.��There are four such “filter conditions”

88 of 105

Sharded Fork Choice Filter condition: �Child block out of synch with parent source

89 of 105

Sharded Fork Choice Filter condition: �Child source out of synch with parent fork choice

90 of 105

Sharded Fork Choice Filter condition: �Child block failed to receive message by expiry

91 of 105

Sharded Fork Choice Filter condition: �Child block sent message not received by expiry

92 of 105

Sharded (Blockchain) Fork Choice rule

�Claim: ��This fork choice rule guarantees that cross-shard atomicity failure cannot be violated, because such violations will be orphaned by the fork choice of the child shard.

93 of 105

94 of 105

Sharded (Blockchain) Fork Choice rule

Claim:�

CBC Casper light clients for this sharded blockchain protocol will not make inconsistent cross-shard decisions (if there aren’t too many faults)

95 of 105

Sharded (Blockchain) Fork Choice rule

Claim:�

CBC Casper light clients can determine which validators they must hear from to make decisions on a given shard, and they don’t need to hear from all validators (at least if any shard has more than one child)

96 of 105

Sharded (Blockchain) Fork Choice rule

Claim:�

CBC Casper light clients deciding on blocks in the described domain of sharded consensus values implement a scalable (blockchain) consensus protocol.

97 of 105

Other Relevant Work, Future Directions

98 of 105

Other Relevant Work, Future Directions

  • More complex consensus values
    • Message routing
    • Shard rotation
    • Validator rotation
  • Guaranteeing Block Validity and Availability
  • Protocol behaviour, validator strategies, liveness
  • Incentive design
  • Efficiency and engineering improvements
  • Performance profiling

99 of 105

100 of 105

101 of 105

Conclusion

102 of 105

Conclusion

Takeaways:

  • Sharding consensus requires defining sharded consensus values
    • Like the shards with the block structure given here
  • Sharding clients are light clients
    • With respect to consensus values
    • With respect to protocol messages
  • Sharded consensus protocols exist
    • Like the CBC Casper light client deciding on sharded blocks!
  • Sharding can be a natural way to scale consensus protocols
  • Sharding is simple (at least in theory)!

103 of 105

CBC Casper Workshop

Title: “Safety & Liveness in CBC Casper”

Presenter: Aditya Asgaonkar

Time: 16:45, Day 1

Location: Jean Fourastié

104 of 105

Q&A

105 of 105

Thanks for listening!

Thanks for having me!

Please reach out,

contribute!