chainspace: a sharded smart contracts platform · on which smart contract code and state runs, and...

15
Chainspace: A Sharded Smart Contracts Platform Mustafa Al-Bassam * , Alberto Sonnino * , Shehar Bano * , Dave Hrycyszyn and George Danezis * * University College London, United Kingdom constructiveproof.com Abstract—Chainspace is a decentralized infrastructure, known as a distributed ledger, that supports user defined smart contracts and executes user-supplied transactions on their objects. The correct execution of smart contract transactions is verifiable by all. The system is scalable, by sharding state and the execution of transactions, and using S -BAC, a distributed commit protocol, to guarantee consistency. Chainspace is secure against subsets of nodes trying to compromise its integrity or availability properties through Byzantine Fault Tolerance (BFT), and extremely high- auditability, non-repudiation and ‘blockchain’ techniques. Even when BFT fails, auditing mechanisms are in place to trace mali- cious participants. We present the design, rationale, and details of Chainspace; we argue through evaluating an implementation of the system about its scaling and other features; we illustrate a number of privacy-friendly smart contracts for smart metering, polling and banking and measure their performance. I. I NTRODUCTION Chainspace is a distributed ledger platform for high-integrity and transparent processing of transactions within a decentralized system. Unlike application specific distributed ledgers, such as Bitcoin [26] for a currency, or certificate transparency [19] for certificate verification, Chainspace offers extensibility though smart contracts, like Ethereum [32]. However, users expose to Chainspace enough information about contracts and transaction semantics, to provide higher scalability through sharding across infrastructure nodes: our modest testbed of 60 cores achieves 350 transactions per second, as compared with a peak rate of less than 7 transactions per second for Bitcoin over 6K full nodes. Etherium currently processes 4 transactions per second, out of theoretical maximum of 25. Furthermore, our platform is agnostic as to the smart contract language, or identity infrastructure, and supports privacy features through modern zero-knowledge techniques [3, 9]. Unlike other scalable but ‘permissioned’ smart contract platforms, such as Hyperledger Fabric [5] or BigchainDB [23], Chainspace aims to be an ‘open’ system: it allows anyone to author a smart contract, anyone to provide infrastructure on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features, by allowing composition of smart contracts from different authors. We integrate a value system, named CSCoin, as a system smart contract to allow for accounting between those parties. However, the security model of Chainspace, is different from traditional unpermissioned blockchains, that rely on proof- of-work and global replication of state, such as Ethereum. In Chainspace smart contract authors designate the parts of the infrastructure that are trusted to maintain the integrity of their contract—and only depend on their correctness, as well as the correctness of contract sub-calls. This provides fine grained control of which part of the infrastructure need to be trusted on a per-contract basis, and also allows for horizontal scalability. This paper makes the following contributions: It presents Chainspace, a system that can scale arbitrar- ily as the number of nodes increase, tolerates byzantine failures, and can be fully and publicly audited. It presents a novel distributed atomic commit protocol, called S -BAC, for sharding generic smart contract transactions across multiple byzantine nodes, and correctly coordinating those nodes to ensure safety, liveness and security properties. It introduces a distinction between parts of the smart contract that execute a computation, and those that check the computation and discusses how that dis- tinction is key to supporting privacy-friendly smart- contracts. It provides a full implementation and evaluates the per- formance of the byzantine distributed commit protocol, S -BAC, on a real distributed set of nodes and under varying transaction loads. It presents a number of key system and applica- tion smart contracts and evaluates their performance. The contracts for privacy-friendly smart-metering and privacy-friendly polls illustrate and validate support for high-integrity and high-privacy applications. Outline: Section II presents an overview of Chainspace; Section III presents the client-facing application interface; Section IV presents the design of internal data structures guaranteeing integrity, the distributed architecture, the byzantine commit protocols, and smart contract definition and composi- tion. Section V argues the correctness and security; specific smart contracts and their evaluations are presented in Section VI; Section VII presents an evaluation of the core protocols and smart contract performance; Section VIII presents limitation and Section IX a comparison with related work; and Section X concludes. II. SYSTEM OVERVIEW Chainspace allows applications developers to implement distributed ledger applications by defining and calling proce- Network and Distributed Systems Security (NDSS) Symposium 2018 18-21 February 2018, San Diego, CA, USA ISBN 1-891562-49-5 http://dx.doi.org/10.14722/ndss.2018.23241 www.ndss-symposium.org

Upload: others

Post on 06-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

Chainspace: A Sharded Smart Contracts Platform

Mustafa Al-Bassam∗, Alberto Sonnino∗, Shehar Bano∗, Dave Hrycyszyn† and George Danezis∗∗ University College London, United Kingdom

† constructiveproof.com

Abstract—Chainspace is a decentralized infrastructure, knownas a distributed ledger, that supports user defined smart contractsand executes user-supplied transactions on their objects. Thecorrect execution of smart contract transactions is verifiable byall. The system is scalable, by sharding state and the executionof transactions, and using S-BAC, a distributed commit protocol,to guarantee consistency. Chainspace is secure against subsets ofnodes trying to compromise its integrity or availability propertiesthrough Byzantine Fault Tolerance (BFT), and extremely high-auditability, non-repudiation and ‘blockchain’ techniques. Evenwhen BFT fails, auditing mechanisms are in place to trace mali-cious participants. We present the design, rationale, and detailsof Chainspace; we argue through evaluating an implementationof the system about its scaling and other features; we illustrate anumber of privacy-friendly smart contracts for smart metering,polling and banking and measure their performance.

I. INTRODUCTION

Chainspace is a distributed ledger platform for high-integrityand transparent processing of transactions within a decentralizedsystem. Unlike application specific distributed ledgers, such asBitcoin [26] for a currency, or certificate transparency [19] forcertificate verification, Chainspace offers extensibility thoughsmart contracts, like Ethereum [32]. However, users expose toChainspace enough information about contracts and transactionsemantics, to provide higher scalability through sharding acrossinfrastructure nodes: our modest testbed of 60 cores achieves350 transactions per second, as compared with a peak rateof less than 7 transactions per second for Bitcoin over 6Kfull nodes. Etherium currently processes 4 transactions persecond, out of theoretical maximum of 25. Furthermore, ourplatform is agnostic as to the smart contract language, or identityinfrastructure, and supports privacy features through modernzero-knowledge techniques [3, 9].

Unlike other scalable but ‘permissioned’ smart contractplatforms, such as Hyperledger Fabric [5] or BigchainDB [23],Chainspace aims to be an ‘open’ system: it allows anyoneto author a smart contract, anyone to provide infrastructureon which smart contract code and state runs, and any user toaccess calls to smart contracts. Further, it provides ecosystemfeatures, by allowing composition of smart contracts fromdifferent authors. We integrate a value system, named CSCoin,as a system smart contract to allow for accounting between

those parties.

However, the security model of Chainspace, is differentfrom traditional unpermissioned blockchains, that rely on proof-of-work and global replication of state, such as Ethereum. InChainspace smart contract authors designate the parts of theinfrastructure that are trusted to maintain the integrity of theircontract—and only depend on their correctness, as well as thecorrectness of contract sub-calls. This provides fine grainedcontrol of which part of the infrastructure need to be trusted ona per-contract basis, and also allows for horizontal scalability.

This paper makes the following contributions:

• It presents Chainspace, a system that can scale arbitrar-ily as the number of nodes increase, tolerates byzantinefailures, and can be fully and publicly audited.

• It presents a novel distributed atomic commit protocol,called S-BAC, for sharding generic smart contracttransactions across multiple byzantine nodes, andcorrectly coordinating those nodes to ensure safety,liveness and security properties.

• It introduces a distinction between parts of the smartcontract that execute a computation, and those thatcheck the computation and discusses how that dis-tinction is key to supporting privacy-friendly smart-contracts.

• It provides a full implementation and evaluates the per-formance of the byzantine distributed commit protocol,S-BAC, on a real distributed set of nodes and undervarying transaction loads.

• It presents a number of key system and applica-tion smart contracts and evaluates their performance.The contracts for privacy-friendly smart-metering andprivacy-friendly polls illustrate and validate supportfor high-integrity and high-privacy applications.

Outline: Section II presents an overview of Chainspace;Section III presents the client-facing application interface;Section IV presents the design of internal data structuresguaranteeing integrity, the distributed architecture, the byzantinecommit protocols, and smart contract definition and composi-tion. Section V argues the correctness and security; specificsmart contracts and their evaluations are presented in Section VI;Section VII presents an evaluation of the core protocols andsmart contract performance; Section VIII presents limitationand Section IX a comparison with related work; and Section Xconcludes.

II. SYSTEM OVERVIEW

Chainspace allows applications developers to implementdistributed ledger applications by defining and calling proce-

Network and Distributed Systems Security (NDSS) Symposium 2018 18-21 February 2018, San Diego, CA, USAISBN 1-891562-49-5http://dx.doi.org/10.14722/ndss.2018.23241www.ndss-symposium.org

Page 2: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

dures of smart contracts operating on controlled objects, andabstracts the details of how the ledger works and scales. In thissection, we first describe data model of Chainspace, followedby an overview of the system design, its threat model andsecurity properties.

A. Data Model: Objects, Contracts, Transactions.

Chainspace applies aggressively the end-to-end princi-ple [29] in relying on untrusted end-user applications to buildtransactions to be checked and executed. We describe belowkey concepts within the Chainspace data model, that developersneed to grasp to use the system.

Objects are atoms that hold state in the Chainspace system.We usually refer to an object through the letter o, and a set ofobjects as o ∈ O. All objects have a cryptographically derivedunique identifier used to unambiguously refer to the object, thatwe denote id(o). Objects also have a type, denoted as type(o),that determines the unique identifier of the smart contract thatdefines them, and a type name. In Chainspace object state isimmutable. Objects may be in two meta-states, either active orinactive. Active objects are available to be operated on throughsmart contract procedures, while inactive ones are retained forthe purposes of audit only.

Contracts are special types of objects, that contain exe-cutable information on how other objects of types defined bythe contract may be manipulated. They define a set of initialobjects that are created when the contract is first created withinChainspace. A contract c defines a namespace within whichtypes (denoted as types(c)) and a checker v for procedures(denoted as proc(c)) are defined.

A procedure, p, defines the logic by which a number ofobjects, that may be inputs or references, are processed by somelogic and local parameters and local return values (denotedas lpar and lret), to generate a number of object outputs.Notionally, input objects, denoted as a vector ~w, representstate that is invalidated by the procedure; references, denotedas ~r represent state that is only read; and outputs are objects, or~x are created by the procedure. Some of the local parametersor local returns may be secrets, and require confidentiality. Wedenote those as spar and sret respectively.

We denote the execution of such a procedure as:

c.p(~w,~r, lpar, spar)→ ~x, lret, sret (1)

for ~w,~r, ~x ∈ O and p ∈ proc(c). We restrict the type ofall objects (inputs ~w, outputs ~x and references ~r) to havetypes defined by the same contract c as the procedure p(formally: ∀o ∈ ~w∪~x∪~r.type(o) ∈ types(c)). However, publiclocals (both lpar and lret) may refer to objects that are fromdifferent contracts through their identifiers. We further requirea procedure that outputs an non empty set of objects ~x, toalso take as parameters a non-empty set of input objects ~w.Transactions that create no outputs are allowed to just takelocals and references ~r.

Associated with each smart contract c, we define a checkerdenoted as v. Those checkers are pure functions (ie. determin-istic, and have no side-effects), and return a Boolean value. Achecker v is defined by a contract, and takes as parameters a

user

Transactionp:w:r:lpar:x:lret:dep:

procedureinputsreferenceslocal parametersoutputslocal returnsdependencies

Shard

node node node

node node …

objects statuso1

o2

active

Shard

node node node

node node …

objects statuso1

o2

active

Fig. 1. Design overview of Chainspace system, showing the interactionbetween users, transactions, objects and nodes in shards.

procedure p, as well as inputs, outputs, references and locals.

c.v(p, ~w,~r, lpar, ~x, lret, dep)→ {true, false} (2)

Note that checkers do not take any secret local parameters(spar or sret). A checker for a smart contract returns true onlyif there exist some secret parameters spar or sret, such thatan execution of the contract procedure p, with the parameterspassed to the checker alongside spar or sret, is possible asdefined in Equation (1). The variable dep represent the contextin which the procedure is called: namely information aboutother procedure executions. This supports composition, as wediscuss in detail in the next section.

We note that procedures, unlike checkers, do not have tobe pure functions, and may be randomized, keep state or haveside effects. A smart contract defines explicitly the checker c.v,but does not have to define procedures per se. The Chainspacesystem is oblivious to procedures, and relies merely on checkers.Yet, applications may use procedures to create valid transactions.The distinction between procedures and checkers—that do nottake secrets—is key to implementing privacy-friendly contracts.

Transactions represent the atomic application of one ormore valid procedures to active input objects, and possiblysome referenced objects, to create a number of new activeoutput objects. The design of Chainspace is user-centric, inthat a user client executes all the computations necessary todetermine the outputs of one or more procedures forming atransaction, and provides enough evidence to the system tocheck the validity of the execution and the new objects.

Once a transaction is accepted in the system it ‘consumes’the input objects, that become inactive, and brings to life all newoutput objects that start their life by being active. Referenceson the other hand must be active for the transaction to succeed,and remain active once a transaction has been successfullycommitted.

A client packages enough information about the executionof those procedures to allow Chainspace to safely serialize itsexecution, and atomically commit it only if all transactions arevalid according to relevant smart contract checkers.

2

Page 3: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

B. System Design, Threat Model and Security Properties

We provide an overview of the system design, illustrated inFigure 1. Chainspace is comprised of a network of infrastructurenodes that manage valid objects, and ensure that only validtransactions are committed. A key design goal is to achievescalability in terms of high transaction throughput and lowlatency. To this end, nodes are organized into shards that managethe state of objects, keep track of their validity, and recordtransactions aborted or committed. Within each shard all honestnodes ensure they consistently agree whether to accept or rejecta transaction: whether an object is active or inactive at any point,and whether traces from contracts they know check. Acrossshards, nodes must ensure that transactions are committed ifall shards are willing to commit the transaction, and rejected(or aborted) if any shards decide to abort the transaction—dueto checkers returning false or objects being inactive. To satisfythese requirements, Chainspace implements S-BAC—a protocolthat composes existing Byzantine agreement and atomic commitprimitives in a novel way. Consensus on committing (oraborting) transactions takes place in parallel across differentshards. For transparency and auditability, nodes in each shardperiodically publish a signed hash chain of checkpoints: shardsadd a block (Merkle tree) of evidence including transactionsprocessed in the current epoch, and signed promises from othernodes, to the hash chain.

Chainspace supports security properties against two distincttypes of adversaries, both polynomial time bounded:

• Honest Shards (HS). The first adversary may createarbitrary contracts, and input arbitrary transactions intoChainspace, however they are bound to only controlup to f faulty nodes in any shard. As a result, andto ensure the correctness and liveness properties ofByzantine consensus, each shard must have a size ofat least 3f + 1 nodes.

• Dishonest Shards (DS). The second adversary has,additionally to HS, managed to gain control of one ormore shards, meaning that they control over f nodesin those shards. Thus, its correctness or liveness maynot be guaranteed.

Faulty nodes in shards may behave arbitrarily, and colludeto violate any of the security, safely or liveness properties ofthe system. They may emit incorrect or contradictory messages,as well as not respond to any or some requests.

Given this threat model, Chainspace supports the followingsecurity properties:

• Transparency. Chainspace ensures that anyone inpossession of the identity of a valid object mayauthenticate the full history of transactions and objectsthat led to the creation of the object. No transactionsmay be inserted, modified or deleted from that causalchain or tree. Objects may be used to self-authenticateits full history—this holds under both the HS and DSthreat models.

• Integrity. Subject to the HS threat model, when one ormore transactions are submitted only a set of valid non-conflicting transactions will be committed within thesystem. This includes resolving conflicts—in terms of

multiple transactions using the same objects—ensuringthe validity of the transactions, and also making surethat all new objects are registered as active. Ultimately,Chainspace transactions are accepted, and the set ofactive objects changes, as if executed sequentially—however, unlike other systems such as Ethereum [32],this is merely an abstraction and high levels ofconcurrency are supported.

• Encapsulation. The smart contract checking systemof Chainspace enforces strict isolation between smartcontracts and their state—thus prohibiting one smartcontract from directly interfering with objects fromother contracts. Under both the HS and DS threatmodels. However, cross-contract calls are supportedbut mediated by well defined interfaces providingencapsulation.

• Non-repudiation. In case conflicting or otherwiseinvalid transactions were to be accepted in honestshards (in the case of the DS threat model), thenevidence exists to pinpoint the parties or shards in thesystem that allowed the inconsistency to occur. Thus,failures outside the HS threat model, are detectable; theguilty parties may be banned; and appropriate off-linerecovery mechanisms could be deployed.

III. THE CHAINSPACE APPLICATION INTERFACE

Smart Contract developers in Chainspace register a smartcontract c into the distributed system managing Chainspace,by defining a checker for the contract and some initial objects.Users may then submit transactions to operate on those objectsin ways allowed by the checkers. Transactions represent theexecution of one or more procedures from one or more smartcontracts. It is necessary for all inputs to all procedures withinthe transaction to be active for a transaction to be executedand produce any output objects.

Transactions are atomic: either all their procedures run, andproduce outputs, or none of them do. Transactions are alsoconsistent: in case two transactions are submitted to the systemusing the same active object inputs, at most one of them willeventually be executed to produce outputs. Other transactions,called conflicting, will be aborted.

Representation of Transactions. A transaction withinChainspace is represented by sequence of traces of theexecutions of the procedures that compose it, and theirinterdependencies. These are computed and packaged by end-user clients, and contain all the information a checker needs toestablish its correctness. A Transaction is a data structure suchthat:

type Transaction : Trace listtype Trace : Record {

c : id(o), p : string,~w,~r, ~x : id(o) list,lpar, lret : arbitrary data,dep : Trace list}

To generate a set of traces composing the transaction, a userexecutes on the client side all the smart contract procedures

3

Page 4: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

α0,Valid(t), α′ α′,Valid(T ′), α1 (Sequence)α0,Valid(T = t :: T ′), α1

α0,Valid(dep), α′ α′, c.v(p, ~w,~r, lpar, ~x, lret, dep), (α′ \ ~w) ∪ ~x

~w,~r ∈ α′∧(~x 6= ∅)→ (~w 6= ∅)∧

∀o ∈ ~w ∪ ~x ∪ ~r.type(o) ∈ types(c)(Check)

α0,Valid(t = [c, p, ~w,~r, ~x, lpar, lret, dep]), (α′ \ ~w) ∪ ~x

Fig. 2. The sequencing and checking validity rules for transactions.

required on the input objects, references and local parameters,and generates the output objects and local returns for everyprocedure—potentially also using secret parameters and re-turns. Thus the actual computation behind the transactions isperformed by the user, and the traces forming the transactionalready contain the output objects and return parameters, andsufficient information to check their validity through smartcontract checkers. This design pattern is related to traditionaloptimistic concurrency control.

Only valid transactions are eventually committed intothe Chainspace system, as specified by two validity rulessequencing and checking presented in Figure 2. Transactionsare considered valid within a context of a set of active objectsmaintained by Chainspace, denoted with α. Valid transactionslead to a new context of active objects (eg. α′). We denotethis through the triplet (α,Valid(T ), α′), which is true if theexecution of transaction T is valid within the context of activeobjects α and generates a new context of active objects α′. Thetwo rules are as follows:

• (Sequence rule). A ‘Trace list’ (within a ‘Transaction’or list of dependencies) is valid if each of the traces arevalid in sequence (see Figure 2 rule for sequencing).Further, the active objects set is updated in sequencebefore considering the validity of each trace.

• (Check rule). A particular ‘Trace’ is valid, if thesequence of its dependencies are valid, and then inthe resulting active object context, the checker for itreturns true. A further three side conditions must hold:(1) inputs and references must be active; (2) if thetrace produces any output objects it must also containsome input objects; and (3) all objects passed to thechecker must be of types defined by the smart contractof this checker (see Figure 2 rule for checking).

The ordering of active object sets in the validation rulesresult in a depth-first validation of all traces, which representsa depth-first execution and data flow dependency between them.It is also noteworthy that only the active set of objects needsto be tracked to determine the validity of new transactions,which is in the order of magnitude of active objects in thesystem. The much longer list of inactive objects, which growsto encompass the full history of every object in the system is notneeded—which we leverage to enable better when validatingtransactions. It also results in a smaller amount of workingmemory to perform incremental audits.

A valid transaction is executed in a serialized manner, andcommitted or aborted atomically. If it is committed, the new setof active objects replaces the previous set; if not the set of active

objects does not change. Determining whether a transactionmay commit involves ensuring all the input objects are active,and all are consumed as a result of the transaction executing,as well as all new objects becoming available for processing(references however remain active). Chainspace ensures thisthrough the distributed atomic commit protocol, S-BAC.

Smart contract composition. A contract procedure may call atransaction of another smart contract, with specific parametersand rely upon returned values. This is achieved through passingthe dep variable to a smart contract checker, a validated list oftraces of all the sub-calls performed. The checker can ensurethat the parameters and return values are as expected, and thosedependencies are checked for validity by Chainspace.

Composition of smart contracts is a key feature of atransparent and auditable computation platform. It allows thecreation of a library of smart contracts that act as utilities forother higher-level contracts: for example, a simple contractcan implement a cryptographic currency, and other contracts—for e-commerce for example—can use this currency as partof their logic. Furthermore, we compose smart contracts, inorder to build some of the functionality of Chainspace itselfas a set of ‘system’ smart contracts, including management ofshards mapping to nodes, key management of shard nodes, andgovernance.

Chainspace also supports the atomic batch execution ofmultiple procedures for efficiency, that are not dependent oneach other.

Reads. Besides executing transactions, Chainspace clients, needto read the state of objects, if anything, to correctly formtransactions. Reads, by themselves, cannot lead to inconsistentstate being accepted into the system, even if they are used asinputs or references to transactions. This is a result of the systemchecking the validity rules before accepting a transaction, whichwill reject any stale state.

Thus, any mechanism may be used to expose the state ofobjects to clients, including traditional relational databases, or‘no-SQL’ alternatives. Additionally, any indexing mechanismmay be used to allow clients to retrieve objects with specificcharacteristics faster. Decentralized, read-only stores have beenextensively studied, so we do not address the question of readsfurther in this work.

Privacy by design. Defining smart contract logic as checkersallows Chainspace to support privacy friendly-contracts bydesign. In such contracts some information in objects is notin the clear, but instead either encrypted using a public key,or committed using a secure commitment scheme as [27].The transaction only contains a valid proof that the logic or

4

Page 5: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

invariants of the smart contract procedure were applied correctlyor hold respectively, and can take the form of a zero-knowledgeproof, or a Succinct Argument of Knowledge (SNARK). Then,generalizing the approach of [25], the checker runs the verifierpart of the proof or SNARK that validates the invariants of thetransactions, without revealing the secrets within the objects tothe verifiers.

IV. THE CHAINSPACE SYSTEM DESIGN

In Chainspace a network of infrastructure nodes managesvalid objects, and ensure key invariants: namely that only validtransactions are committed. We discuss the data structures nodesuse collectively and locally to ensure high integrity; and thedistributed protocols they employ to reach consensus on theaccepted transactions.

A. High-Integrity Data Structures

Chainspace employs a number of high-integrity data struc-tures. They enable those in possession of a valid object orits identifier to verify all operations that lead to its creation;they are also used to support non-equivocation—preventingChainspace nodes from providing a split view of the state theyhold without detection.

Hash-DAG structure. Objects and transactions naturally forma directed acyclic graph (DAG): given an initial state ofactive objects a number of transactions render their inputsinvalid, and create a new set of outputs as active objects.These may be represented as a directed graph between objects,transactions and new objects and so on. Each object may onlybe created by a single transaction trace, thus cycles betweenfuture transactions and previous objects never occur. We provethat output object identifiers resulting from valid transactionsare fresh (see Security Theorem 1). Hence, the graph of objectsinputs, transactions and objects outputs form a DAG, that maybe indexed by their identifiers.

We leverage this DAG structure, and augment it to provide ahigh-integrity data structure. Our principal aim is to ensure thatgiven an object, and its identifier, it is possible to unambiguouslyand unequivocally check all transactions and previous (nowinactive) objects and references that contribute to the existenceof the object. To achieve this we define as an identifier for allobjects and transactions a cryptographic hash that directly orindirectly depends on the identifiers of all state that contributedto the creation of the object.

Specifically, we define a function id(Trace) as the identifierof a trace contained in transaction T . The identifier of a traceis a cryptographic hash function over the name of contract andthe procedure producing the trace; as well as serialization ofthe input object identifiers, the reference object identifiers, andall local state of the transaction (but not the secret state ofthe procedures); the identifiers of the trace’s dependencies arealso included. Thus all information contributing to definingthe Trace is included in the identifier, except the output objectidentifiers.

We also define the id(o) as the identifier of an object o. Wederive this identifier through the application of a cryptographichash function, to the identifier of the trace that created theobject o, as well as a unique name assigned by the procedures

creating the trace, to this output object. (Unique in the contextof the outputs of this procedure call, not globally, such as alocal counter.)

An object identifier id(o) is a high-integrity handle that maybe used to authenticate the full history that led to the existenceof the object o. Due to the collision resistance properties ofsecure cryptographic hash functions an adversary is not ableto forge a past set of objects or transactions that leads to anobject with the same identifier. Thus, given id(o) anyone canverify the authenticity of a trace that led to the existence of o.

A very important property of object identifiers is thatfuture transactions cannot re-create an object that has alreadybecome inactive. Thus checking object validity only requiresmaintaining a list of active objects, and not a list of past inactiveobjects:

Security Theorem 1. No sequence of valid transactions, bya polynomial time constrained adversary, may re-create anobject with the same identifier with an object that has alreadybeen active in the system.

Proof: We argue this property by induction on the serializedapplication of valid transactions, and for each transaction by structuralinduction on the two validity rules. Assuming a history of n − 1transactions for which this property holds we consider transaction n.Within transaction n we sequence all traces and their dependencies,and follow the data flow of the creation of new objects by the ‘check’rule. For two objects to have the same id(o) there need to be twoinvocations of the check rule with the same contract, procedure, inputsand references. However, this leads to a contradiction: once the firsttrace is checked and considered valid the active input objects areremoved from the active set, and the second invocation becomesinvalid. Thus, as long as object creation procedures have at least oneinput (which is ensured by the side condition) the theorem holds,unless an adversary can produce a hash collision. The inductive basecase involves assuming that no initial objects start with the sameidentifier – which we can ensure axiomatically.

We call this directed acyclic graph with identifiers derivedusing cryptographic functions a Hash-DAG, and we makeextensive use of the identifiers of objects and their propertiesin Chainspace.

Node Hash-Chains. Each node in Chainspace, that is entrustedwith preserving integrity, associates with its shard a hash chain.Periodically, peers within a shard consistently agree to seal acheckpoint, as a block of transactions into their hash chains.They each form a Merkle tree containing all transactions thathave been accepted or rejected in sequence by the shard sincethe last checkpoint was sealed. Then, they extend their hashchain by hashing the root of this Merkle tree and a blocksequence number, with the head hash of the chain so far, tocreate the new head of the hash chain. Each peer signs the newhead of their chain, and shares it with all other peers in the shard,and anyone who requests it. For strong auditability additionalinformation, besides committed or aborted transactions, has tobe included in the Merkle tree: node should log any promiseto either commit or abort a transaction from any other peer inany shard (the prepared(T,*) statements explained in the nextsections).

All honest nodes within a shard independently create thesame chain for a checkpoint, and a signature on it—as long

5

Page 6: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

as the consensus protocols within the shards are correct. Wesay that a checkpoint represents the decision of a shard, for aspecific sequence number, if at least f + 1 signatures of shardnodes sign it. On the basis of these hash chains we define apartial audit and a full audit of the Chainspace system.

In a partial audit a client is provided evidence that atransaction has been either committed or aborted by a shard.A client performing the partial audit may request from anynode of the shard evidence for a transaction T. The shard peerwill present a block representing the decision of the shard,with f + 1 signatures, and a proof of inclusion of a commit orabort for the transaction, or a signed statement the transactionis unknown. A partial audit provides evidence to a client ofthe fate of their transaction, and may be used to detect pastof future violations of integrity. A partial audit is an efficientoperation since the evidence has size O(s+ logN) in N thenumber of transactions in the checkpoint and s the size ofthe shard—thanks to the efficiency of proving inclusion in aMerkle tree, and checking signatures.

A full audit involves replaying all transactions processedby the shard, and ensuring that (1) all transactions were validaccording to the checkers the shard executed; (2) the objectsinput or references of all committed transactions were all active(see rules in Figure 2); and (3) the evidence received fromother shards supports committing or aborting the transactions.To do so an auditor downloads the full hash-chain representingthe decisions of the shard from the beginning of time, andre-executes all the transactions in sequence. This is possible,since—besides their secret signing keys—peers in shardshave no secrets, and their execution is deterministic oncethe sequence of transactions is defined. Thus, an auditor canre-execute all transactions in sequence, and check that theirdecision to commit or abort them is consistent with the decisionof the shard. Doing this, requires any inter-shard communication(namely the promises from other shards to commit or aborttransactions) to be logged in the hash-chain, and used by theauditor to guide the re-execution of the transactions. A fullaudit needs to re-execute all transactions and requires evidenceof size O(N) in the number N of transactions. This is costly,but may be done incrementally as new blocks of shard decisionsare created.

B. Distributed Architecture & Consensus

A network of nodes manages the state of Chainspace objects,keeps track of their validity, and record transactions that areseen or that are accepted as being committed.

Chainspace uses sharding strategies to ensure scalability:a public function φ(o) maps each object o to a set of nodes,we call a shard. These nodes collectively are entrusted tomanage the state of the object, keep track of its validity, recordtransactions that involve the object, and eventually commitat most one transaction consuming the object as input andrendering it inactive. However, nodes must only record such atransaction as committed if they have certainty that all othernodes have, or will in the future, record the same transactionas consuming the object. We call this distributed algorithm theconsensus algorithm within the shard.

For a transaction T we define a set of concerned nodes,Φ(T ) for a transaction structure T . We first denote as ζ the

set of all objects identifiers that are input into or referencedby any trace contained in T . We also denote as ξ the set ofall objects that are output by any trace in T . The functionΦ(T ) represents the set of nodes that are managing objectsthat should exist, and be active, in the system for T to succeed.More mathematically, Φ(T ) =

⋃{φ(oi)|oi ∈ ζ \ ξ}, where

ζ \ ξ represents the set of objects input but not output by thetransaction itself (its free variables). The set of concerned peersthus includes all shard nodes managing objects that alreadyexist in Chainspace that the transaction uses as references orinputs.

An important property of this set of nodes holds, that ensuresthat all smart contracts involved in a transaction will be mappedto some concerned nodes that manage state from this contract:

Security Theorem 2. If a contract c appears in any tracewithin a transaction T , then the concerned nodes set Φ(T )will contain nodes in a shard managing an object o of a typefrom contract c. I.e. ∃o.type(o) ∈ types(c)∧ φ(o)∩Φ(T ) 6= ∅.

Proof: Consider any trace t within T , from contract c. If theinputs or references to this trace are not in ξ—the set of objects thatwere created within T—then their shards will be included withinΦ(T ). Since those are of types within c the theorem holds. If on theother hand the inputs or references are in ξ, it means that there existsanother trace within T from the same contract c that generated thoseoutputs. We then recursively apply the case above to this trace fromthe same c. The process will terminate with some objects of typesin c and shard managing them within the concerned nodes set—andthis is guarantee to terminate due to the Hash-DAG structure of thetransactions (that may have no loops).

Security Theorem 2 ensures that the set of concernednodes, includes nodes that manage objects from all contractsrepresented in a transaction. Chainspace leverages this todistribute the process of rule validation across peers in twoways:

• For any existing object o in the system, used as areference or input within a transaction T , only theshard nodes managing it, namely in φ(o), need tocheck that it is active (as part of the ‘check’ rule inFigure 2).

• For any trace t from contract c within a transaction T ,only shards of concerned nodes that manage objects oftypes within c need to run the checker of that contractto validate the trace (again as part of the ‘check’ rule),and that all input, output and reference objects are oftypes within c.

However, all shards containing concerned nodes for T needto ensure that all others have performed the necessary checksbefore committing the transaction, and creating new objects.

There are many options for ensuring that concerned nodes ineach shards do not reach an inconsistent state for the acceptedtransactions, such as Nakamoto consensus through proof-of-work [26], two-phase commit protocols [18], and classicalconsensus protocols like Paxos [17], PBFT [6], or xPaxos [21].However, these approaches lack in performance, scalability,and/or security. We design an open, scalable and decentralizedmechanism to perform Sharded Byzantine Atomic Commit orS-BAC.

6

Page 7: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

Nonestart Active

Lockedfor T Inactive

ALLPREPARED

(commit, T’)

LOCALPREPARED(abort, T)

LOCALPREPARED(commit, T)

ALLPREPARED(commit, T)

SOMEPREPARED(Abort, T)

*PREPARED

(*, T”)

Fig. 3. The state machine representing the active, locked and inactive statesfor any object within Chainspace. Each node in a shard replicates the state ofthe object, and participates in a consensus protocol that allows it to derive theinvariants “Local prepared”, “All prepared”, and “Some prepared” to updatethe state of an object.

C. Sharded Byzantine Atomic Commit (S-BAC).

Chainspace implements the previously described intra-shardconsensus algorithm for transaction processing in the byzantineand asynchronous setting, through the Sharded ByzantineAtomic Commit (S-BAC) protocol, that combines two primitiveprotocols: Byzantine Agreement and atomic commit.

• Byzantine agreement ensures that all honest membersof a shard of size 3f + 1, agree on a specific commonsequence of actions, despite some f malicious nodeswithin the shard. It also guarantees that when agree-ment is sought, a decision or sequence will eventuallybe agreed upon. The agreement protocol is executedwithin each shard to coordinate all nodes. We useMOD-SMART [30] implementation of PBFT for statemachine replication that provides an optimal numberof communications steps (similar to PBFT [6]). This isachieved by replacing reliable broadcast with a specialleader-driven Byzantine consensus primitive calledValidated and Provable Consensus (VP-Consensus).

• Atomic commit is run across all shards managingobjects relied upon by a transaction. It ensures thateach shard needs to accept to commit a transaction, forthe transaction to be committed; even if a single shardrejects the transaction, then all agree it is rejected.We propose the use of a simple two-phase commitprotocol [1], composed with an agreement protocolto achieve this—loosely inspired by Lamport andGray [12]. This protocol was the first to reconcile theneeds for distributed commit, and replicated consensus(but only in the non-byzantine setting).

S-BAC composes the above primitives in a novel wayto ensure that shards process safely and consistently alltransactions. Figure 4 illustrates a simple example of the S-BACprotocol to commit a single transaction with two inputs and oneoutput that we may use as an example. The corresponding objectstate transitions have been illustrated in Figure 3. The combinedprotocol has been described below. For ease of understanding,in our description we state that all messages are sent andprocessed by shards. In reality, some of these are handled bya designated node in each shard—the BFT-Initiator —as we

discuss at the end of this section.

Initial Broadcast (Prepare). A user acts as a transactioninitiator, and sends ‘prepare(T)’ to at least one honest concernednode for transaction T . To ensure at least one honest nodereceives it, the user may send the message to f + 1 nodes of asingle shard, or f + 1 nodes in each concerned shard.

Sequence Prepare. Upon a message ‘prepare(T)’ being re-ceived, nodes in each shard interpret it as the initiation of a two-phase commit protocol performed across the concerned shards.The shard locally sequences ‘prepare(T)’ message through theByzantine consensus protocol.

Process Prepare. Upon the first action ‘prepare(T )’ beingsequenced through BFT consensus in a shard, nodes of theshard implicitly decide whether it should be committed oraborted. Since all honest nodes in the shard have a consistentreplica of the full sequence of actions, they will all decide thesame consistent action following ‘prepare(T)’.

Transaction T is to be committed if it is valid according tothe usual rules (see Figure 2), in brief: (1) the objects inputor referenced by T in the shard are active, (2) there is noother instance of the two-phase commit protocol on-goingconcerning any of those objects (no locks held) and (3) if Tis valid according to the validity rules, and the smart contractcheckers in the shard. Only the checkers for types of objectsheld by the shard are checked by the shard.

If the decision is to commit, the shard broadcasts to allconcerned nodes ‘prepared(T ,commit)’, otherwise it broadcasts‘prepared(T , abort)’—along with sufficient signatures to con-vince any party of the collective shard decision (we denotethis action as LOCALPREPARED(*, T)). The objects used orreferenced by T are ‘locked’ (Figure 3) in case of a ‘preparedcommit’ until an ‘accept’ decision on the transaction is reached,and subsequent transactions concerning them will be aborted bythe shard. Any subsequent ‘prepare(T ′′)’ actions in the sequenceare ignored, until a matching accept(T , abort) is reached torelease locks, or forever if the transaction is committed.

Process Prepared (accept or abort). Depending on the deci-sion of ‘prepare(T )’, the shard sequences ‘accept(T ,commit)’ or‘accept(T ,abort)’ through the atomic commit protocol across allthe concerned shards—along with all messages and signaturesof the bundle of ‘prepared’ messages relating to T proving toother shards that the decision should be ‘accept(T ,commit)’ or‘accept(T ,abort)’ according to its local consensus. If it receiveseven a single ‘LOCALPREPARED(T ,abort)’ from another shardit instead will move to reach consensus on ‘accept(T , abort)’(denoted as SOMEPREPARED(abort,T)). Otherwise, if all theshards respond with ‘LOCALPREPARED(T ,commit)’ it willreach a consensus on ALLPREPARED(commit,T). The finaldecision is sent to the user, along with all messages andsignatures of the bundle of ‘accept’ messages relating to Tproving that the final decision should be to commit or abortaccording to responses from all concerned shards.

It is possible, that a shard hears a prepared message forT before a prepare message, due to unreliability, asynchronyor a malicious user. In that case the shard assumes that a‘prepare(T)’ message is implicit, and sequences it.

7

Page 8: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

User with T{o1, o2} → o3

Input shard φ(o1) BFT BFT

Input shard φ(o2) BFT BFT

Output shard φ(o3) BFT

InitialBroadcast

ProcessPrepare

ProcessPrepared

ProcessAccept

Send prepare(T ) Client Accept Confirmation

Create o3

Inactive o1

Inactive o2

Fig. 4. S-BAC for a transaction T with two inputs (o1, o2) and one output object (o3). The user sends the transaction to all nodes in shards managing o1 and o2.The BFT-Initiator takes the lead in sequencing T , and emits ’prepared(accept, T)’ or ’prepared(abort, T)’ to all nodes within the shard. Next the BFT-Initiator ofeach shard assesses whether overall ‘All proposed(accept, T)’ or ‘Some proposed(abort, T)’ holds across shards, sequences the accept(T,*), and sends the decisionto the user. All cross-shard arrows represent a multicast of all nodes in one shard to all nodes in another.

Process Accept. When a shard sequences an ‘accept(T , com-mit)’ decision, it sets all objects that are inputs to the transactionT as being inactive (Figure 3). It also creates any output objectsfrom T via BFT consensus that are to be managed by the shard.If the output objects are not managed by the shard, the shardsends requests to the concerned shards to create the objects. Onthe other hand if the shard decision is ‘accept(T , abort)’, allnodes release locks held on inputs or references of transactionT . Thus those objects remain active and may be used by othertransactions.

As previously mentioned, some of the messages in S-BACare handled by a designated node in each shard called the BFT-Initiator . Specifically, the BFT-Initiator drives the composedS-BAC protocol by sending ‘prepare(T)’ and then ‘accept(T , *)’messages to reach BFT consensus within and across shards. It isalso responsible for broadcasting consensus decisions to relevantparties. The protocol supports a two-phase process to recoverfrom a malicious BFT-Initiator that suppresses transactions. Asnodes in a shard hear all messages, they wait for the BFT-Initiator to act on it until they time out. They first send areminder to the BFT-Initiator along with the original messageto account for network losses. Next they proceed to wait; ifthey time out again, other nodes perform the action of BFT-Initiator which is idempotent.

D. Concurrency & Scalability

Each transaction T involves a fixed number of concernednodes Φ(T ) within Chainspace, corresponding to the shardsmanaging its inputs and references. If two transactions T0 andT1 have disjoint sets of concerned nodes (Φ(T0)∩Φ(T1) = ∅)they cannot conflict, and are executed in parallel or in anyarbitrary order. If however, two transactions have commoninput objects, only one of them is accepted by all nodes. Thisis achieved through the S-BAC protocol. It is local, in that itconcerns only nodes managing the conflicting transactions, anddoes not require a global consensus.

From the point of view of scalability, Chainspace capacitygrows linearly as more shards are added, subject to transactionshaving on average a constant, or sub-linear, number of inputsand references (see Figure 6). Furthermore, those inputs must

be managed by different nodes within the system to ensurethat load of accepting transactions is distributed across them.

V. SECURITY AND CORRECTNESS

A. Security & Correctness of S-BAC

The S-BAC protocol guarantees a number of key properties,on which rest the security of Chainspace, namely livenessconsistency, and validity. Before proceeding with stating thoseproperties in details, and proving them we note three keyinvariants, that nodes may decide:

• LOCALPREPARED(commit / abort, T): A node con-siders that LOCALPREPARED(commit / abort, T) fora shard holds, if it receives at least f + 1 distinctsigned messages from nodes in the shard, stating ‘pre-pared(commit, T)’ or ‘prepared(abort, T)’ respectively.As a special case a node automatically concludesLOCALPREPARED(commit / abort, T) for a shard itis a member of, if all the preconditions necessary toprovide that answer are present when an ‘prepare(T)’is sequenced.

• ALLPREPARED(commit, T): A node considers that‘ALLPREPARED(commit, T)’ holds if it believes that‘LOCALPREPARED(commit, T)’ holds for all shardswith concerned nodes for T . Note this may onlybe decided after reaching a conclusion (e.g. throughreceiving signed messages) about all shards.

• SOMEPREPARED(abort, T): A node considers that‘SOMEPREPARED(abort, T)’ holds if it believes that‘LOCALPREPARED(abort, T)’ holds for at least oneshard with concerned nodes for T . This may beconcluded after only reaching a conclusion for a singleshard, including the shard the node may be part of.

Liveness ensures that transactions make progress onceproposed by a user, and no locks are held indefinitely onobjects, preventing other transactions from making progress.

S-BAC Theorem 1. Liveness: Under the ‘honest shards’ threatmodel, a transaction T that is proposed to at least one honestconcerned node, will eventually result in either being committed

8

Page 9: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

or aborted, namely all parties deciding accept(commit, T) oraccept(abort, T).

Proof: We rely on the standard liveness properties of theunderlying byzantine agreement: ie. shards with only up to f faultynodes will reach a consensus on a sequence eventually. We alsorely on the broadcast from nodes of shards to all other nodes ofshards, including the shards that manage transaction outputs. Assumingprepare(T) has been given to an honest node, it will be sequencedwithing an honest shard BFT sequence, and thus a prepared(commit,T) or prepared(abort, T) will be sent from the 2f + 1 honest nodes ofthis shard, to the 2f + 1 nodes of the other concerned shards. Uponreceiving these messages the honest nodes from other shards willschedule a prepare(T) message within their shards, and the BFT willeventually sequence it. Thus the user and all other honest concernednodes will receive enough ‘prepared’ messages to decide whether toproceed with ‘ALLPREPARED(commit, T)’ or ‘SOMEPREPARED(abort,T)’ and proceed with sequencing them through BFT. Eventually, eachshard will sequence those, and decide on the appropriate ‘accept’.

The second key property ensures that the execution of validtransactions could be serialized, and thus is correct.

S-BAC Theorem 2. Consistency: Under the ‘honest shards’threat model, no two conflicting transactions, namely transac-tions sharing the same input will be committed. Furthermore,a sequential execution for all transactions exists.

Proof: A transaction is committed only if some nodes concludethat ‘ALLPREPARED(commit, T)’, which presupposes all shards haveprovided enough evidence to conclude ‘LOCALPREPARED(commit,T)’ for each of them. Two conflicting transaction, sharing an inputor reference, must share a shard of at least 3f + 1 concerned nodesfor the common object—with at most f of them being malicious.Without loss of generality upon receiving the prepare(T) messagefor the first transaction, this shard will sequence it, and the honestnodes will emit messages for all to conclude ‘ALLPREPARED(commit,T)’—and will lock this object until the two phase protocol concludes.Any subsequent attempt to prepare(T’) for a conflicting T’ will resultin a LOCALPREPARED(abort, T’) and cannot yield a commit, if allother shards are honest majority too. After completion of the first‘accept(commit, T)’ the shard removes the object from the active set,and thus subsequent T’ would also lead to SOMEPREPARED(abort,T’). Thus there is no path in the chain of possible interleavings ofthe executions of two conflicting transactions that leads to them bothbeing committed.

S-BAC Theorem 3. Validity: Under the ‘honest shards’ threatmodel, a transaction may only be committed if it is validaccording to the smart contract checkers matching the tracesof the procedures it executes.

Proof: A transaction is committed only if some nodes concludethat ‘ALLPREPARED(commit, T)’, which presupposes all shards haveprovided enough evidence to conclude ‘LOCALPREPARED(commit,T)’ for each of them. The concerned nodes include at least one shardper input or reference object for the transaction; for any contract crepresented in the transaction, at least one of those shards will bemanaging object from that contract. Each shard checks the validityrules for the objects they manage (ensuring they are active, and notlocked) and the contracts those objects are part of (ensuring thecalls to c pass its checker) in order to LOCALPREPARED(accept, T).Thus if all shards say LOCALPREPARED(accept, T) to conclude that‘ALLPREPARED(commit, T)’, all object have been checked as active,and all the contract calls within the transaction have been checked byat least one shard—whose decision is honest due to at most f faultynodes. If even a single object is inactive or locked, or a single tracefor a contract fails to check, then the honest nodes in the shard will

emit ‘prepared(abort, T)’ upon sequencing ‘prepare(T)’, and the finaldecision will be ‘SOMEPREPARED(abort, T)’.

B. Auditability

In the previous sections we show that if each shard containsat most f faulty nodes (honest shard model), the S-BACprotocol guarantees consistency and validity. In this sectionwe argue that if this assumption is violated, i.e. one or moreshards contain more than f byzantine nodes each, then honestshards can detect faulty shards. Namely, enough auditinginformation is maintained by honest nodes in Chainspace todetect inconsistencies and attribute them to specific shards (ornodes within them).

The rules for transaction validity are summarized in Figure 2.Those rules are checked in a distributed manner: each shardkeeps and checks the active or inactive state of objects assignedto it; and also only the contract checkers corresponding to thetype of those objects. An honest shard emits a proposed(T,commit) for a transaction T only if those checks pass, andproposed(T, abort) otherwise or if there is a lock on a relevantobject. A dishonest shard may emit proposed(T, *) messagesarbitrarily without checking the validity rules. By definition,an invalid transaction is one that does not pass one or more ofthe checks defined in Figure 2 at a shared, for which the shardhas erroneously emitted a proposed(T, commit) message.

Security Theorem 3. Auditability: A malicious shard (withmore than f faulty nodes) that attempts to introduce an invalidtransaction or object into the state of one or more honestshards, can be detected by an auditor performing a full auditof the Chainspace system.

Proof: We consider two hash-chains from two distinct shards.We define the pair of them as being valid if (1) they are each validunder full audit, meaning that a re-execution of all their transactionsunder the messages received yields the same decisions to commitor abort all transactions; and (2) if all prepared(T,*) messages inone chain are compatible with all messages seen in the other chain.In this context ‘compatible’ means that all prepared(T,*) statementsreceived in one shard from the other represent the ‘correct’ decisionto commit or abort the transaction T in the other shard. An exampleof incompatible message would result in observing a proposed(T,commit) message being emitted from the first shard to the second,when in fact the first shard should have aborted the transaction, dueto the checker showing it is invalid or an input being inactive.

Due to the property of digital signatures (unforgeability and non-repudiation), if two hash-chains are found to be ‘incompatible’, onebelonging to an honest shard and one belonging to a dishonest shard,it is possible for everyone to determine which shard is the dishonestone. To do so it suffices to isolate all statements that are signed byeach shard (or a peer in the shard)—all of which should be self-consistent. It is then possible to show that within those statementsthere is an inconsistency—unambiguously implicating one of the twoshards in the cheating. Thus, given two hash-chains it is possibleto either establish their consistency, under a full audit, or determinewhich belongs to a malicious shard.

Note that the mechanism underlying tracing dishonest shardsis an instance of the age-old double-entry book keeping1: shardskeep records of their operations as a non-repudiable signed hash-chain of checkpoints—with a view to prove the correctness of

1The first reported use is 1340AD [20].

9

Page 10: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

their operations. They also provide non-repudiable statementsabout their decisions in the form of signed proposed(T,*)statements to other shards. The two forms of evidence mustbe both correct and consistent—otherwise their misbehaviouris detected.

VI. SYSTEM AND APPLICATIONS SMART CONTRACTS

A. System Contracts

The operation of a Chainspace distributed ledger itselfrequires the maintenance of a number of high-integrity high-availability data structures. Instead of employing an ad-hocmechanism, Chainspace employs a number of system smartcontracts to implement those. Effectively, instantiation ofChainspace is the combination of nodes running the basicS-BAC protocol, as well as a set of system smart contractsproviding flexible policies about managing shards, smartcontract creation, auditing and accounting. This section providesan overview of system smart contracts.

Shard management. The discussion of Chainspace so far,has assumed a function φ(o) mapping an object o to nodesforming a shard. However, how those shards are constitutedhas been abstracted. A smart contract ManageShards isresponsible for mapping nodes to shards. ManageShardsinitializes a singleton object of type MS.Token and providesthree procedures: MS.create takes as input a singleton object,and a list of node descriptors (names, network addresses andpublic verification keys), and creates a new singleton objectand a MS.Shard object representing a new shard; MS.updatetakes an existing shard object, a new list of nodes, and 2f + 1signatures from nodes in the shard, and creates a new shardobject representing the updated shard. Finally, the MS.objectprocedure takes a shard object, and a non-repudiable record ofmalpractice from one of the nodes in the shard, and createsa new shard object omitting the malicious shard node—aftervalidating the misbehaviour. Note that Chainspace is ‘open’ inthe sense that any nodes may form a shard; and anyone mayobject to a malicious node and exclude it from a shard.

Smart-contract management. Chainspace is also ‘open’ inthe sense that anyone may create a new smart contract, and thisprocess is implemented using the ManageContracts smart con-tract. ManageContracts implements three types: MC.Token,MC.Mapping and MC.Contract. It also implements at leastone procedure, MC.create that takes a binary representing achecker for the contract, an initialization procedure name thatcreates initial objects for the contract, and the singleton tokenobject. It then creates a number of outputs: one object of typeMC.Token for use to create further contracts; an object oftype MC.Contract representing the contract, and containingthe checker code, and a mapping object MC.mapping encodingthe mapping between objects of the contract and shards withinthe system. Furthermore, the procedure MC.create calls theinitialization function of the contract, with the contract itselfas reference, and the singleton token, and creates the initialobjects for the contract.

Note that this simple implementation for ManageContractsdoes not allow for updating contracts. The semantics of suchan update are delicate, particularly in relation to governanceand backwards compatibility with existing objects. We leave

the definitions of more complex, but correct, contracts formanaging contracts as future work. In our first implementationwe have hardcoded ManageShards and ManageContracts.

Payments for processing transactions. Chainspace is an opensystem, and requires protection againt abuse resulting fromoveruse. To achieve this we implement a method for trackingvalue through a contract called CSCoin.

The CSCoin contract creates a fixed initial supply of coins—a set of objects of type The CSCoin.Account that may only beaccessed by a user producing a signature verified by a publickey denoted in the object. A CSCoin.transfer procedure allowsa user to input a number of accounts, and transfer value betweenthem, by producing the appropriate signature from incomingaccounts. It produces a new version of each account objectwith updated balances. This contract has been implemented inPython with approximately 200 lines of code.

The CSCoin contract is designed to be composed with otherprocedures, to enable payments for processing transactions.The transfer procedure outputs a number of local returnswith information about the value flows, that may be used incalling contracts to perform actions conditionally on those flows.Shards may advertise that they will only consider actions validif some value of CSCoin is transferred to their constituentnodes. This may apply to system contracts and applicationcontracts.

B. Application level smart contracts

This section describes some examples of privacy-friendlysmart contracts and showcases how smart contract creators mayuse Chainspace to implement advanced privacy mechanisms.

Smart-Meter Private Billing. We implement a basic privatesmart-meter billing mechanism [14, 28] using the contractSMet: it implements three types SMet.Token, SMet.Meterand SMet.Bill; and three procedures, SMet.createMeter,SMet.AddReading, and SMet.computeBill. The procedureSMet.createMeter takes as input the singletone token and apublic key and signature as local parameters, and it outputs aSMet.Meter object tied to this meter public key if the signaturematches. SMet.Meter objects represent a collection of readingsand some meta-data about the meter. Subsequently, the metermay invoke SMet.addReading on a SMet.Meter with a setof cryptographic commitments readings and a period identifieras local parameters, and a valid signature on them. A signatureis also included and checked to ensure authenticity from themeter. A new object SMet.Meter is output appending the listof new readings to the previous ones. Finally, a procedureSMet.computeBill is invoked with a SMet.Meter and localparameters a period identifier, a set of tariffs for each readingin the period, and a zero-knowledge proof of correctness ofthe bill computation. The procedure outputs a SMet.Bill object,representing the final bill in plain text and the meter and periodinformation.

This proof of correctness is provided to the checker—rather than the secret readings—which proves that the readingsmatching the available commitments and the tariffs providedyield the bill object. The role of the checker, which checkspublic data, in both those cases is very different from the role of

10

Page 11: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

the procedure that is passed secrets not available to the checkersto protect privacy. This contracts has been implemented in about200 lines of Python code and is evaluated in section Section VII.

A Platform for Decision Making. An additional example ofChainspace’s privacy-friendly application is a smart votingsystem. We implement the contract SVote with three types,SVote.Token, SVote.Vote and SVote.Tally; and three proce-dures.

SVote.createElection, consumes a singleton token andtakes as local parameters the options, a list of all voter’s publickey, the tally’s public key, and a signature on them from thetally. It outputs a fresh SVote.Vote object, representing theinitial stage of the election (all candidates having a scoreof zero) along with a zero-knowledge proof asserting thecorrectness of the initial stage. SVote.addVote, is called on aSVote.Vote object and takes as local parameters a new vote toadd, homomorphically encrypted and signed by the voter. Inaddition, the voter provides a zero-knowledge proof certifyingthat her vote is a binary value and that she voted for exactlyone option. The voter’s public key is then removed from the listof participants to ensure that she cannot vote more than once.If all proofs are verified by the checker and the voter’s publickey appears in the list, a new SVote.Vote object is created asthe homomorphic addition of the previous votes with the newone. Note that the checker does not need to know the clearvalue of the votes to assert their correctness since it only hasto verify the associated signatures and zero-knowledge proofs.

Finally, the procedure SVote.tally is called to thresholddecrypt the aggregated votes and provide a SVote.Tally objectrepresenting the final election’s result in plain text, along with aproof of correct decryption from the tally. The SVote contract’ssize is approximately 400 lines.

VII. IMPLEMENTATION & EVALUATION

We implemented a prototype of Chainspace in ∼10K linesof Python and Java code. The implementation consists of twocomponents: a Python contracts environment and a Java node.We have released the code as an open-source project.2

Python Contract Environment. The Python contracts envi-ronment allows developers to write, deploy and test smartcontracts. These are deployed on each node by running thePython script for the contract, which starts a local web servicefor the contract’s checker. The contract’s checker is then calledthough the web service. The environment provides a frameworkto allow developers to write smart contracts with little worryabout the underlying implementation, and provides an auto-generated checker for simple contracts.

Java Node Implementation. The Java node implements ashard replica that accepts incoming transactions from clientsand initiates, and executes, the S-BAC protocol. For BFTconsensus, we use the BFT-SMART [2] Java library—one ofthe very few maintained open source libraries for BFT.

To communicate with Chainspace, end users also run an S-BAC–enabled client. First, she creates a transaction through thePython environments using a smart contract. She then submits

2https://github.com/chainspace/chainspace

1. submit transaction

2. send to Chainspace

USER SIDE SERVER SIDE

core

checker

node

core

checker

node

core

checker

node

core

checker

node

Shard

Client Software

S-BAC client

HTTP API

core

checker

node

core

checker

node

core

checker

node

core

checker

node

Shard

USER

Fig. 5. Diagram illustrating the implementation of a Chainspace system withtwo shards managing four nodes each. The user submits the transaction to itslocal S-BAC client through a built-in HTTP API (arrow 1). Then, this S-BACclient sends the transaction to Chainspace (arrow 2).

the transaction to its S-BAC client through the HTTP API asindicated in Figure 5, that sends the transaction to Chainspaceaccording to the BFT-SMART protocol.

A node is composed of a server divided in two parts: thecore and the checker. To communicate with other nodes, eachnode also contains an S-BAC client. When a transaction isreceived, the core is in charge of verifying that the input objectsand references are active (neither locked nor inactive). Then,the node runs the checker associated with the contract, in anisolated container. (The checker is provided by the contract’screator when the node starts up, and interfaces with the nodethrough an HTTP API.) When the client submits a transactionwith dependencies, the core recursively checks each dependenttransaction first, and the top-level transaction at last (similar todepth-first search algorithm).

Performance Measurements. We evaluated the performancesand scalability of our implementation of Chainspace, throughdeployments on Amazon EC2 containers. We launched up to96 nodes on t2.medium virtual machines, each containing 8 GBof RAM on 2 virtual CPUs and running GNU/Linux Debian8.1. We sent transactions to the network from a Chainspaceclient running on a t2.xlarge virtual machine, containing 16GB of RAM and 4 virtual CPUs, also running GNU/LinuxDebian 8.1. In our tests, we map objects to shards randomlyusing the mapping function φ(o) = id(o) mod K where Kis a constant representing the number of shards and id(o) isthe SHA256 hash of the object.

We first measure the effect of the number of shards ontransaction throughput (Figure 6). The transaction throughputof Chainspace scales linearly with the number of shards: with4 nodes per shard, the number of transactions per second (t/s)increases on average by 22 for 1-input transactions for eachshard added. This is because as inputs are randomly assignedto shards based on their hashes, the transaction processing loadis spread out over a larger number of shards.

Next we investigate the effect of shard size (the numberof nodes per shard) on transaction throughput (Figure 9). Wefix the number of shards to 2, and increase the number ofnodes per shard from 2 to 48. With BFT-SMART configuredfor 3f + 1 fault tolerance, we observe an expected graciousdecrease in transaction throughput: for each node added, thethroughput reduces on average by 1.6 transactions per second.This is because in order for a BFT-SMART node to realiseconsensus for a message, it must receive a result from at least

11

Page 12: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

Fig. 6. The effect of the number of shards on transaction throughput. (Nodesper shard: 4, input-to-shard mapping: random. Repeats: 20.)

f + 1 nodes. Thus, the bottleneck is the latency of the f + 1thnode with the highest response time.

Another factor that can potentially affect transaction through-put is the number of inputs per transaction: the more shardstouched by the transaction inputs, the longer it will take to runS-BAC among all the concerned shards. In Figure 7, we studyhow the number of inputs per transaction affects transactionthroughput. We measure this for 5 shards, varying the numberof inputs per transaction from 1 to 10, and the inputs arerandomly mapped to shards as previously stated. The transactionthroughput decreases asymptotically until it becomes stable ataround 40 transactions per second. This is because S-BAC’smaximum time in processing transactions is capped at the timeit takes to process transactions that touch all the 5 shards.Increasing the number of inputs does not further deterioratethe transaction throughput.

Finally, we measure the client-perceived latency—the timefrom when a client submits a transaction until it receives adecision about whether the transaction has been committed—under varying system loads expressed in terms of transactionsreceived per second. Figure 8 shows the effect of transactionsreceived by the system per second (all 1-input transactions) onclient-perceived latency for 2 shards, each having 4 nodes.Recall from Figure 6 that the average throughput for aChainspace system with similar configuration is 75 1-inputtransactions per second. Consequently, we observe in Figure 9that the increase in latency with varying system loads is smallerfor 20 t/s–60 t/s (average 69 ms), but the values start to getbigger after 60 t/s (average 210 ms). This is when the systemreaches its maximum transaction throughput, causing a backlogof transactions to be processed.

Smart Contract Benchmarks. We evaluate the cost andperformance of some smart contracts described in Section VI-A.We compute the mean (µ) and standard deviation (σ) of theexecution of each procedure (denoted as [g]) and checker(denoted as [c]) in the contracts. Each figure is the resultof 10,000 measured on a dual-core Apple MacBook Pro4.1, 2.7GHz Intel Core i7. The last column indicates the

Fig. 7. The effect of the number of inputs per transaction on transactionthroughput. (Shards: 2, nodes per shard: 4, input-to-shard mapping: random.Repeats: 20.)

Fig. 8. The cumulative distribution function of delay for the client to receive afinal commit or abort response, for varying system load. (Shards: 2, nodes pershard: 4, inputs per transaction: 1, input-to-shard mapping: random. Repeats:5.)

transaction’s size resulting from executing the procedure.All cryptographic operations as digital signatures and zero-knowledge proofs have been implemented using the Pythonlibrary petlib 3, wrapping OpenSSL.

CSCoin—Contract size: ∼200 linesOperation µ [ms] σ [ms] size [B]createAccount [g] 4.845 ± 0.683 512

[c] 0.022 ± 0.005 -authTransfer [g] 4.986 ± 0.684 1114

[c] 5.750 ± 0.474 -

The user needs to generate a signing key pair to create anaccount in the CSCoin contract, which takes about 5 ms.However, verifying the account creation only requires tocheck the transaction’s format, and it is therefore very fast.

3https://github.com/gdanezis/petlib

12

Page 13: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

Fig. 9. The effect of the number of nodes per shard on transaction throughput.(Shards: 2, inputs per transaction: 1, input-to-shard mapping: random. Repeats:20.)

Transferring money is a little more expensive due to the need tosign the amount transferred and the beneficiary, and verifyingthe signature in the checker.

SMet—Contract size: ∼200 linesOperation µ [ms] σ [ms] size [B]createMeter [g] 4.786 ± 0.480 ∼600

[c] 0.060 ± 0.003 -addReading [g] 5.286 ± 0.506 ∼1100

[c] 5.965 ± 0.697 -computeBill [g] 5.043 ± 0.513 ∼1100

[c] 5.870 ± 0.603 -

Similarly to CSCoin, creating a meter requires generating acryptographic key pair which takes about 5 ms, while verifyingthe meter’s creation is faster and only requires checking thetransaction’s format. Adding new readings takes about 5 ms,as the user needs to create a signed commitment of thereadings which requires elliptic curve operations and an ECDSAsignature. Computing the bill takes slightly longer (5.8 ms), andinvolves homomorphic additions, and verifying the bill involveschecking a zero-knowledge proof of the billing calculation.

SVote—Contract size: ∼400 linesOperation µ [ms] σ [ms] size [B]createElection [g] 11.733 ± 1.028 ∼1227

[c] 11.327 ± 0.782 -addVote [g] 14.086 ± 1.043 ∼2758

[c] 28.178 ± 1.433 -tally [g] 253.286 ± 7.793 ∼1264

[c] 11.589 ± 0.937 -

The SVote contract is more expensive than the others sinceit extensively uses zero-knowledge proofs and more advancedcryptography. For simplicity, this smart contract has been testedwith three voters and two options. First of all, creating anew election event requires building a signed homomorphicencryption of the initial value for each option, and a zero-knowledge proof asserting that the encrypted value is zero;this takes roughly 11 ms to generate the transaction and torun the checker. Next, each time a vote is added, the userproves two zero-knowledge statements—one asserting that she

votes for exactly one option and one proving that her vote is abinary value—and computes an ECDSA signature on her vote,which takes about 11 ms and generates a transaction of about2.7 kB. Verifying the signature and the two zero-knowledgeproofs are slower and takes about 30 ms. Finally, tallying is theslowest operation since it requires to decrypt the homomorphicencryption of the votes’ sum.

VIII. LIMITATIONS

Chainspace has a number of limitations, that are beyondthe scope of this work to tackle, and deferred to future work.

The integrity properties of Chainspace rely on all shardsmanaging objects being honest, namely containing at most ffault nodes each. We allow any set of nodes to create a shard.However, this means that the function φ(o) mapping objectsto shards must avoid dishonest shards. Our isolation propertiesensure that a dishonest shard can at worse affect state fromcontracts that have objects mapped to it. Thus, in Chainspace,we opt to allow the contract creator to designate which shardsmanage objects from their contract. This embodies specifictrust assumptions where users have to trust the contract creatorboth for the code (which is auditable) and also for the choiceof shards to involve in transactions—which is also public.

In case one or more shards are malicious, we provide anauditing mechanism for honest nodes in honest shards to detectthe inconsistency and to trace the malicious shard. Throughthe Hash-DAG structure it is also possible to fully audit thehistories of two objects, and to ensure that the validity ruleshold jointly—in particular the double-use rules. However, itis not clear how to automatically recover from detecting suchan inconsistency. Options include: forcing a fork into one ormany consistent worlds; applying a rule to collectively agreethe canonical version; patching past transactions to recoverconsistency; or agree on a minimal common consistent state.Which of those options is viable or best is left as future work.

Checkers involved in validating transactions can be costly.For this reason we allow peers in a shard to accept transactionssubject to a SCCoin payment to the peers. However, this ‘flat’fee is not dependent on the cost or complexity of running thechecker which might be more or less expensive. Etherium [32]instead charges ‘gas’ according to the cost of executing thecontract procedure—at the cost of implementing their ownvirtual machine and language.

The S-BAC protocol ensures correctness in all cases.However, under high contention for the same object the rateof aborted transactions rises. This is expected, since the S-BAC protocol in effect implements a variant of optimisticconcurrency control, that is known to result in aborts underhigh contention. There are strategies for dealing with this in thedistributed systems literature, such as locking objects in someconventional order—however none is immediately applicableto the byzantine setting.

Finally, we present in Section VI-A “payments for pro-cessing transactions” to address DoS through transaction fees.However, this mechanism only offers a partial solutions, sinceoperations with higher costs to the system would need to costmore, and all infrastructure nodes would have to be properincentives to continue participating in the protocols. A throughstudy of such mechanisms is left for future work.

13

Page 14: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

IX. COMPARISONS WITH RELATED WORK

Bitcoin’s underlying blockchain technology suffers fromscalability issues: with a current block size of 1MB and 10minute inter-block interval, throughput is capped at about 7transactions per second, and a client that creates a transactionhas to wait for about 10 minutes to confirm. In contrast,mainstream payment processing companies like Visa confirmtransactions within a few seconds, and have high throughputof over 24,000 transactions per second 4. Reparametrization ofBitcoin—such as Bitcoin-NG—can improve this to a limitedextent up to 27 transactions per second and 12 second latency,respectively [8]. More significant improvement requires afundamental redesign of the blockchain paradigm.

The most comparable system to Chainspace is Om-niLedger [16]—that was developed concurrently—and providesa scalable distributed ledger for a cryptocurrency, and cannotsupport generic smart contracts. OmniLedger assigns nodes(selected using a Sybil-attack resistant mechanism) into shardsamong which state, representing coins, is split. The node-to-shard assignment is done every epoch using a bias-resistantdecentralized randomness protocol [31] to prevent an adversaryfrom compromising individual shards. A block-DAG (DirectedAcyclic Graph) structure is maintained in each shard rather thana single blockchain, effectively creating multiple blockchainsin which consensus of transactions can take place in parallel.Nodes within shards reach consensus through the PBFTprotocol [6] with ByzCoin [15]’s modifications that enableO(n) messaging complexity. In contrast, Chainspace usesBFT-SMART ’s PBFT implementation [30] as a black box,and inherits its O(n2) messaging complexity—however, BFT-SMART can be replaced with any improved PBFT variantwithout breaking any security assumptions.

Similar to Chainspace, OmniLedger uses an atomic commitprotocol to process transactions across shards. However, it usesa different, client-driven approach to achieve it. To commita transaction, the client first sends the transaction to thenetwork. The leader of each shard that is responsible for thetransaction inputs (input shard) validates the transaction andreturns a proof-of-acceptance (or proof-of-rejection) to theclient, and inputs are locked. To unlock those inputs, the clientsends proof-of-accepts to the output shards, whose leadersadd the transaction to the next block to be appended to theblockchain. In case the transaction fails the validation test, theclient can send proof-of-rejection to the input shards to rollback the transaction and unlock the inputs. To avoid denial-of-service, the protocol assumes that clients are incentivizedto proceed to the Unlock phase. Such incentives may existin a cryptocurrency application, where coin owners only canspend them, but do not hold for a generalized platform likeChainspace where objects may have shared ownership. Hence,Chainspace’s atomic commit protocol has the entire shard—rather than a single untrusted client—act as a coordinator. Otherrelated works include improvements to Byzantine consensusfor reduced latency and decentralization 5, but these do notsupport sharding.

4https://usa.visa.com/run-your-business/small-business-tools/retail.html5http://atrium.lib.uoguelph.ca/xmlui/bitstream/handle/10214/9769/

Buchman Ethan 201606 MAsc.pdf, https://www.stellar.org/papers/stellar-consensus-protocol.pdf, https://ripple.com/files/ripple consensus whitepaper.pdf

Elastico [22] scales by partitioning nodes in the network intoa hierarchy of committees, where each committee is responsiblefor managing a subset (shard) of transactions consistentlythrough PBFT. A final committee collates sets of transactionsreceived from committees into a final block and then broadcastsit. At the end of each epoch, nodes are reassigned to committeesthrough proof-of-work. The block throughput scales up almostlinear to the size of the network. However, Elastico cannotprocess multi-shard transactions.

RSCoin [10] is a permissioned blockchain. The centralbank controls all monetary supply, while mintettes (nodesauthorized by the bank) manage subsets of transactions andcoins. Like OmniLedger, communication between mintettestakes place indirectly, through the client—and also relies onthe client to ensure completion of transactions. RSCoin haslow communication overhead, and the transaction throughputscales linearly with the number of mintettes, but cannot supportgeneric smart contracts.

Some systems improve transaction latency by replacing itsprobabilistic guarantees with strong consistency. ByzCoin [15]extends Bitcoin-NG for high transaction throughput. A con-sensus group is organized into a communication tree wherethe most recent miner (the leader) is at the root. The leaderruns an O(n) variant of PBFT (using CoSI) to get all membersto agree on the next microblock. The outcome is a collectivesignature that proves that at least two-thirds of the consensusgroup members witnessed and attested the microblock. A nodein the network can verify in O(1) that a microblock has beenvalidated by the consensus group. PeerConsensus [11] achievesstrong consistency by allowing previous miners to vote onblocks. A Chain Agreement tracks the membership of identitiesin the system that can vote on new blocks. Algorand [24]replaces proof-of-work with strong consistency by proposing afaster graded BFT protocol, that allows for a set of nodes todecide on the next block. A key aspect of Algorand is that thesenodes are selected randomly using algorithimic randomnessbased on input from previously generated blocks. However,none of those systems are designed to support generic smartcontracts.

Some recent systems provide a transparent platform basedon blockchains for smart contracts. Hyperledger Fabric [5] isa permissioned blockchain to setup private infrastructures forsmart contracts. It is designed around the idea of a ‘consortium’blockchain, where a specific set of nodes are designated tovalidate transactions, rather than random nodes in a decentral-ized network. Each smart contract (called chaincode) has itsown set of endorsers that re-execute submitted transactions tovalidate them. A consensus service then orders transactionsand filters out those endorsed by too few. It uses modularconsensus, which is replaceable depending on the requirements(e.g., Apache Kafka or SBFT).

Ethereum [32] provides a decentralized virtual machine,called EVM, for executing smart-contracts. Its main scalabilitylimitation results from every node having to process everytransaction, as Bitcoin. On the other hand, Chainspace’s shardedarchitecture allows for a ledger linearly scalable since onlythe nodes concerned by the transaction—that is, managing thetransaction’s inputs or references—have to process it. Ethereumplans to improve scalability through sharding techniques [4],but their work is still theoretical and is not implemented

14

Page 15: Chainspace: A Sharded Smart Contracts Platform · on which smart contract code and state runs, and any user to access calls to smart contracts. Further, it provides ecosystem features,

or measured. One major difference with Chainspace is thatEthereum’s smart contract are executed by the node, contrarilyto the user providing the outputs of each transaction. Chainspacealso supports smart contracts written in any kind of language aslong as checkers are pure functions, and there are no limitationsfor the code creating transactions. Some industrial systems 6

implement similar functionalities as Chainspace, but withoutany empirical performance evaluation.

In terms of security policy, Chainspace system implementsa platform that enforces high-integrity by embodying a variantof the Clark-Wilson [7], proposed before smart contracts wereheard of. Before the emergence of blockchain-based systems,PeerReview [13] was proposed, a system that allow Byzantinefaults to be irrefutably linked to a faulty node. It works by usingtamper-evident logs based on hashchains, achieving similarproperties to blockchain-based systems.

X. CONCLUSIONS

We presented the design of Chainspace—an open, dis-tributed ledger platform for high-integrity and transparentprocessing of transactions. Chainspace offers extensibilitythough privacy-friendly smart contracts. We presented an in-stantiation of Chainspace by parameterizing it with a number of‘system’ and ‘application’ contracts, along with their evaluation.However, unlike existing smart-contract based systems suchas Ethereum [32], it offers high scalability through shardingacross nodes using a novel distributed atomic commit protocolcalled S-BAC, while offering high auditability. We presentedimplementation and evaluation of S-BAC on a real cloud-based testbed under varying transaction loads and showed thatChainspace’s transaction throughput scales linearly with thenumber of shards by up to 22 transactions per second foreach shard added, handling up to 350 transactions per secondwith 15 shards. As such it offers a competitive alternative toboth centralized and permissioned systems, as well as fullypeer-to-peer, but unscalable systems like Ethereum.

Acknowledgements. George Danezis, Shehar Bano and AlbertoSonnino are supported in part by EPSRC Grant EP/N028104/1 ‘GlassHouses’ and the EU H2020 DECODE project under grant agreementnumber 732546. Mustafa Al-Bassam is supported by a scholarshipfrom The Alan Turing Institute. Many thanks to Daren McGuinnessand Ramsey Khoury for discussions about the Chainspace design.

REFERENCES

[1] P. A. Bernstein, V. Hadzilacos, and N. Goodman. CONCURRENCYCONTROL AND RECOVERY IN DATABASE SYSTEMS. 1987.

[2] A. Bessani, J. a. Sousa, and E. E. P. Alchieri. State machine replicationfor the masses with bft-smart. In Proceedings of the 2014 44thAnnual IEEE/IFIP International Conference on Dependable Systemsand Networks, DSN ’14, 2014.

[3] J. Bootle, A. Cerulli, P. Chaidos, and J. Groth. Efficient zero-knowledgeproof systems. In Foundations of Security Analysis and Design VIII,pages 1–31. Springer, 2016.

[4] V. Buterin, J. Coleman, and M. Wampler-Doty. Notes on scalableblockchain protocols (verson 0.3.2), 2015.

[5] C. Cachin. Architecture of the hyperledger blockchain fabric. In Workshopon Distributed Cryptocurrencies and Consensus Ledgers, 2016.

[6] M. Castro, B. Liskov, et al. Practical byzantine fault tolerance. In OSDI,volume 99, pages 173–186, 1999.

6http://www.rsk.co, https://www.tezos.com/static/papers/position paper.pdf,https://docs.corda.net/ static/corda-technical-whitepaper.pdf

[7] D. D. Clark and D. R. Wilson. A comparison of commercial andmilitary computer security policies. In Security and Privacy, 1987 IEEESymposium on, pages 184–184. IEEE, 1987.

[8] K. Croman, C. Decker, I. Eyal, A. E. Gencer, A. Juels, A. Kosba,A. Miller, P. Saxena, E. Shi, and E. Gun. On scaling decentralizedblockchains. In 3rd Workshop on Bitcoin and Blockchain Research,Financial Cryptography 16, 2016.

[9] G. Danezis, J. Groth, C. Fournet, and M. Kohlweiss. Square spanprograms with applications to succinct nizk arguments. Springer BerlinHeidelberg, 2014.

[10] G. Danezis and S. Meiklejohn. Centrally banked cryptocurrencies. InNetwork and Distributed System Security. The Internet Society, 2016.

[11] C. Decker, J. Seidel, and R. Wattenhofer. Bitcoin meets strong consistency.In Proceedings of the 17th International Conference on DistributedComputing and Networking, ICDCN ’16, 2016.

[12] J. Gray and L. Lamport. Consensus on transaction commit. ACMTransactions on Database Systems (TODS), 31(1):133–160, 2006.

[13] A. Haeberlen, P. Kouznetsov, and P. Druschel. Peerreview: Practicalaccountability for distributed systems. In Proceedings of Twenty-firstACM SIGOPS Symposium on Operating Systems Principles, SOSP ’07,pages 175–188, New York, NY, USA, 2007. ACM.

[14] M. Jawurek, M. Johns, and F. Kerschbaum. Plug-in privacy for smartmetering billing. In Privacy Enhancing Technologies - 11th InternationalSymposium, PETS 2011, Waterloo, ON, Canada, July 27-29, 2011.Proceedings, pages 192–210, 2011.

[15] E. K. Kogias, P. Jovanovic, N. Gailly, I. Khoffi, L. Gasser, and B. Ford.Enhancing bitcoin security and performance with strong consistencyvia collective signing. In 25th USENIX Security Symposium (USENIXSecurity 16), pages 279–296, Austin, TX, 2016. USENIX Association.

[16] E. Kokoris-Kogias, P. Jovanovic, L. Gasser, N. Gailly, and B. Ford.Omniledger: A secure, scale-out, decentralized ledger. IACR CryptologyePrint Archive, 2017:406, 2017.

[17] L. Lamport et al. Paxos made simple. ACM Sigact News, 32(4):18–25,2001.

[18] B. Lampson and D. B. Lomet. Distributed transaction processing usingtwo-phase commit protocol with presumed-commit without log force,Aug. 2 1994. US Patent 5,335,343.

[19] B. Laurie, A. Langley, and E. Kasper. Certificate transparency. Technicalreport, 2013.

[20] L. Lauwers and M. Willekens. Five hundred years of bookkeeping:a portrait of luca pacioli. Tijdschrift voor Economie en Management,39(3):289–304, 1994.

[21] S. Liu, C. Cachin, V. Quema, and M. Vukolic. Xft: practical faulttolerance beyond crashes. CoRR, abs/1502.05831, 2015.

[22] L. Luu, V. Narayanan, C. Zheng, K. Baweja, S. Gilbert, and P. Saxena.A secure sharding protocol for open blockchains. In Proceedings ofthe 2016 ACM SIGSAC Conference on Computer and CommunicationsSecurity, CCS ’16, pages 17–30, New York, NY, USA, 2016. ACM.

[23] T. McConaghy, R. Marques, A. Muller, D. De Jonghe, T. McConaghy,G. McMullen, R. Henderson, S. Bellemare, and A. Granzotto. Bigchaindb:a scalable blockchain database. white paper, BigChainDB, 2016.

[24] S. Micali. Algorand: The efficient and democratic ledger.http://arxiv.org/abs/1607.01341, 2016. Accessed: 2017-02-09.

[25] I. Miers, C. Garman, M. Green, and A. D. Rubin. Zerocoin: Anonymousdistributed e-cash from bitcoin. In Security and Privacy (SP), 2013 IEEESymposium on, pages 397–411. IEEE, 2013.

[26] S. Nakamoto. Bitcoin: A peer-to-peer electronic cash system. 2008.[27] T. P. Pedersen et al. Non-interactive and information-theoretic secure

verifiable secret sharing. In Crypto, volume 91.[28] A. Rial and G. Danezis. Privacy-preserving smart metering. In ISSE 2012

- Securing Electronic Business Processes, Highlights of the InformationSecurity Solutions Europe 2012 Conference, Brussels, Belgium, October23-24, 2012, pages 105–115, 2012.

[29] J. H. Saltzer, D. P. Reed, and D. D. Clark. End-to-end arguments insystem design. ACM Transactions on Computer Systems (TOCS), 2(4).

[30] J. a. Sousa and A. Bessani. From byzantine consensus to bft state machinereplication: A latency-optimal transformation. In Proceedings of the 2012Ninth European Dependable Computing Conference, EDCC ’12, pages37–48, Washington, DC, USA, 2012. IEEE Computer Society.

[31] E. Syta, P. Jovanovic, E. Kokoris-Kogias, N. Gailly, L. Gasser, I. Khoffi,M. J. Fischer, and B. Ford. Scalable bias-resistant distributed randomness.IACR Cryptology ePrint Archive, 2016:1067, 2016.

[32] G. Wood. Ethereum: A secure decentralised generalised transactionledger. Ethereum Project Yellow Paper, 151, 2014.

15