目录
正在加载目录…
正在阅读专栏 分布式共识系统专栏 第 37 篇 · 共 59 篇 · 63%

论文:Practical Byzantine Fault Tolerance(PBFT)

发布于 2026-09-21 10:07 · 最后编辑于 2026-09-21 18:15 · 版本 v2 · 字数 42,216 · 预计阅读 85 分钟 👁 39 次阅读

本篇按 MIT 6.5840 / 6.824 课程资料引用的 1999 年论文《Practical Byzantine Fault Tolerance》整理。每一页保留原始 PDF 页面图;页面图是原文排版、Figure、公式、脚注、benchmark 图表和参考文献的原始副本,下面按原页顺序给出中文译文与必要术语说明。

论文:Practical Byzantine Fault Tolerance(PBFT)

相关文章:6.5840:Lecture 21 Byzantine Fault Tolerance · 6.5840:Lecture 04 Fault-Tolerant Agreement and Paxos · 论文:Raft 可理解的共识算法(扩展版)

TL;DR

  • 问题:节点可能因为 software bug、malicious attack 或 arbitrary Byzantine behavior 而失效;network 也可能丢失、延迟、重复或乱序传递 message。
  • 核心结论:在 n = 3f + 1 个 replica 中,最多 f 个 replica Byzantine faulty 时,PBFT 同时提供 safety 和 liveness;safety 不依赖 synchrony,liveness 只要求最终 message delay 不会无限快地增长。
  • 协议主线:client request → PRE-PREPARE → PREPARE → COMMIT → execution/reply;view change 用来替换失效 primary,checkpoint 用来 garbage collect log 并推进 water mark。
  • 工程优化:normal case 使用 MAC/authenticator,不把 public-key signature 放进每条 message 的 critical path;read-only request 可用单 round-trip,large reply 只由 designated replica 发送。
  • 实验结果:作者实现了 Byzantine-fault-tolerant NFS(BFS);在 Andrew benchmark 上,BFS 比 Digital Unix 的标准 NFS 只慢约 3%。

名词解释

名词含义本文对应物
Byzantine fault节点任意偏离协议,包括发送互相矛盾的 messagePBFT 的 fault model
Primary当前 view 中负责提出 request order 的 replicai = v mod n
Backup当前 view 中除 primary 外的 replica参与 prepare/commit
Viewreplica group 的一个逻辑配置与编号view change 的基本单位
Prepared某 request 已有匹配的 pre-prepare 和 2f 个 prepare进入 commit 的条件
Committed-local本地已经看到足够 commit,可以执行 request本地 execution 条件
Checkpoint某个 sequence number 处 service state 的快照stable checkpoint 证明 log 可截断
Water mark可接受 sequence number 的低、高边界防止 log 无限增长与 primary 选超大编号
Authenticator每个接收 replica 一个 MAC 的向量normal-case message 的认证结构
BFSByzantine-fault-tolerant NFS servicePBFT 的实际 prototype

目录

章节内容
版本与来源固定 PDF、版本、图片和翻译边界
原文页面与逐段翻译14 个 PDF 页面按顺序保留并翻译
机制索引PBFT 的协议对象、优化与实现关系
本篇验收页面、图片、覆盖范围和格式检查

版本与来源

  • 论文标题:Practical Byzantine Fault Tolerance。
  • 作者与机构:Miguel Castro、Barbara Liskov,MIT Laboratory for Computer Science。
  • 发表信息:Proceedings of the Third Symposium on Operating Systems Design and Implementation,New Orleans,February 1999。
  • 官方来源:MIT 6.5840 / 6.824 PBFT paper PDF;本地固定文件为 source/pbft.pdf。
  • PDF 固定信息:14 页,每页 612×792 points;SHA-256:4072e5923a9d113bde62aebfb16f040893c8512ee0c6f7df7ef6ba038882fb51。
  • 附件处理:每页渲染为 1224×1584 PNG,存放于 assets/36 PBFT/,正文以 600 宽度嵌入。Figure、公式、脚注、benchmark 表格和 References 由原页图保留。
  • 翻译边界:双栏 PDF 的物理换行不作为语义断句;以标题、段落、列表、协议步骤、公式、图注和表格为最小翻译单元。PBFT、Byzantine、primary、backup、view、MAC、digest、checkpoint、water mark 等术语保留 English 或中英并列。

原文页面与逐段翻译

第 1 页:Abstract 与 Introduction(上)

pbft p01

Practical Byzantine Fault Tolerance

《实用 Byzantine Fault Tolerance》;作者为 Miguel Castro 和 Barbara Liskov,MIT Laboratory for Computer Science。

Abstract

本文描述一种能够容忍 Byzantine fault 的新 replication algorithm。作者认为,随着 malicious attack 和 software error 越来越常见,Byzantine-fault-tolerant algorithm 会变得越来越重要,因为 faulty node 可能表现出任意行为。

此前的 algorithm 要么假设 synchronous system,要么速度太慢、无法用于实践。本文算法具有实践性:它能在 Internet 这样的 asynchronous environment 中工作,并通过多项重要 optimization,使早期 algorithm 的 response time 提升一个数量级以上。作者使用该算法实现 Byzantine-fault-tolerant NFS service 并测量性能;结果表明,该 service 只比 standard unreplicated NFS 慢 3%。

1 Introduction

Malicious attack 和 software error 正变得越来越普遍。industry 与 government 对 online information service 的依赖增加,使 malicious attack 更有吸引力,也使成功攻击的后果更严重。同时,software 的规模和复杂度增长,导致 software error 数量上升。由于 malicious attack 和 software error 都可能让 faulty node 表现出 Byzantine,即 arbitrary behavior,Byzantine-fault-tolerant algorithm 的重要性不断提高。

本文提出一种新的、实用的 state-machine replication algorithm,用来容忍 Byzantine fault。只要总共 n 个 replica 中同时 faulty 的 replica 不超过 f,其中 n ≥ 3f + 1,该算法就能提供 liveness 和 safety。Liveness 表示 client 最终会收到 reply;safety 表示这些 reply 按照 linearizability [14, 4] 是正确的。算法可在 Internet 这样的 asynchronous system 中工作,并包含多项重要 optimization,使其能够高效运行。

关于能够容忍 Byzantine fault 的 agreement 和 replication technique,已有大量研究(从 [19] 开始)。但早期工作(例如 [3, 24, 10])大多只是证明理论可行,效率不足以实践,或者假设 synchrony——即依赖已知的 message delay 和 process speed 上界。与本文最接近的系统 Rampart [30] 和 SecureRing [16] 虽然面向实践,却依赖 synchrony assumption 才能保证 correctness;在 malicious attack 存在时,这是危险的。攻击者可以延迟 non-faulty node 或它们之间的 communication,直到这些 node 被标记为 faulty 并从 replica group 中排除。这样的 denial-of-service attack 通常比控制一个 non-faulty node 更容易。

本文算法不会受到这类攻击,因为它不依赖 synchrony 来提供 safety。此外,如第 7 节所述,它比 Rampart 和 SecureRing 的性能高一个数量级以上。它只需要一个 message round trip 执行 read-only operation,需要两个 round trip 执行 read-write operation。normal operation 使用基于 message authentication code 的高效 authentication scheme;public-key cryptography 曾被认为是 Rampart 的主要 latency [29] 和 throughput [22] bottleneck,但在本文中只在发生 fault 时使用。

为了评估方法,作者实现了一个 replication library,并用它实现真实 service:支持 NFS protocol 的 Byzantine-fault-tolerant distributed file system。作者使用 Andrew benchmark 评估系统性能;结果表明,normal-case operation 下,该系统只比 Digital Unix kernel 中的 standard NFS daemon 慢 3%。

因此,本文的贡献包括:提出第一个能够在 asynchronous network 中正确存活于 Byzantine fault 的 state-machine replication protocol;提出多项重要 optimization,使 algorithm 性能足够好、可以用于真实系统;实现 Byzantine-fault-tolerant distributed file system;提供量化 replication technique 成本的实验结果。

第 2 页:Introduction(下)、System Model 与 Service Properties(上)

pbft p02

Introduction(续)

本文余下部分安排如下:第 2 节描述 system model,包括 failure assumption;第 3 节说明算法解决的问题并给出 correctness condition;第 4 节描述 algorithm;第 5 节介绍重要 optimization;第 6 节介绍 replication library 及其 Byzantine-fault-tolerant NFS 实现;第 7 节给出实验结果;第 8 节讨论 related work;最后总结工作成果并讨论 future research direction。

2 System Model

本文假设 asynchronous distributed system,node 通过 network 连接。Network 可能无法 deliver message,可能 delay、duplicate message,或以 out-of-order 顺序交付 message。

本文使用 Byzantine failure model:faulty node 可以任意行为,只有下文所述的限制除外。假设 node failure 是 independent 的。若要让这一假设在 malicious attack 下成立,需要采取一些措施:每个 node 可以运行不同的 service code 和 operating system,拥有不同的 root password 与 administrator;可以从同一 code base 产生不同 implementation [28];在 replication degree 较低时,也可以购买不同 vendor 的 operating system。对某些 service,N-version programming——由不同 programmer team 分别生成不同 implementation——也是一种选择。

本文使用 cryptographic technique 防止 spoofing 和 replay,并检测 corrupted message。Message 可以包含 public-key signature [33]、message authentication code [36] 和 collision-resistant hash function 产生的 message digest [32]。记 node i 签名的 message 为 m_i,记 message m 的 digest 为 D(m)。按照常见做法,签名的是 message digest,并将签名附加到 plaintext,而不是直接签名完整 message。所有 replica 都知道其他 replica 的 public key,用来验证 signature。

本文允许非常强的 adversary:它可以协调 faulty node、delay communication,或者 delay correct node,以便对 replicated service 造成最大损害。但假设 adversary 不能无限期地 delay correct node;并且 adversary 及其控制的 faulty node 受到 computational bound 约束,因此以极高概率无法破坏上述 cryptographic technique。例如,adversary 不能产生 non-faulty node 的 valid signature,不能从 digest 计算出被摘要的信息,也不能找到具有相同 digest 的两个 message。本文使用的 cryptographic technique 被认为具备这些性质 [33, 36, 32]。

3 Service Properties(上)

本文 algorithm 可以实现任意 deterministic replicated service。Service 有 state 和若干 operation;operation 不限于简单地读写 state 的某一部分,也可以使用 state 与 operation argument 做任意 deterministic computation。Client 向 replicated service 发 request 来 invoke operation,并 block 等待 reply。

如果 client 和 replica 遵循第 4 节的 algorithm,且 attacker 不能伪造其 signature,则它们是 non-faulty。只要 faulty replica 不超过 f,algorithm 同时提供 safety 和 liveness。

Safety 表示 replicated service 满足 linearizability(对 Byzantine-faulty client 做了修改 [14, 4]):service 的行为等价于一个 centralized implementation,后者一次只 atomic 地执行一个 operation。Safety 需要对 faulty replica 数量设上限,因为 faulty replica 可以任意行为,例如摧毁自己的 state。

无论有多少 faulty client 使用 service,safety 都成立,即使 faulty client 与 faulty replica 串谋:non-faulty client 会以一致的方式观察到 faulty client 执行的全部 operation。特别地,如果 service operation 设计为维护某些 state invariant,faulty client 就不能破坏这些 invariant。

Safety 本身不足以抵御 faulty client。例如在 file system 中,faulty client 仍可以向 shared file 写入 garbage data。本文用 access control 限制 faulty client 能造成的 damage:authenticate client,如果发起 request 的 client 没有 invoke 该 operation 的权限,就拒绝 access。Service 还可以提供修改 client access permission 的 operation。由于 algorithm 保证所有 client 一致地观察 access revocation 的效果,这为从 faulty client attack 中恢复提供了强大机制。

第 3 页:Service Properties(下)、Algorithm 引入与 Client

pbft p03

Service Properties(续)

Algorithm 不依赖 synchrony 来提供 safety,因此必须依赖 synchrony 来提供 liveness;否则它就能在 asynchronous system 中实现 consensus,而这是不可能的 [9]。本文保证:只要 faulty replica 不超过 f,且 message delay d 最终不会无限快地增长,client 就会最终收到 request 的 reply。d 是从 message 第一次发送到 destination 收到 message 之间的时间(假定 sender 会持续 retransmit,直到 message 被收到)。这是一个较弱的 synchrony assumption:只要 network fault 最终得到修复,任何真实 system 很可能都满足它,同时它足以绕过 [9] 的 impossibility result。

本文的 resiliency 是 optimal 的:在最多 f 个 replica faulty 时,要让 asynchronous system 同时提供 safety 与 liveness,最少需要 3f + 1 个 replica [2]。原因是 system 必须在与 2f + 1 个 replica communication 后继续推进,因为可能有 f 个 replica faulty 且不响应;但这 2f + 1 个 response 中仍可能有 f 个来自 faulty replica,因此必须保证 non-faulty response 多于 faulty response。这个 quorum 交集关系正是 n ≥ 3f + 1 的来源。

本文不解决 fault-tolerant privacy:faulty replica 可能向 attacker 泄露信息。一般情况下无法提供 fault-tolerant privacy,因为 service operation 可以使用 argument 和 service state 做任意 computation,replica 必须以 clear text 获得这些信息才能高效执行。对于 service operation 看不见的 argument 或 state 部分,可以使用 secret-sharing scheme [35],即使达到一定 threshold 的 replica 恶意,也能保护 privacy [13];作者计划未来研究这些技术。

4 The Algorithm

本文 algorithm 是 state-machine replication [17, 34] 的一种形式:把 service 建模为 state machine,并在 distributed system 的不同 node 上复制它。每个 state-machine replica 保存 service state 并实现 service operation。Replica 集合记为 R,每个 replica 用 0 到 n - 1 的整数标识。为简单起见,假设 n = 3f + 1,其中 f 是最多可能 faulty 的 replica 数;虽然可以使用多于 3f + 1 个 replica,但额外 replica 只会因为传输更多、更大的 message 而降低 performance,不会提高 resiliency。

Replica 依次经过称为 view 的 configuration。在一个 view 中,一个 replica 是 primary,其余是 backup。View 连续编号;view v 的 primary 是 replica p = v mod n。当 primary 看起来 failed 时,系统执行 view change。Viewstamped Replication [26] 和 Paxos [18] 也使用类似方法容忍 benign fault。

Algorithm 的粗略流程如下:

  1. Client 向 primary 发送 invoke service operation 的 request。
  2. Primary 将 request multicast 给 backups。
  3. Replica 执行 request 并向 client 发送 reply。
  4. Client 等待来自不同 replica、结果相同的 f + 1 个 reply;这就是 operation 的结果。

和所有 state-machine replication technique 一样,replica 必须 deterministic:给定相同 state 和相同 argument,执行 operation 必须得到相同 result;而且所有 replica 必须从相同 initial state 开始。基于这两个条件,algorithm 通过保证 non-faulty replica 即使在 failure 下也能对 request 的 execution 达成 total order,来提供 safety。

下面先描述 algorithm 的简化版本。受篇幅限制,暂不讨论 node 从 fault 中 recovery 的细节,也省略 message retransmission 细节。此处假设 message authentication 使用 digital signature;更高效的 MAC scheme 在第 5 节讨论。完整 algorithm 的 I/O automaton formalization 见 [4]。

4.1 The Client

Client c 通过向 primary 发送 REQUEST message ⟨REQUEST, o, t, c⟩_σc,请求执行 state-machine operation o。Timestamp t 用于保证 client request 的 exactly-once semantics。对 client c 的 request,timestamp 具有 total order;后发出的 request 使用更大的 timestamp,例如可以使用 client local clock 的读数。

Replica 发给 client 的每条 message 都包含当前 view number,让 client 能跟踪 view 和当前 primary。Client 通过 point-to-point message,把 request 发给它认为是当前 primary 的 replica。Primary 使用下一节描述的 protocol,把 request atomic multicast 给所有 backup。

Replica 直接向 client 发送 reply。Reply 形如 ⟨REPLY, v, t, i, r⟩_σi:v 是当前 view number,t 是对应 request 的 timestamp,i 是 replica number,r 是执行 operation 得到的 result。Client 等待来自不同 replica 的 f + 1 个 valid signature;这些 reply 必须具有相同的 v 和 r,然后才接受 result r。因为最多只有 f 个 replica faulty,这样的 result 必然有效。

如果 client 没有及时收到 reply,就把 request broadcast 给所有 replica。若 request 已经处理,replica 只需重新发送 reply;每个 replica 会记住它发给每个 client 的最后一个 reply。若收到 request 的 replica 不是 primary,它会把 request relay 给 primary。若 primary 没有 multicast request,它最终会被足够多的 replica suspect 为 faulty,从而触发 view change。

本文假设 client 在一个 request 完成后才发送下一个 request。不过,也可以允许 client 发出 asynchronous request,同时保留这些 request 之间的 ordering constraint。

第 4 页:Normal-Case Operation(上)

pbft p04

4.2 Normal-Case Operation

每个 replica 的 state 包括 service state、一个记录 replica 已接受 message 的 message log,以及表示 replica 当前 view 的 integer。第 4.3 节会说明如何 truncate log。

Primary p 收到 client request m 后,启动一个将 request atomic multicast 给所有 replica 的 three-phase protocol。除非当前 protocol in progress 的 message 数量超过给定 maximum,否则 primary 立即启动 protocol;超过时将 request buffer 起来,稍后作为 group multicast,以降低 heavy load 下的 message traffic 和 CPU overhead。这类似 transactional system 中的 group commit [11];下面为简单起见忽略该 optimization。

Three phase 分别是 pre-prepare、prepare 和 commit。Pre-prepare 与 prepare 用于在同一 view 内为 request 建立 total order,即使提出 order 的 primary 是 faulty;prepare 与 commit 用于确保在不同 view 中 commit 的 request 仍有一致的 total order。

在 pre-prepare phase,primary 为 request 分配 sequence number n,把带有 digest d = D(m) 的 PRE-PREPARE message multicast 给所有 backup,并把该 message 加入自己的 log。Message 形式是 ⟨PRE-PREPARE, v, n, d⟩_σp,其中 v 是发送该 message 的 view,m 是 client request,d 是 request digest。

Pre-prepare message 不包含完整 request,目的是保持 message 较小。这一点很重要,因为在 view change 中,pre-prepare message 会作为“request 在 view v 中被分配 sequence number n”的 proof。此外,这使得 total-order protocol 与向 replica 传输 request 的 protocol 解耦:小 message 可以使用针对 small message 优化的 transport,大 request 则使用针对 large message 优化的 transport。

Backup 只有在以下条件全部满足时才接受 pre-prepare:request 和 pre-prepare 的 signature 正确,d 确实是 m 的 digest;backup 当前处于 view v;它没有接受过同一 view 与 sequence number、但包含不同 digest 的 pre-prepare;sequence number 位于 low water mark h 与 high water mark H 之间。最后一个条件防止 faulty primary 选择一个非常大的 sequence number、耗尽 sequence-number space;h 与 H 的推进见第 4.3 节。

Backup 接受 PRE-PREPARE 后进入 prepare phase:向其他 replica multicast PREPARE message,并把 pre-prepare 与 prepare 都加入 log;否则什么也不做。包括 primary 在内的 replica,只在 prepare 的 signature 正确、view number 等于当前 view、sequence number 位于 h 与 H 之间时接受 prepare message 并写入 log。

定义 prepared(m, v, n, i):当且仅当 replica i 的 log 中已经有 request m、view v 中 sequence number 为 n 的 pre-prepare,以及来自不同 backup、与该 pre-prepare 匹配的 2f 个 prepare。Replica 通过检查 view、sequence number 和 digest 是否相同,判断 prepare 是否与 pre-prepare 匹配。

Pre-prepare 与 prepare 保证 non-faulty replica 在一个 view 内对 request 达成相同 total order。更精确地说,如果 prepared(m, v, n, i) 为 true,那么对任意 non-faulty replica j 和任意 m'、n',只要 n' ≠ n 或 digest 不同,就不能有 prepared(m', v, n', j) 为 true。

原因是 prepared 需要 2f + 1 个相关 replica,而 n = 3f + 1;两个这样的集合至少有一个 non-faulty replica 交集。若两个不同 request 在同一 view、同一 sequence number 上都 prepared,就至少有一个 non-faulty replica 发送冲突 prepare(primary 对应的 pre-prepare 也算),这违反 non-faulty replica 不发送冲突 message 的性质。Collision-resistant digest 又使两个不同 request 恰好拥有同一 digest 的概率可以忽略。

当 prepared(m, v, n, i) 变为 true 时,replica i 向其他 replica multicast COMMIT,从而进入 commit phase。Replica 只在 commit signature 正确、message view number 等于当前 view、sequence number 位于 h 与 H 之间时接受 commit,并写入 log。

第 5 页:Commit、Execution 与 Garbage Collection

pbft p05

定义两个 predicate。committed(m, v, n) 当且仅当存在一个包含 2f + 1 个 non-faulty replica 的集合,其中每个 replica 都满足 prepared(m, v, n, i)。committed-local(m, v, n, i) 当且仅当 prepared(m, v, n, i) 为 true,并且 replica i 已接受来自不同 replica 的 2f + 1 个 commit(可以包括自己的 commit),这些 commit 与 m 的 pre-prepare 匹配;匹配表示 view、sequence number 和 digest 都相同。

Commit phase 保证如下 invariant:如果某个 non-faulty replica i 的 committed-local(m, v, n, i) 为 true,那么 committed(m, v, n) 也为 true。这个 invariant 与第 4.4 节的 view-change protocol 一起,保证 non-faulty replica 即使在不同 replica 上于不同 view 中 commit,也会对本地 commit 的 request 使用相同 sequence number;并且,任何在 non-faulty replica 上 locally commit 的 request,最终都会在 2f + 1 个或更多 non-faulty replica 上 commit。

当 committed-local(m, v, n, i) 为 true,且 replica i 的 state 已经反映所有 sequence number 小于 n 的 request 的 sequential execution 后,replica 才执行 m。这样可以保证所有 non-faulty replica 以相同 order 执行 request,从而满足 safety。执行完成后,replica 向 client 发送 reply。为保证 exactly-once semantics,replica 丢弃 timestamp 小于它最后一次发给该 client 的 reply 中 timestamp 的 request。

本文不依赖 ordered message delivery,因此 replica 可能 out of order 地 commit request。这没有问题:它会保留 pre-prepare、prepare 和 commit message,直到对应 request 可以执行。

Figure 1:Normal Case Operation

原图展示 primary 没有 fault 时的 normal-case 流程:replica 0 是 primary,replica 3 是 faulty,C 是 client。Client 发送 request 给 primary;primary 发送 pre-prepare;replica 之间传播 prepare 与 commit;最终 client 收到 reply。原图中的四个 replica、消息箭头和 X 标记均由页面图保留。

4.3 Garbage Collection

为了保持 safety,replica 必须把 message 保留在 log 中,直到它知道相关 request 已经被至少 2f + 1 个 non-faulty replica 执行,并且在 view change 中能够向其他 replica 证明这一点。如果某个 replica 漏掉了已经被所有 non-faulty replica 丢弃的 message,就需要传输全部或部分 service state 使它追上进度;因此还需要能证明该 state 正确的 proof。

如果每执行一个 operation 就生成 proof,成本会很高。因此,系统周期性地生成 proof:例如每执行一个 sequence number 可被 100 整除的 request,就生成一次。由这些 request 产生的 state 称为 checkpoint;带有 proof 的 checkpoint 称为 stable checkpoint。

每个 replica 维护若干 logical copy:last stable checkpoint、零个或多个尚未 stable 的 checkpoint,以及 current state。可以使用 copy-on-write 降低保存这些额外 state copy 的空间开销,第 6.3 节会说明实现。

Checkpoint proof 的生成如下:replica i 产生 checkpoint 时,向其他 replica multicast CHECKPOINT message,其中包含 checkpoint 所反映的最后一个 request 的 sequence number n 和 state digest d。每个 replica 在 log 中收集 checkpoint message,直到得到来自不同 replica 的 2f + 1 个 message(可以包括自己的 message),它们对同一个 n 使用相同 digest d。这 2f + 1 个 message 就是 checkpoint correctness proof。

带 proof 的 checkpoint 变成 stable。Replica 随后从 log 中丢弃 sequence number 小于或等于 n 的所有 pre-prepare、prepare 和 commit message,同时丢弃更早的 checkpoint 与 checkpoint message。

生成 proof 是高效的,因为可以使用 incremental cryptography [1] 计算 digest,而且 checkpoint 并不频繁。Checkpoint protocol 还用于推进 low/high water mark:low water mark h 等于最后一个 stable checkpoint 的 sequence number;high water mark H = h + L,其中 L 足够大,使 replica 不会因为等待 checkpoint stable 而停止。例如 checkpoint 每 100 个 request 生成一次时,可以令 L = 200。

第 6 页:View Change 与 Safety

pbft p06

4.4 View Changes

View-change protocol 通过在 primary failed 时允许系统继续推进来提供 liveness。View change 由 timeout 触发,防止 backup 无限等待 request 执行。

如果 backup i 收到 valid request 却尚未执行它,就称 i 正在等待该 request。Backup 在收到 request 且 timer 尚未运行时启动 timer;当它不再等待执行 request 时停止 timer;如果此时仍在等待另一个 request,则重新启动 timer。

如果 backup i 的 timer 在 view v 中过期,它就发起从 view v 转移到 view v + 1 的 view change。它停止接受普通 message,只接受 checkpoint、view-change 和 new-view message,然后向所有 replica multicast VIEW-CHANGE(v + 1, C, P)。其中:C 是 i 已知的最后一个 stable checkpoint 的 sequence number 及其 2f + 1 个 checkpoint message proof;P 是一个集合,对 i prepared 的每个 sequence number n > C,包含一个 valid pre-prepare(不带对应 client message)和 2f 个来自不同 backup、具有相同 view、sequence number 和 request digest 的 matching prepare。

当 view v + 1 的 primary p 从其他 replica 收到 2f 个有效 view-change message,再加上自己的 view-change message 后,它向其他 replica multicast NEW-VIEW(v + 1, V, O)。V 包含 primary 收到的 valid view-change message;O 是一组不带 piggybacked request 的 pre-prepare message。

Primary 按以下步骤计算 O:

  1. 找到 V 中最新 stable checkpoint 的 sequence number min-s,以及 V 中 prepare message 的最高 sequence number max-s。
  2. 对每个 n,其中 min-s < n ≤ max-s,生成 view v + 1 的新 pre-prepare。若 V 中某个 view-change message 的 P 包含 n,则选择其中 view number 最高的 pre-prepare 的 request digest,生成 PRE-PREPARE(v + 1, n, d);否则生成特殊 null request 的 digest。Null request 也会像普通 request 一样走 protocol,但执行时是 no-op;Paxos [18] 也使用类似技术填补 log gap。

Primary 把 O 中的 message 加入 log。若 min-s 大于 primary 最新 stable checkpoint 的 sequence number,它还把 min-s 的 checkpoint stability proof 加入 log,并按第 4.3 节丢弃旧 log 信息。随后 primary 进入 view v + 1,此时可以接受新 view 的 message。

Backup 只有在 new-view signature 正确、其中的 view-change message 对 v + 1 有效、并且 O 的计算正确时才接受 new-view。它使用与 primary 相似的 computation 验证 O,然后把新信息加入 log;对 O 中的每个 message multicast prepare,把 prepare 加入 log,并进入 view v + 1。

之后 protocol 按第 4.2 节继续。Replica 会对 min-s 与 max-s 之间的 message 重新执行 protocol,但使用每个 client 的 last-reply information 避免再次执行已经执行过的 client request。

New-view message 不发送某些 request message 或 stable checkpoint,因此 replica 可能缺少这些信息。它可以向其他 replica 获取。例如,replica i 可以从那些 checkpoint message 在 V 中证明其 correctness 的 replica 之一获得缺失 checkpoint state。因为其中至少有 2f + 1 个 replica 正确,i 总能获得该 checkpoint 或更晚的 certified stable checkpoint。还可以把 state 分 partition,并为每个 partition 记录最后修改它的 request sequence number;这样 catch up 时只需传输落后的 partition,不必传输整个 checkpoint。

4.5 Correctness:Safety(上)

Safety 的关键是:所有 non-faulty replica 必须对 locally commit 的 request 使用一致 sequence number。第 4.2 节已经证明,如果 prepared(m, v, n, i) 为 true,那么任意 non-faulty replica j 都不会对不同 request 或不同 sequence number 得到 prepared。因此,同一 view 内在两个 replica 上 locally commit 的 request 一定使用相同 sequence number。

View-change protocol 保证不同 replica 在不同 view 中 locally commit 时仍保持 sequence-number agreement。假设 request m 在 non-faulty replica 上以 view v、sequence number n local commit,则 committed(m, v, n) 为 true;也就是说,存在一个包含至少 2f + 1 个 non-faulty replica 的集合 S1,使得 S1 中每个 replica 都 prepared m。

Non-faulty replica 在没有收到 view v' 的 new-view message 前不会接受 view v' 的 pre-prepare。任何正确的 new-view(v') 都包含一个至少 2f + 1 个 replica 的集合 S2 发出的正确 view-change message。因为总共有 3f + 1 个 replica,S1 与 S2 至少交集于一个 non-faulty replica。该 replica 的 view-change message 会把先前 view 中的 prepared fact 传播到后续 view,除非 new-view message 带有 sequence number 更高的 stable checkpoint。

在没有更高 checkpoint 的情况下,后续 view 会以相同 sequence number 重新执行 atomic multicast 的三阶段 protocol,且使用新的 view number;这防止先前 view 中为 n 分配的另一个 request commit。在有更高 checkpoint 的情况下,新 view 中的 replica 不会接受低于该 checkpoint sequence number 的 message。两种情况都保证 sequence number n 上 locally commit 的 request 一致。

第 7 页:Liveness、Non-Determinism 与 Optimizations

pbft p07

4.5.2 Liveness

若 replica 无法执行 request,就必须移动到新 view。但需要尽量延长至少 2f + 1 个 non-faulty replica 处于同一 view 的时间,并让这个时间段以 exponential rate 增长,直到某个 requested operation 执行。本文通过三种方式实现。

第一,为避免过早启动 view change,replica multicast VIEW-CHANGE(v + 1) 后,会等待 2f + 1 个针对该 view 的 view-change message,然后才启动一个在时间 T 后过期的 timer。如果 timer 在收到 valid new-view message 或在新 view 执行一个此前尚未执行的 request 之前过期,它就发起更高 view 的 view change;下一次等待 2T,再下一次等待 4T,以此指数增长。

第二,如果 replica 收到一组来自其他 replica、目标 view 高于当前 view 的 2f + 1 个 valid view-change message,它会针对其中最小 view 发送 view-change message,即使自己的 timer 尚未过期。这防止 replica 太晚才开始下一次 view change。

第三,faulty replica 不能通过频繁 view change 阻止 progress。Faulty replica 单独发送 view-change message 不足以造成 view change,因为至少需要 2f + 1 个 replica;它只能在自己成为 primary 时,通过不发送 message 或发送 bad message 触发 view change。但 view v 的 primary 是 v mod n 的 replica,因此同一 faulty primary 不可能连续担任超过 f 个 view 的 primary。

三种技术共同保证 liveness,除非 message delay 无限期地增长得比 timeout period 更快;在真实 system 中这不太可能。

4.6 Non-Determinism

State-machine replica 必须 deterministic,但许多 service 包含某种 non-determinism。例如 NFS 的 time-last-modified 通过读取 server local clock 设置;如果每个 replica 独立读取 local clock,non-faulty replica 的 state 就会 divergence。因此需要机制让所有 replica 选择同一个 value。

一般不能由 client 选择该 value,因为 client 没有足够信息:例如,它不知道自己的 request 会相对于其他 client 的 concurrent request 按什么顺序执行。通常由 primary 独立选择 value,或者根据 backup 提供的 value 选择。

如果 primary 独立选择 non-deterministic value,它把 value 与 associated request 拼接起来,再执行 three-phase protocol,保证 non-faulty replica 对这个 request/value pair 使用同一 sequence number。这样 faulty primary 就不能向不同 replica 发送不同 value 并造成 state divergence。但是 faulty primary 仍可能向所有 replica 发送同一个错误 value。因此,replica 必须仅根据 service state deterministic 地判断 value 是否正确,并在 value 错误时决定如何处理。

该 protocol 对大多数 service(包括 NFS)足够。但有时必须让 replica 参与 value selection,才能满足 service specification。此时可增加一个 phase:primary 获取 backup 提议且经过 authentication 的 value,拼接来自 2f + 1 个 backup 的 value 与 associated request,再为拼接后的 message 启动 three-phase protocol。Replica 根据这 2f + 1 个 value 和自身 state 做 deterministic computation,例如取 median。常见情况下可以优化掉额外 phase:如果 replica 只需要一个“与 local clock 足够接近”的 value,而各 clock 已在某个 delta 内同步,就可以避免该 phase。

5 Optimizations

下列 optimization 改善 normal-case operation 的 performance,同时保持 liveness 和 safety。

5.1 Reducing Communication

第一项 optimization 避免发送大多数 large reply。Client request 指定一个 replica 发送完整 result;其他 replica 只发送 result 的 digest。Client 可以用 digest 检查 result correctness,同时显著降低 large reply 的 network bandwidth 和 CPU cost。如果 designated replica 没有返回正确 result,client 像平常一样 retransmit request,并要求所有 replica 发送完整 reply。

第二项 optimization 把 operation invocation 的 message delay 从 5 次降低到 4 次。只要 request 的 prepared predicate 成立、所有更低 sequence number 的 request 都已执行且已知 commit,replica 就可以在 tentative state 中执行 request,并向 client 发送 tentative reply。Client 等待 2f + 1 个 matching tentative reply;收到后即可保证 request 最终会 commit。若没有收到足够 reply,client retransmit request,等待 f + 1 个 non-tentative reply。

Tentatively 执行的 request 可能因为 view change 而 abort,并被 null request 替代。此时 replica 回滚到 new-view message 中的 last stable checkpoint,或回滚到自己最后一个 checkpointed state,取 sequence number 更高者。

第三项 optimization 改善不修改 service state 的 read-only operation。Client 把 read-only request multicast 给所有 replica。Replica 验证 request authenticated、client 有 access、request 确实 read-only 后,立即在 tentative state 中执行。只有当 tentative state 中反映的所有 request 都已经 commit 后,replica 才发送 reply,以防 client 观察到 uncommitted state。Client 等待来自不同 replica 的 2f + 1 个相同 result。如果 concurrent write 会改变 result,client 可能无法收集足够 reply;此时 retransmission timer 过期后,client 把 request 作为普通 read-write request 重发。

第 8 页:Cryptography

pbft p08

5.2 Cryptography

第 4 节描述的 algorithm 使用 digital signature authenticate 所有 message。但实际实现只对很少发送的 view-change 和 new-view message 使用 digital signature;其他 message 全部使用 message authentication code(MAC)。这消除了早期 system [29, 22] 的主要 performance bottleneck。

相对于 digital signature,MAC 的根本限制是:不能向 third party 证明 message authentic。第 4 节的 algorithm 以及此前用于 state-machine replication 的 Byzantine-fault-tolerant algorithm [31, 16] 都依赖 digital signature 的额外能力。作者通过利用特定 invariant 修改 algorithm 来绕过这个问题,例如:两个 non-faulty replica 不会在同一个 view 和 sequence number 上为不同 request 得到 prepared。修改后的 algorithm 见 [5];这里概述使用 MAC 的主要影响。

MAC 的计算速度比 digital signature 快三个数量级。例如,在 200 MHz Pentium Pro 上,生成一个对 MD5 digest 做 1024-bit modulus RSA signature 需要 43 ms,验证需要 0.6 ms;而作者实现中计算一个 64-byte message 的 MAC 只需 10.3 微秒。其他 public-key cryptosystem(如 elliptic-curve cryptosystem)可以更快生成 signature,但 signature verification 更慢;而本文 algorithm 会多次验证每个 signature。

每个 node(包括 active client)与每个 replica 共享一个 16-byte secret session key。MAC 通过对 message 与 secret key 的 concatenation 应用 MD5 计算。最终 MD5 digest 有 16 bytes,但只使用最低有效的 10 bytes。这样既能减少 MAC 大小,也能提高其抵御某些 attack 的能力 [27]。这是 secret-suffix method [36] 的变体,只要 MD5 保持 collision-resistant,就具有安全性 [27, 8]。

Reply 中的 digital signature 被一个 MAC 替代,因为 reply 只有一个 intended recipient。其他所有 message(client request 也包括在内,但 view change 除外)的 signature 被替换成 MAC vector,称为 authenticator。Authenticator 对 sender 之外的每个 replica 都有一个 entry;该 entry 是使用 sender 与对应 replica 共享的 key 计算出的 MAC。

Authenticator 的 verification time 是 constant,但 generation time 随 replica 数量线性增长。作者认为这不是问题:预期 replica 数量不会很大,而且 MAC 与 digital signature 的 computation speed 差距巨大。Authenticator 也能高效计算:MD5 只对 message 应用一次,随后复用产生的 context,为各个 session key 计算 vector entry。

例如在有 37 个 replica、能够容忍 12 个 simultaneous fault 的系统中,authenticator 的计算速度仍比 1024-bit modulus RSA signature 快两个数量级以上。Authenticator size 随 replica 数量线性增长,但增长很慢,大小约为 30(n - 1) bytes。对于 n < 13 的 configuration(最多容忍 4 个 simultaneous fault),authenticator 比 1024-bit RSA signature 更小;作者预期多数 configuration 都属于这一范围。

第 9 页:Implementation、Replication Library 与 BFS

pbft p09

6 Implementation

本节描述实现。首先介绍可作为任意 replicated service 基础的 replication library;第 6.2 节介绍如何在 library 之上实现 replicated NFS;随后描述 checkpoint 的维护,以及如何高效计算 checkpoint digest。

6.1 The Replication Library

Replication library 的 client interface 只有一个 procedure:invoke。它接收一个 input buffer,buffer 中包含 invoke state-machine operation 的 request。invoke 使用本文 protocol 在 replica 上执行 requested operation,并从各个 replica 的 reply 中选择正确 reply;它返回一个指向 operation result buffer 的 pointer。

Server 侧的 replication code 会向 application 的 server part 发起若干 upcall;application 必须实现这些 procedure:执行 request 的 execute,维护 service state checkpoint 的 make_checkpoint 与 delete_checkpoint,获取指定 checkpoint digest 的 get_digest,以及获取缺失信息的 get_checkpoint 与 set_checkpoint。execute 接收包含 requested operation 的 buffer,执行 operation,并把 result 放进 output buffer;其他 procedure 在第 6.3 和 6.4 节进一步说明。

Node 之间的 point-to-point communication 使用 UDP;replica group 的 multicast 使用 UDP over IP multicast [7]。每个 service 对应一个 IP multicast group,包含所有 replica。两种 communication protocol 都不可靠:它们可能 duplicate 或 lose message,也可能 out of order 地交付 message。

Algorithm 能容忍 out-of-order delivery 并拒绝 duplicate。View change 可以恢复 lost message,但成本高,因此 retransmission 很重要。Normal operation 下,lost-message recovery 由 receiver 驱动:backup 在落后时向 primary 发送 negative acknowledgment,primary 在较长 timeout 后 retransmit pre-prepare message。对 negative acknowledgment 的 reply 还可以包含 stable checkpoint 的一部分和 missing message。View change 期间,replica 持续 retransmit view-change message,直到收到 matching new-view message 或进入更晚的 view。

本文实现的 replication library 当时还没有实现 view change 或 retransmission。这不影响第 7 节实验结果的准确性:algorithm 的其余部分(包括触发 view change 的 timer manipulation)已经完整实现,并且完整 algorithm 已被 formalize 且 correctness 已证明 [4]。

6.2 BFS:Byzantine-Fault-Tolerant File System

作者使用 replication library 实现 BFS,即 Byzantine-fault-tolerant NFS service。Figure 2 展示 BFS architecture。由于没有 Digital Unix kernel 的 source,作者没有修改 kernel NFS client 和 server。

Fault-tolerant NFS service export 的 file system 可以像普通 NFS file system 一样 mount 到 client machine。Application process 不需要修改,通过 kernel 中的 NFS client 与 mounted file system 交互。作者使用 user-level relay process,在 standard NFS client 与 replica 之间中介:relay 接收 NFS protocol request,调用 replication library 的 invoke,再把 result 返回给 NFS client。

Figure 2:Replicated File System Architecture

原图的路径是:Andrew benchmark → kernel NFS client → client-side relay → replication library;随后 request 到达 replica 0 到 replica n,每个 replica 运行 replication library、snfsd 和 kernel VM。原始 architecture 图按原页保留。

每个 replica 运行一个 user-level process,其中包含 replication library 和 NFS V2 daemon,称为 snfsd(simple nfsd)。Replication library 从 relay 接收 request,通过 upcall 与 snfsd 交互,再把 NFS reply 包装成 replication protocol reply,发送回 relay。

snfsd 使用 fixed-size memory-mapped file 实现。所有 file-system data structure——包括 inode、block 和 free list——都位于 mapped file 中。作者依赖 operating system 管理 memory-mapped file page 的 cache,并异步把 modified page 写入 disk。当前实现使用 8 KB block;inode 包含 NFS status information 和 256 bytes data,用于 directory entry、file block pointer 及 symbolic-link text。Directory 和 file 也可以像 Unix 一样使用 indirect block。

第 10 页:BFS Determinism、Checkpoint 与 Performance Setup

pbft p10

BFS 的 deterministic state

为了满足 protocol correctness 的必要条件,所有 state-machine replica 从相同 initial state 开始,并保持 deterministic。Primary 提出 time-last-modified 与 time-last-accessed 的 value;replica 选择 proposed value 与“此前 request 选出的所有 value 的最大值加一”二者中的较大者。BFS 不需要 synchronous write 来实现 NFS V2 protocol semantics,因为它通过 replication 实现 modified data 与 metadata 的 stability [20]。

6.3 Maintaining Checkpoints

每个 replica 维护 current state、若干还不 stable 的 checkpoint,以及最后一个 stable checkpoint。snfsd 直接在 memory-mapped file 中执行 file-system operation,以保持 locality;同时使用 copy-on-write 降低维护 checkpoint 的 space/time overhead。它为 mapped file 中每个 512-byte block 维护一个 copy-on-write bit。

当 replication code 调用 make_checkpoint upcall 时,snfsd 设置所有 copy-on-write bit,并创建一个 volatile checkpoint record。Record 包含 upcall 参数中的 current sequence number 和一个 block list;该 list 保存从 checkpoint 生成后被修改的 block 的旧副本,因此初始为空。Record 还包含 current state 的 digest,digest 计算见第 6.4 节。

在执行 client request 时,如果某个 mapped-file block 被修改,snfsd 检查该 block 的 copy-on-write bit。若 bit 已设置,则把 block 的当前内容和 identifier 保存进最后一个 checkpoint 的 record,然后用新 value 覆盖 block,并清除 bit。

snfsd 一直保留 checkpoint record,直到 replication code 通过 delete_checkpoint upcall 要求丢弃;该 upcall 会在更晚的 checkpoint 变成 stable 时调用。如果 replication code 需要向另一个 replica 发送 checkpoint,就调用 get_checkpoint。获取一个 block 的 value 时,snfsd 先在 stable checkpoint record 中查找,再查找后续 checkpoint record;如果所有 record 都找不到,就返回 current state 中的 value。

Copy-on-write 与最多保留两个 checkpoint 的设计,使维护多个 logical state copy 的 space/time overhead 很低。在第 7 节 Andrew benchmark 中,checkpoint record 平均只有 182 个 block,最大为 500 个 block。

6.4 Computing Checkpoint Digests

snfsd 在 make_checkpoint upcall 中计算 checkpoint state digest。虽然 checkpoint 不频繁,但 state 可能很大,因此必须 incremental 地计算 digest。snfsd 使用称为 AdHash [1] 的 incremental collision-resistant one-way hash function:将 state 划分为 fixed-size block,使用其他 hash function(例如 MD5)计算“block index 与 block value concatenation”的 digest;整个 state 的 digest 是这些 block digest 在某个 large integer 下的 sum。

当前实现使用 copy-on-write 的 512-byte block,并使用 MD5 计算 block digest。为 incrementally 计算 state digest,snfsd 维护一张表,为每个 512-byte block 保存 hash value。该 value 是在上次 checkpoint 时对 block index 和 block value concatenation 应用 MD5 得到的。

make_checkpoint 调用时,snfsd 从相关 checkpoint record 取得上一个 checkpoint state 的 digest D_old。随后对每个 copy-on-write bit 已 reset 的 block,以 block index 和当前 block value 计算新的 MD5 hash;把新 hash 加到 D_old,把旧 hash 减掉,并更新 table。只要每个 checkpoint 修改的 block 数量较少,该过程就高效;Andrew benchmark 中平均每个 checkpoint 只修改 182 个 block。

7 Performance Evaluation(引入)

本节使用两个 benchmark 评估 system:micro-benchmark 与 Andrew benchmark。Micro-benchmark 提供 service-independent 的 replication library 性能评估,测量 invoke null operation 的 latency,即一个什么也不做的 operation。Andrew benchmark 将 BFS 与两种 file system 比较:Digital Unix 的 NFS V2,以及一个去掉 replication、其他部分与 BFS 相同的 file system。

第一组比较通过显示 latency 接近每天实际使用的 commercial system,证明 system 是 practical 的;第二组比较让作者能够在真实 service 的实现中准确测量 algorithm overhead。

7.1 Experimental Setup

实验测量 normal-case behavior,即没有 view change,因为这决定 system performance。

第 11 页:实验环境与 Micro-Benchmark

pbft p11

所有实验使用一个 client、两个 relay process 和四个 replica。四个 replica 可以容忍一个 Byzantine fault;作者认为这一级别的 reliability 足以覆盖大多数 application。Replica 和 client 运行在相同的 DEC 3000/400 Alpha workstation 上:133 MHz Alpha 21064 processor、128 MB memory、Digital Unix 4.0。每个 replica 把 file system 存在 DEC RZ26 disk 上。

所有 workstation 通过 10 Mbit/s switched Ethernet 连接,使用 DEC LANCE Ethernet interface;switch 是 DEC EtherWORKS 8T/TX。实验在 isolated network 上运行。Checkpoint 间隔为 128 个 request,这会让 garbage collection 在实验期间发生多次。Replica 接受的 pre-prepare 最大 sequence number,是最后 stable checkpoint 的 sequence number 加 256。

7.2 Micro-Benchmark

Micro-benchmark 测量 invoke null operation 的 latency。作者实现了两个无 state 的简单 service:都支持带不同大小 argument 和 result 的 null operation,一个使用 replication library,另一个直接使用 UDP、没有 replication。表 1 报告 client 端测得的 read-only 与 read-write response time;每种 operation invocation 计时 10,000 次,运行三个独立 run,并报告三个 run 的 median。Median 偏差始终低于报告值的 0.3%。Operation 用 a/b 表示,其中 a 是 argument size,b 是 result size,单位为 KB。

arg./res. (KB)replicated read-writereplicated read-onlywithout replication
0/03.35 ms(309%)1.62 ms(98%)0.82 ms
4/014.19 ms(207%)6.98 ms(51%)4.62 ms
0/48.01 ms(72%)5.94 ms(27%)4.66 ms

表 1:Micro-benchmark 结果;括号中的 percentage overhead 相对于 unreplicated case。

Replication library 引入的 overhead 来自额外 computation 和 communication。例如 read-write 0/0 operation 的 computation overhead 约为 1.06 ms,其中 0.55 ms 用于 cryptographic operation;其余 1.47 ms 是 communication overhead:library 增加了一个 message round trip,发送更大的 message,并提高每个 node 收到的 message 数量。

Read-only operation 的 overhead 明显更低,因为第 5.1 节 optimization 同时减少 computation 和 communication。例如 read-only 0/0 的 computation overhead 约为 0.43 ms,其中 0.23 ms 用于 cryptographic operation;communication overhead 只有 0.37 ms,因为 read-only protocol 只使用一个 round trip。

对 4/0 与 0/4 operation,relative overhead 更低,因为 replication library 的一大部分 overhead 与 argument/result size 无关。例如 read-write 0/4 中,large reply 只在 network 上传输一次,增加的主要是处理 reply message 的 cryptographic overhead。Read-write 4/0 的 overhead 更高,因为 large request 要在 network 上传输两次,同时增加 request 与 pre-prepare message 的 cryptographic processing cost。

这个 micro-benchmark 代表本文 algorithm 的 worst-case overhead:operation 不做任何 work,而 unreplicated server 提供的 guarantee 很弱。多数 service 需要更强 guarantee,例如 authenticated connection;相对于一个同样提供这些 guarantee 的 server,本文 algorithm 的 relative overhead 会更低。例如,与使用 MAC authentication 的 unreplicated service 相比,replication library 在 read-write 0/0 上的 overhead 只有 243%,read-only 4/0 上为 4%。

作者还估算相对于 Rampart [30] 的粗略 performance gain。Rampart 在 10 Mbit/s Ethernet、4 台 SparcStation 10 上,对 null message 的 multi-RPC latency 为 45 ms。普通 client 调用 state-machine operation 还需增加一次 message delay、一次 RSA signature 和 verification 来 authenticate client,因此 latency 至少为 65 ms。即使将该 latency 除以 DEC 3000/400 与 SparcStation 10 的 SPECint92 rating 比值 1.7,本文 algorithm 对 read-write 与 read-only 0/0 operation 的 latency 仍分别降低超过 10 倍和 20 倍。这个 scaling 估计仍然保守,因为 Rampart latency 的很大一部分来自 network,而且其结果使用了今天不被认为安全的 300-bit modulus RSA signature。

第 12 页:Andrew Benchmark

pbft p12

Rampart 与 SecureRing 没有公开的 performance number;由于 SecureRing 的 algorithm 在 critical path 上有更多 message delay 与 signature operation,它会比 Rampart 更慢。

7.3 Andrew Benchmark

Andrew benchmark [15] 模拟 software-development workload,共有五个 phase:

  1. 递归创建 subdirectory。
  2. 复制 source tree。
  3. 检查 tree 中所有 file 的 status,但不读取 data。
  4. 读取所有 file 的每一个 byte。
  5. 编译并 link file。

作者使用 Andrew benchmark 比较三种 file-system configuration:NFS-std 是 Digital Unix 的 NFS V2 implementation;BFS-nr 与 BFS 相同但没有 replication。BFS-nr 在 client 上运行两个简单 UDP relay,在 server 上运行一个与 snfsd version 连接的 thin veneer,并删除所有 checkpoint-management code。该 configuration 在回复 client 前不会把 modified file-system state 写入 disk,因此不实现 NFS V2 protocol semantics;BFS 与 NFS-std 都实现这些 semantics。

NFS V2 protocol 的 18 个 operation 中,只有 getattr 是 read-only,因为 file 和 directory 的 time-last-accessed attribute 会被本来应该 read-only 的 operation(如 read 与 lookup)设置。因此 read-only optimization 很少能使用。为了展示其影响,作者还运行了一个修改版 BFS benchmark:把 lookup 修改为 read-only。这个修改违反严格的 Unix file-system semantics,但实践中不太可能产生不良影响。

所有 configuration 都在 client workstation 上运行相同 benchmark code,使用 Digital Unix kernel 的 standard NFS client 和相同 mount option。相关 option 包括 UDP transport、4096-byte read/write buffer、允许 asynchronous client write 和允许 attribute caching。

每个 configuration 报告 benchmark 运行 10 次的 mean。Total benchmark time 的 sample standard deviation 始终低于报告值的 2.6%,但前四个 phase 的 individual time 最高可达 14%;这种高 variance 在 NFS-std 中也存在。单个 phase 的 reported mean 估计误差低于 4.5%,total 的估计误差低于 0.8%。

BFS phaseBFS strictread-only lookupBFS-nr
10.55 s(57%)0.47 s(34%)0.35 s
29.24 s(82%)7.91 s(56%)5.08 s
37.24 s(18%)6.45 s(6%)6.11 s
48.77 s(18%)7.87 s(6%)7.41 s
538.68 s(20%)38.38 s(19%)32.12 s
total64.48 s(26%)61.07 s(20%)51.07 s

表 2:Andrew benchmark,BFS 与 BFS-nr;括号为相对于 BFS-nr 的 overhead。

BFS strict 与 BFS-nr 的比较表明,Byzantine fault tolerance 的 overhead 很低:完整 benchmark 只多花 26% 时间。相比之下,client 在 operation 之间、收到 reply 到发出下一个 request 之前所做的 computation,以及 server 执行 operation 的 computation,会稀释 replication overhead。前两个 phase 的 overhead 较高,因为 client 在这两个 phase 中约 40% 的 total time 用于 computation;后三个 phase 中这一比例约为 70%。对 lookup 使用 read-only optimization 后,BFS 相对 BFS-nr 的 overhead 降到 20%,尤其改善前四个 phase。

BFS phaseBFS strictread-only lookupNFS-std
10.55 s(-69%)0.47 s(-73%)1.75 s
29.24 s(-2%)7.91 s(-16%)9.46 s
37.24 s(35%)6.45 s(20%)5.36 s
48.77 s(32%)7.87 s(19%)6.60 s
538.68 s(-2%)38.38 s(-2%)39.35 s
total64.48 s(3%)61.07 s(-2%)62.52 s

表 3:Andrew benchmark,BFS 与 NFS-std;括号为相对于 NFS-std 的差异。

结果表明 BFS 可以实践使用:BFS strict 完成 benchmark 只比 NFS-std 慢 3%,因此可以用 BFS 替换 Digital Unix 的 NFS V2 implementation,而不改变 user 感知到的 latency。带 read-only lookup optimization 的 BFS 甚至比 NFS-std 快 2%。

BFS 相对 NFS-std 的 overhead 并非每个 phase 都相同。两个 BFS version 在 phase 1、2、5 更快,在 phase 3、4 更慢。这是因为 phase 1、2、5 中 client 发出的 synchronous operation 比例较大(21%–40%);这些 operation 要求 NFS implementation 在 reply 前确保 modified file-system state stable。NFS-std 通过写 disk 达到 stability;BFS 像 Harp [20] 一样,通过 replication 以较低 latency 达到 stability。Phase 3、4 中 client 不发出 synchronous operation,因此 NFS-std 比 BFS(以及 BFS-nr)更快。

第 13 页:Related Work 与 Conclusions(上)

pbft p13

此前大多数 replication technique 要么忽略 Byzantine fault,要么假设 synchronous system model(例如 [17, 26, 18, 34, 6, 10])。Viewstamped Replication [26] 与 Paxos [18] 使用带 primary 和 backup 的 view,在 asynchronous system 中容忍 benign fault。容忍 Byzantine fault 则需要更复杂的 protocol:cryptographic authentication、额外的 pre-prepare phase,以及不同的 view-change trigger 和 primary-selection technique。此外,本文 system 的 view change 只用于选择新 primary,从不象 [26, 18] 那样选择一组不同的 replica 来组成 new view。

一些 agreement 和 consensus algorithm 能在 asynchronous system 中容忍 Byzantine fault(例如 [2, 3, 24]),但它们没有提供完整的 state-machine replication solution;而且多数 algorithm 只是为证明 theoretical feasibility 设计,速度太慢,无法实践使用。本文 algorithm 的 normal-case operation 类似 [2] 的 Byzantine agreement algorithm,但后者无法在 primary failure 下继续运行。

与本文最接近的两个 system 是 Rampart [29, 30, 31, 22] 和 SecureRing [16]。它们实现 state-machine replication,但速度比本文 system 慢一个数量级以上;更重要的是,它们依赖 synchrony assumption。两者都必须把 faulty replica 从 group 中排除,才能 progress(例如删除 faulty primary、选举新 primary)和执行 garbage collection。它们依赖 failure detector 判断哪些 replica faulty。

但 failure detector 在 asynchronous system 中不可能准确 [21],它可能把 non-faulty replica 错误归类为 faulty。由于 correctness 要求 group member 中 faulty 的比例小于 1/3,错误分类可能因为移除 non-faulty replica 而破坏 correctness。这还产生一种 attack path:attacker 控制一个 replica,但不改变它任何可检测的行为;然后减慢 correct replica 或它们之间的 communication,直到足够多 replica 被排除出 group。

可以通过延迟把 replica 标记为 faulty,降低 misclassification probability。但要让 probability negligible,delay 必须非常大,这又不可取。例如 primary 实际已经 failed 时,group 必须等待 delay 结束后才能处理 client request。本文 algorithm 不受这一问题影响,因为它从不需要把 replica 从 group 中排除。

Phalanx [23, 25] 使用 quorum replication technique,在 asynchronous system 中实现 Byzantine fault tolerance。它不是 generic state-machine replication,而是提供一个 data repository,支持读写 individual variable 和 acquire lock。它对 read/write operation 提供的 semantics 弱于本文 algorithm:本文可以实现访问任意数量 variable 的 arbitrary operation,而 Phalanx 必须先 acquire、最后 release lock 才能执行这类 operation。

Phalanx 没有公开 performance number,但作者认为本文 algorithm 更快,因为 critical path 中 message delay 更少,并且使用 MAC 而非 public-key cryptography。Phalanx 的方法可能有更好的 scalability potential,因为每个 operation 只由 replica subset 处理;但这种 scalability 很昂贵:容忍 f 个 fault 需要 4f + 1 个 replica;每个 replica 仍需保存一份 state;而且随着 replica 数量 n 增加,每个 replica 的 load 下降很慢,约为 O(1/n)。

9 Conclusions(上)

本文描述了一种新的 state-machine replication algorithm,它能够容忍 Byzantine fault,并且可以在实践中使用:它是第一个能够在 Internet 这样的 asynchronous system 中正确运行的 algorithm,并把此前 algorithm 的 performance 提高了一个数量级以上。

本文还描述了 BFS,即 Byzantine-fault-tolerant NFS implementation。BFS 证明可以用该 algorithm 实现真实 service,同时保持接近 unreplicated service 的 performance;BFS 只比 Digital Unix 的 standard NFS implementation 慢 3%。这种良好 performance 来自若干重要 optimization:用 MAC vector 替换 public-key signature;减少 message 的大小和数量;使用 incremental checkpoint-management technique。

Byzantine-fault-tolerant algorithm 未来重要的一个原因,是它们能让 system 即使发生 software error 也继续正确工作。并非所有 error 都能 survivable:本文方法无法 mask 同时发生在所有 replica 上的 software error;但它可以 mask 在不同 replica 上 independent 发生的 error,包括 nondeterministic software error。后者最 problematic、最持久,也最难检测。事实上,作者在运行 system 时遇到过这样的 software bug,而 algorithm 仍能让 system 正确继续运行。

第 14 页:Conclusions(下)、Acknowledgments 与 References

pbft p14

Conclusions(续)

在进一步改进 system 方面仍有大量工作。一项特别重要的问题是降低实现 algorithm 所需的 resource。可以使用 f 个 witness replica:它们只有在某个 full replica failure 时才参与 protocol,这样有机会减少 full replica 数量。作者还认为可以把 state copy 的数量减少到 2f + 1,但具体细节仍有待解决。

Acknowledgments

作者感谢 Atul Adya、Chandrasekhar Boyapati、Nancy Lynch、Sape Mullender、Andrew Myers、Liuba Shrira 以及 anonymous referee 对论文 draft 提出的有益意见。

References(原文逐条保留并译注)

  1. M. Bellare、D. Micciancio,《A New Paradigm for Collision-free Hashing: Incrementality at Reduced Cost》;Advances in Cryptology – Eurocrypt 97。低成本 incremental collision-free hashing。
  2. G. Bracha、S. Toueg,《Asynchronous Consensus and Broadcast Protocols》;Journal of the ACM,32(4),1995。Asynchronous consensus 与 broadcast。
  3. R. Canetti、T. Rabin,《Optimal Asynchronous Byzantine Agreement》;Hebrew University Technical Report #92-15,1992。Optimal asynchronous Byzantine agreement。
  4. M. Castro、B. Liskov,《A Correctness Proof for a Practical Byzantine-Fault-Tolerant Replication Algorithm》;MIT/LCS/TM-590,1999。PBFT correctness proof。
  5. M. Castro、B. Liskov,《Authenticated Byzantine Fault Tolerance Without Public-Key Cryptography》;MIT/LCS/TM-589,1999。不依赖 public-key cryptography 的 authenticated BFT。
  6. F. Cristian、H. Aghili、H. Strong、D. Dolev,《Atomic Broadcast: From Simple Message Diffusion to Byzantine Agreement》;FTCS,1985。Atomic broadcast 与 Byzantine agreement。
  7. S. Deering、D. Cheriton,《Multicast Routing in Datagram Internetworks and Extended LANs》;ACM TOCS,8(2),1990。IP multicast routing。
  8. H. Dobbertin,《The Status of MD5 After a Recent Attack》;RSA Laboratories’ CryptoBytes,2(2),1996。MD5 attack 后的安全状态。
  9. M. Fischer、N. Lynch、M. Paterson,《Impossibility of Distributed Consensus With One Faulty Process》;JACM,32(2),1985。FLP impossibility result。
  10. J. Garay、Y. Moses,《Fully Polynomial Byzantine Agreement for n ≥ 3t Processors in t + 1 Rounds》;SIAM Journal of Computing,27(1),1998。
  11. D. Gawlick、D. Kinkade,《Varieties of Concurrency Control in IMS/VS Fast Path》;Database Engineering,8(2),1985。Concurrency control 与 group commit 背景。
  12. D. Gifford,《Weighted Voting for Replicated Data》;ACM SOSP,1979。Replicated data 的 weighted voting。
  13. M. Herlihy、J. Tygar,《How to make replicated data secure》;Advances in Cryptology,LNCS 293,1988。Replicated data security。
  14. M. Herlihy、J. Wing,《Axioms for Concurrent Objects》;ACM POPL,1987。Linearizability 的经典来源。
  15. J. Howard et al.,《Scale and performance in a distributed file system》;ACM TOCS,6(1),1988。Andrew benchmark 来源。
  16. K. Kihlstrom、L. Moser、P. Melliar-Smith,《The SecureRing Protocols for Securing Group Communication》;HICSS,1998。SecureRing group communication。
  17. L. Lamport,《Time, Clocks, and the Ordering of Events in a Distributed System》;CACM,21(7),1978。Distributed event ordering。
  18. L. Lamport,《The Part-Time Parliament》;DEC SRC Technical Report 49,1989。Paxos 早期论文。
  19. L. Lamport、R. Shostak、M. Pease,《The Byzantine Generals Problem》;ACM TOPLAS,4(3),1982。Byzantine generals problem。
  20. B. Liskov et al.,《Replication in the Harp File System》;ACM SOSP,1991。Harp replication。
  21. N. Lynch,《Distributed Algorithms》;Morgan Kaufmann,1996。Distributed algorithms textbook。
  22. D. Malkhi、M. Reiter,《A High-Throughput Secure Reliable Multicast Protocol》;CSFW,1996。Secure reliable multicast。
  23. D. Malkhi、M. Reiter,《Byzantine Quorum Systems》;ACM STOC,1997。Byzantine quorum。
  24. D. Malkhi、M. Reiter,《Unreliable Intrusion Detection in Distributed Computations》;CSFW,1997。Unreliable intrusion detection。
  25. D. Malkhi、M. Reiter,《Secure and Scalable Replication in Phalanx》;IEEE SRDS,1998。Phalanx replication。
  26. B. Oki、B. Liskov,《Viewstamped Replication: A New Primary Copy Method to Support Highly-Available Distributed Systems》;ACM PODC,1988。Viewstamped Replication。
  27. B. Preneel、P. Oorschot,《MDx-MAC and Building Fast MACs from Hash Functions》;Crypto 95。由 hash 构建 fast MAC。
  28. C. Pu、A. Black、C. Cowan、J. Walpole,《A Specialization Toolkit to Increase the Diversity of Operating Systems》;ICMAS,1996。提高 OS diversity 的 toolkit。
  29. M. Reiter,《Secure Agreement Protocols》;ACM CCS,1994。Secure agreement。
  30. M. Reiter,《The Rampart Toolkit for Building High-Integrity Services》;LNCS 938,1995。Rampart toolkit。
  31. M. Reiter,《A Secure Group Membership Protocol》;IEEE TSE,22(1),1996。Secure group membership。
  32. R. Rivest,《The MD5 Message-Digest Algorithm》;RFC 1321,1992。MD5 specification。
  33. R. Rivest、A. Shamir、L. Adleman,《A Method for Obtaining Digital Signatures and Public-Key Cryptosystems》;CACM,21(2),1978。RSA signature 与 public-key cryptosystem。
  34. F. Schneider,《Implementing Fault-Tolerant Services Using The State Machine Approach: A Tutorial》;ACM Computing Surveys,22(4),1990。State-machine approach tutorial。
  35. A. Shamir,《How to share a secret》;CACM,22(11),1979。Secret sharing。
  36. G. Tsudik,《Message Authentication with One-Way Hash Functions》;ACM Computer Communications Review,22(5),1992。One-way-hash message authentication。
  37. M. Wiener,《Performance Comparison of Public-Key Cryptosystems》;RSA Laboratories’ CryptoBytes,4(1),1998。Public-key cryptosystem performance comparison。

机制索引

机制论文位置与本专栏其他笔记的连接
n = 3f + 1Sections 2–3Byzantine quorum 与安全性边界;连接 6.5840:Lecture 21 Byzantine Fault Tolerance
State-machine replicationSection 4与 Raft/Paxos 的 replicated state machine 主线对照
PRE-PREPARE / PREPARE / COMMITSection 4.2PBFT normal-case three-phase protocol
prepared / committed-localSections 4.2、4.5从 local evidence 推出全局 commit 的安全条件
Checkpoint / water markSection 4.3log truncation、state transfer 与 recovery
View change / new viewSection 4.4primary failure、liveness、null request 与 log continuity
Tentative executionSection 5.1把普通 invocation 从 5 个 message delay 降到 4 个
Read-only fast pathSection 5.1one-round-trip read 与 concurrent write 冲突处理
MAC authenticatorSection 5.2normal path 避免 public-key signature bottleneck
BFSSection 6PBFT 在 NFS service 上的完整实现与实验
Andrew benchmarkSection 7.3与 standard NFS、unreplicated BFS 的端到端比较

本篇验收

  • [x] 官方 PDF 已固定:14 页,每页 612×792 points。
  • [x] SHA-256 已记录:4072e5923a9d113bde62aebfb16f040893c8512ee0c6f7df7ef6ba038882fb51。
  • [x] 14 个原始页面均渲染为 1224×1584 PNG,并按 600 宽度嵌入。
  • [x] Abstract、Sections 1–9、Figure 1–2、三阶段 normal case、checkpoint、view change、safety/liveness、non-determinism、cryptography、BFS、micro-benchmark、Andrew benchmark、related work、conclusion、acknowledgments 和 37 条 References 均按原页顺序完成译注或由原页图保留。
  • [x] n = 3f + 1、prepared、committed-local、water mark、stable checkpoint、PRE-PREPARE / PREPARE / COMMIT、view change、MAC authenticator 和 BFS 均已覆盖。
  • [x] 术语如 Byzantine、primary、backup、view、digest、MAC、authenticator、checkpoint、water mark、BFS、NFS、AdHash 和 Andrew benchmark 保留 English 或中英并列。
  • [x] 原页图已逐页生成并尺寸校验;翻译层按 14 页原始顺序对应。
← 返回列表
← 上一篇 论文:Secure Untrusted Data Repository(SUNDR) 下一篇 → 论文:Dynamo:Amazon’s Highly Available Key-value Store

评论 (0)

暂无评论,来留下第一条吧。
登录 或 注册 后才能发表评论