If many distributed applications need consensus, can it be offered once, as middleware, instead of being rewritten for each?
Middleware gives heterogeneous applications a common model and a common infrastructure. A distributed ledger is middleware of a new kind: a ledger kept synchronised across unsynchronised nodes. Underneath, a blockchain is state machine replication of a notary service. Hash chains, signatures and consensus make it tamper-evident, accountable and robust to Byzantine peers. Closed systems use classical quorum/leader-based consensus; open ones use competition, such as Proof-of-Work, with probabilistic, eventual consistency. Replicate an interpreter instead and you get universal SMR: users deploy smart contracts, N copies computing as one.
Middleware lies in the middle between the operating system and the applications: vertical layers, with top (middleware-to-application) and bottom (middleware-to-OS) interfaces.
Development is hard, good designers rare, applications ever more complex. Middleware is built once for many applications (affording better designers), provides services, and abstracts from the OS.
Its key feature is interoperability: applications on the same middleware work together. But middleware systems are many and incompatible, and making A-applications work with B-applications is the Enterprise Application Integration (EAI) task, with the emphasis on horizontal communication (application-to-application, middleware-to-middleware). Integration is unavoidable: every project inherits legacy systems and adds features without modifying them. The first casualty is conceptual integrity.
The property of a system of being understandable and explainable through a coherent, limited set of concepts.
Piecemeal growth stays popular (asymptotically cheapest as development time goes to zero). Middleware is an integration technology: to limit conceptual drift it casts a model on heterogeneous applications.
A common model: CORBA, Java RMI, DCOM and OSGi all model a system as network-reachable objects (with differences even there).
A common infrastructure, aiming at actual interoperability, so it handles finer details. Until CORBA 2.0, two vendors' CORBAs did not interoperate.
For infrastructure the key issue is the network effect: the value of a technology grows with the number of its adopters. Hence standards consortia (OMG, FIPA, OSGi, W3C) and players pushing de facto standards. The slides then ask: beyond authentication, authorisation, security and shared resources, what about consensus? Should every application write it from scratch (Ch. 6), or should middleware provide it?
Distributed ledger technology (DLT) refers to the processes and related technologies that enable nodes in a network to securely propose, validate, and record state changes (or updates) to a synchronised ledger that is distributed across the network's nodes.
Where is synchronisation? The ledger is synchronised, whereas nodes and network are not required to be synchronous. So DLT is expected to work as a synchronising layer for the processes, as middleware can be expected to do.
Ledger: information store that keeps records of transactions that are intended to be final, definitive, and immutable. Distributed ledger: ledger shared across a set of DLT nodes and synchronised between them using a consensus mechanism. DLT: technology that enables the operation and use of distributed ledgers.
Open systems rest on shared standards, most generally at the middleware level. ITU (Focus Group on DLT) and ISO (TC 307) produced them, including actors and a reference architecture covering public chains (Ethereum, Bitcoin), private chains (Hyperledger Fabric) and non-blockchain ledgers. Use cases span finance, pharma, medicine, ICT and energy [FG DLT, 2019c]. General benefits:
Specific benefits: transparency and trust among untrusted users, security, disintermediation. ACM has a dedicated journal, Distributed Ledger Technologies.
Blockchain sat in Gartner's Hype Cycle for Emerging Technologies from 2016 and vanishes after 2018, as ITU (2019) and ISO (2020) complete their standards: a sign, for the slides, of maturity and industrial exploitation.
DLT ⊃ BCT (blockchain technology): a blockchain is one way to implement a ledger, and IOTA, Hedera Hashgraph and Corda use none. And blockchain ≠ Bitcoin: the blockchain is a model for distributed, decentralised computation, with diverse implementations, domains and goals; Bitcoin is one implementation, for cryptocurrencies, digitalising and decentralising fiat currency.
A shared, transparent, distributed, append-only ledger tracking the order and timing of transactions: secured by cryptography (hashes, signatures, certificates, encryption); replicated on a P2P network, with no trusted intermediary, making it immutable; updated through consensus, robust to Byzantine failures. Ideal use: a secure hub for mutually-untrusted parties.
✓ input → digest; × digest → input; P(H(x) = H(y) | x ≠ y) ≈ 0; small input change, big digest change. Goal: revealing tampering.
✓ make a key pair, encrypt with one key, decrypt with the other; × decrypt with the wrong key, derive one key from the other. Goals: confidentiality, authenticity, non-repudiation.
EncryptPriv(H(Message)), verified with the public key: authenticity (alleged ≡ actual sender) and integrity.
A hash chain keeps track of a sequence of events: event i goes in block bi, and bi+1 records H(bi), so the sequence cannot be altered unnoticed.
Edit block 1's data or timestamp, then press Attacker rewrites links.
Add timestamps and you get a timestamping service: blocks appended (almost) periodically, possibly several events per block, recording what happened and when. Accept only correctly signed events and you get a notary service: who did what and when, with non-repudiation. The slides' applications:
In general: whenever parties may want to lie about what they did or when. After each block a resulting state can be computed (in the punch-in example, who is inside).
Run as one logically centralised server (validating events, keeping the chain, storing data), even a redundant one, the notary has a single point of trust: its owner may alter the ordering or timing of events, or exclude someone, with no defence. Hence replication:
State machine replication: executing the same (not necessarily finite) state machine over multiple independent (possibly distributed) processors, in parallel, to achieve fault tolerance (to stops, crashes, lies, bugs), availability and reactivity, and data/software replication and untamperability. The replicas form a P2P network with the same observable behaviour and no assumed topology.
Computation is stateless when output depends on input only (functions), stateful when (Input, State) → (Output, State′) (objects). A machine is deterministic if its state depends only on the initial state and the input sequence. Randomisers and concurrency break this, and a deterministic machine plus its environment is still non-deterministic overall [Wegner & Goldin, 1999]. Deterministic stateful machines can be arbitrarily replicated and run concurrently if
All then move through the same states: notary + replication + a ledger class ≈ a simple cryptocurrency. Condition 2 is the bank-account problem of Ch. 2.
| Open-system challenge | Response |
|---|---|
| messages lost, corrupted, reordered, duplicated: how to impose one order? | robust transport (TCP); hashes for integrity |
| no global time: how to share a common time? | reasonable to assume access to UTC through NTP (Ch. 2) |
| CAP [Brewer, 2000]: replicas temporarily cut off? | ∼ eventual consistency |
| Byzantine generals [Lamport et al., 1982]: replicas crash or lie? | ∼ redundancy + BFT consensus |
On CAP (Ch. 5): the blockchain basically chooses P and A. Like NoSQL databases (e.g. MongoDB) it provides eventual consistency, “sooner or later, in finite time”, often governed by probabilistic rules (§7).
Why consensus? Alice and Bob update simultaneously through different replicas; the result depends on order, so replicas must agree on one. Byzantine faults (inconsistent views, deliberate lies) can block agreement: three replicas reach an impasse, a fourth may break it. Bad actors have economic incentives; without BFT a replica can alter ordering, exclude events, or block agreement forever.
A distributed protocol aimed at making an SMR system resistant (i.e. ensuring eventual consistency) to Byzantine failures.
Consensus is impossible under either assumption:
The slides' analogy: UTM : TM = Interpreter : Program = ??? : SMR. Instead of a deterministic program with one business logic (say a bank ledger), replicate an interpreter, a program that executes other programs: Universal State Machine Replication (USMR), whose operations let users deploy, undeploy or invoke programs. Smart-contract-enabled blockchains act as replicated universal state machines (§8).
A clever implementation of an SMR system keeping track of which users own some assets (representations), by means of a replicated ledger, updated through consensus.
Replicas R1…RN store the ledger; clients C1…CM propose updates to any. Users are identified by f(Kpub) (a hash or a CA certificate), their address. Many non-intelligible addresses per user give pseudonymity and decentralisation but invite the Sybil attack; one certified address makes the CA a single point of failure and trust.
SystemState ::= Asset | SystemState ∪ SystemState Asset ::= UserID, AssetStateThe world state is a set of assets with owners; AssetState is application-specific (a balance, custom data). Implementations: account-based (Ethereum), UTXO (Bitcoin), versioned key-value store (Fabric).
TX ::= UserID, Operation, Arguments, SignatureA transaction is a proposed state change. Operations are application-specific, but must at least create and update assets; a cryptocurrency has deposit, Value and transfer, UserID, Value.
A transaction is valid if (i) it is well formed, (ii) the signature matches the issuer address, (iii) the signature certifies its integrity. A valid tx is applied by γ, giving its resulting state:
γ(s, tx) = s′Possibly s ≡ s′ (e.g. insufficient funds). γ(·,·) is the state machine (the program) being replicated.
Blocks are timestamped, hash-linked lists of transactions and (hashes of) their resulting states. A block is a 5-tuple of previous hash, height, timestamp, metadata and transactions:
bi = ( phi, hi, tsi, mi, (txi1, ri1, …, txini, rini) )where rij is the state after txi1…txij.
With bi−1 the replica's last known block, bi is locally valid if
Then Γ executes it, applying its transactions in order through γ: Γ(si−1, bi) = rini ≡ si.
What blocks buy
In general, limn→∞ P[inconsistent(Bi)] = 0: as the number n of successors of block Bi grows, the probability that nodes disagree on its content vanishes.
The first, genesis block is assumed shared by all replicas.
Transaction life-cycle
Block life-cycle · each node, every Δt
Step 4 exists because replicas may be corrupted, or have seen transactions in different orders.
Identity management decides which consensus is possible:
| Permissioned BCT | Permissionless BCT | |
|---|---|---|
| identities | constrained through CAs | any (Kpub, Kpr) |
| consensus | “classical” quorum/leader-based. BFT: PBFT, BFT-SMaRt, HoneyBadgerBFT; non-BFT: Paxos, Raft, ZooKeeper, Chubby | “novel” competition-based: Proof-of-Work, Proof-of-Stake, Proof-of-Elapsed-Time, IOTA Tangle |
| assumptions on N | number of replicas and their IDs | none |
| upper bound on nodes | ∼ 100 / 1000 | virtually ∞ |
| throughput (order) | high, ∼ 1000 TX/s | low, ∼ 10 TX/s |
| consistency | “exact” | probabilistic |
| ideal for | closed multi-administrative organisations | open systems, e.g. cryptocurrencies |
| Sybil attack | solved with CAs | solved with PoW |
In a Sybil attack, an attacker subverts the P2P system by creating a large number of pseudonymous identities, using them to gain a disproportionately large influence. Exposed: systems deciding by majority vote among entities with cheap-to-create IDs.
PBFT [Castro & Liskov, 2002] is the classical answer. An elected leader multicasts each client request; replicas agree in two rounds, prepare and commit; the client waits for f + 1 replies (f = maximum faulty replicas). A suspect leader (timeouts) is replaced by negotiation. The slides' questions: N = 1000 needs order N² messages (all-to-all rounds); fictitious IDs let a Sybil attacker own the quorum. Open systems need something else. Paxos and Raft are in Ch. 6.
Proof-of-Work (PoW), or mining, was conceived against email spam [Back, 2002]; nowadays it endows cryptocurrencies with their value. PoW = computational puzzle + branch resolution strategy.
The computational puzzle
Bitcoin: from bi = (phi, hi, tsi, mi, tx̄i) with mi = 0, while H(bi) ≥ hthreshold, increase mi: a hash starting with enough zeros. Ethereum: the block selects parts of a reproducible ∼1 GiB pseudo-random graph, hashed into the block.
Propagation takes time: while honest replicas adopt a block, another replica, uninformed or malicious, may mine a competitor. That is a branch: several versions of the ledger, an inconsistency. Branches are unavoidable, so each replica applies a local rule to pick the true one; if the majority follows it, all eventually select one branch: eventual consistency. Bitcoin uses the longest chain rule: honest replicas consider the longest chain they heard about first. Branches never grow at the same speed, so one gets longer and the other is abandoned, its blocks becoming orphans. Ethereum uses GHOST, Greedy Heaviest Observed SubTree [Sompolinsky & Zohar, 2013].
Blocks A4 and B4 were mined at once; your payment tx★ is in B4. Mine on either side, or at random.
How likely is an adversary to produce a longer branch faster than everyone else? With r = adversary CP / honest CP (computing power) and n blocks to catch up [Nakamoto, 2008]:
P[n | r] = 1 − Σk=0..n ((nr)k e−nr / k!) · (1 − rn−k)Bitcoin waits nthreshold = 6 blocks, ≈ 1 hour since E[ΔT] = 10 min. The slides: 99.999% secure if the adversary has less than 13% of the total CP.
Set attacker share q and confirmations z; hover the chart for other z.
PoW features
Why would rational, i.e. selfish miners pay to validate others' transactions? Incentives: the winner gets money created ex nihilo by the protocol. Disincentives: attacks like deliberate branching are not prevented but made extremely costly. PoW, value and security are strictly related:
Swan [2015] names three generations: 1 cryptocurrencies, 2 custom assets, 3 smart contracts. The model so far covers 1–2, with expected applications such as online payments in place of PayPal, smart property, unified medical records, non-censurable social media and news, shared balances among companies, public tenders, naming and access control, voting. Generation 3: data is now stored without single points of trust, but who trusts its producers? Software automation just moves trust to developers; we need trustable agents managing assets automatically.
Smart contracts (SC) are stateful, user-defined, reactive, immutable (therefore trustable), deterministic processes executing replicated and expressive computations on the blockchain.
SCs act as intermediaries in multi-party workflows, reducing failures from corrupt or selfish operators. Immutability + inspectability + accountability + replication make them trustworthy with critical assets: “the code is always right, the true history is on the blockchain”, fewer disputes, no arbitration. They lack situatedness: data and computation are totally disembodied [Mariani & Omicini, 2013], like the cloud with no single point of trust. N copies of an SC exist, one per replica, but they always compute as one.
Clients get two operations, deploy and invoke:
Deployment
Invocation
Storage is like an object's fields, code like its methods. γ now creates an SC on deploy, updates its state on invoke, updates both balances on transfer; Γ still executes a block's transactions sequentially. This is the Order-Execute architecture [Androulaki et al., 2018].
What about non-terminating programs? The halting problem forbids filtering them, and open systems cannot assume good behaviour, so long computations must be discouraged. Ethereum uses gas; Hyperledger Fabric the Execute-Order-Validate architecture.
Computation's economics enter SC design, and SCs are not really Turing-complete: quasi-Turing-complete [Wood, 2014].
In Fabric, endorsing peers first execute (simulate) a transaction and return its read/write sets; the ordering service orders the results; every peer validates them before applying. A runaway contract only costs the endorsers.
The slides' Solidity example:
contract Counter {
event Increased(uint oldValue, address cause); // event definition
address owner;
uint value;
function Counter() public { owner = msg.sender; } // constructor
function inc(uint times) public { // API
for (uint i = 0; i < times; i++) {
emit Increased(value++, msg.sender);
}
}
}
On the chain, Alice deploys it; Bob, Dan and Carl call inc; states show value going 0, 3, 5, events emitted; callers pay gas to each block's miner. SCs are expected to mediate money management (bills, insurance, shares), shared governance (DAOs) and supply-chain tracking, e.g. with IoT:
The idea: delegate trust-critical decisions to transparent, trustable software agents.
A common model (a synchronised ledger) and infrastructure over unsynchronised nodes: consensus provided once, as a layer. Middleware economics apply: network effect, standards, General Purpose Technology.
γ is the deterministic machine, transactions its inputs, the genesis block the common initial state, consensus the common input order. Hash chains and signatures add tamper-evidence and accountability.
PBFT needs known identities (else Sybils own the quorum) and its all-to-all rounds cap it near a thousand nodes. PoW ties votes to computing power and assumes nothing on N, at ∼10 TX/s and probabilistic consistency.
A bound on an attacker with share q overtaking from 6 blocks behind: ≈0.02% at 10%, ≈0.1% at 13%, certainty at 50%. It is lim P[inconsistent(Bi)] = 0 made quantitative.
Replicate an interpreter and users can deploy their own programs. Non-termination cannot be ruled out in a Turing-complete language, so Ethereum charges per instruction and aborts past gasLimit: quasi-Turing-completeness.
| Slides | Content | Here |
|---|---|---|
| C4 · Middleware | Definition; why; models I–III; abstract vs concrete; standards; consensus? | §1 |
| C4 · DLT | Definitions; standards; actors; architecture; use cases; benefits; journal; DLT vs BCT | §2 |
| C4 · Expectations | Hype cycle I–IV; blockchain ≠ Bitcoin I–II | §2 |
| C4 · Background | At a glance; crypto tools; hash chains; timestamping; notary; replication I–III | §2, §3 |
| C4 · SMR | Overview; deterministic stateful computation; open-DS issues; CAP; Byzantine faults; consensus | §4 |
| C4 · Universal SMR | UTM : TM = interpreter : program = USMR : SMR | §4 |
| C4 · Main elements | Overview; users; world state; transactions; blocks; life cycles | §5 |
| C4 · Main elements | Consensus & mining I–II; Sybil I–II; PBFT I–II | §6 |
| C4 · Main elements | PoW; longest chain; features; incentives; generations; towards SC | §7 |
| C4 · Smart contracts | Definition; features; run time; updated model; termination; gas | §8 |
| C4 · Examples | Solidity I–II; use cases; SC + IoT I–II | §8 |
| C4 · Issues | Early technology and its seven issues | §9 |