algo-blockchain-basics

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Blockchain Fundamentals

区块链基础知识

Overview

概述

A blockchain is a distributed, append-only ledger where blocks of transactions are cryptographically linked. Each block contains: transactions, previous block hash, timestamp, and nonce. Consensus mechanisms (PoW, PoS, BFT) ensure agreement without a central authority. Trade-off: decentralization vs performance.
区块链是一种分布式的、仅可追加的账本,交易区块通过密码学方式相互关联。每个区块包含:交易记录、前一区块哈希值、时间戳和随机数(nonce)。共识机制(PoW、PoS、BFT)确保在没有中央权威机构的情况下达成一致。需要权衡:去中心化与性能。

When to Use

适用场景

Trigger conditions:
  • Evaluating whether blockchain is appropriate for a use case
  • Designing systems requiring distributed trust, immutability, or transparency
  • Understanding blockchain architecture for integration or development
When NOT to use:
  • When a trusted central authority exists and works well (use a database)
  • When performance (thousands of TPS) is the primary requirement
  • When data privacy requires deletion capability (blockchain is append-only)
触发条件:
  • 评估区块链是否适用于某一用例
  • 设计需要分布式信任、不可篡改性或透明度的系统
  • 为集成或开发了解区块链架构
不适用场景:
  • 存在可信赖的中央权威机构且运行良好时(使用数据库即可)
  • 性能(数千TPS)是核心需求时
  • 数据隐私要求具备删除能力时(区块链仅支持追加操作)

Algorithm

算法逻辑

IRON LAW: Blockchain Is Useful ONLY When You Need TRUSTLESS Consensus
If participants trust each other (or trust a central authority), a
traditional database is faster, cheaper, and simpler. Blockchain's
value proposition is: untrusted parties can agree on state without
an intermediary. If trust already exists, blockchain adds overhead
with no benefit. Ask: "Who doesn't trust whom?" before choosing blockchain.
IRON LAW: Blockchain Is Useful ONLY When You Need TRUSTLESS Consensus
If participants trust each other (or trust a central authority), a
traditional database is faster, cheaper, and simpler. Blockchain's
value proposition is: untrusted parties can agree on state without
an intermediary. If trust already exists, blockchain adds overhead
with no benefit. Ask: "Who doesn't trust whom?" before choosing blockchain.

Phase 1: Input Validation

阶段1:输入验证

Assess use case against blockchain decision criteria: multiple untrusting writers? Need for immutability? No trusted central party? Public verifiability required? Gate: At least 3 of 4 criteria met to justify blockchain.
根据区块链决策标准评估用例:是否存在多个互不信任的写入方?是否需要不可篡改性?是否没有可信赖的中央主体?是否需要公开可验证性? 准入门槛: 至少满足4项标准中的3项,才具备使用区块链的合理性。

Phase 2: Core Algorithm

阶段2:核心算法

Block structure:
  1. Transactions are grouped into blocks
  2. Each block header contains: previous hash, Merkle root of transactions, timestamp, nonce
  3. Hash of block header links it to previous block (chain)
  4. Modifying any past block invalidates all subsequent hashes
Consensus mechanisms:
  • PoW (Proof of Work): miners compete to solve hash puzzle. Energy-intensive, secure.
  • PoS (Proof of Stake): validators stake tokens. Energy-efficient, relies on economic incentives.
  • BFT (Byzantine Fault Tolerance): voting-based, fast finality, requires known validator set.
区块结构:
  1. 交易被分组到区块中
  2. 每个区块头包含:前一区块哈希值、交易默克尔根、时间戳、随机数
  3. 区块头的哈希值将其与前一区块关联(形成链)
  4. 修改任何历史区块都会使后续所有哈希值失效
共识机制:
  • PoW(工作量证明):矿工竞争解决哈希谜题,能耗高但安全性强。
  • PoS(权益证明):验证者质押代币,能耗低,依赖经济激励。
  • BFT(拜占庭容错):基于投票机制,最终确认速度快,需要已知的验证者集合。

Phase 3: Verification

阶段3:验证

Check: is the use case genuinely multi-party with trust deficits? Would a simpler solution (shared database, digital signatures) suffice? Gate: Blockchain justified, appropriate consensus mechanism selected.
检查:该用例是否真的涉及多方且存在信任缺口?更简单的解决方案(共享数据库、数字签名)是否足够? 准入门槛: 确认区块链具备使用合理性,并选定合适的共识机制。

Phase 4: Output

阶段4:输出

Return architecture recommendation with trade-off analysis.
返回包含权衡分析的架构建议。

Output Format

输出格式

json
{
  "recommendation": {"use_blockchain": true, "type": "permissioned", "consensus": "PBFT", "platform": "Hyperledger Fabric"},
  "trade_offs": {"decentralization": "medium", "throughput_tps": 3000, "finality_seconds": 2, "energy": "low"},
  "metadata": {"use_case": "supply chain provenance", "participants": 5, "trust_level": "low"}
}
json
{
  "recommendation": {"use_blockchain": true, "type": "permissioned", "consensus": "PBFT", "platform": "Hyperledger Fabric"},
  "trade_offs": {"decentralization": "medium", "throughput_tps": 3000, "finality_seconds": 2, "energy": "low"},
  "metadata": {"use_case": "supply chain provenance", "participants": 5, "trust_level": "low"}
}

Examples

示例

Sample I/O

输入输出示例

Input: 5 companies tracking seafood provenance from boat to restaurant Expected: Permissioned blockchain recommended (known participants, no trust, need immutable audit trail). Platform: Hyperledger Fabric or similar.
输入: 5家企业追踪海鲜从渔船到餐厅的溯源信息 预期输出: 推荐使用许可链(已知参与方、互不信任、需要不可篡改的审计轨迹)。平台:Hyperledger Fabric或同类产品。

Edge Cases

边缘案例

InputExpectedWhy
Single company internal useDon't use blockchainTrust already exists internally
Need to delete data (GDPR)Blockchain problematicImmutability conflicts with right to erasure
Public transparency requiredPublic/consortium chainPermissionless or hybrid
输入预期输出原因
单一企业内部使用不使用区块链企业内部已存在信任基础
需要删除数据(符合GDPR要求)区块链不适用不可篡改性与删除权存在冲突
需要公开透明度公链/联盟链无许可或混合架构

Gotchas

注意事项

  • Blockchain ≠ cryptocurrency: Blockchain is the technology; cryptocurrency is one application. Many blockchain use cases have nothing to do with tokens.
  • Immutability is a spectrum: "Permissioned" blockchains can be rewritten by consortium agreement. True immutability only exists in large public chains.
  • Oracle problem: Blockchain guarantees integrity of data ON the chain. It cannot guarantee the accuracy of data ENTERING the chain from the real world. Garbage in = immutable garbage.
  • Scalability trilemma: Decentralization, security, scalability — pick two. No blockchain optimizes all three simultaneously.
  • Regulatory uncertainty: Legal status of blockchain records, smart contracts, and tokens varies by jurisdiction. Consult legal before production deployment.
  • 区块链 ≠ 加密货币:区块链是底层技术;加密货币是其应用之一。许多区块链用例与代币无关。
  • 不可篡改性是相对的:“许可链”可通过联盟协议重写记录。真正的不可篡改性仅存在于大型公链中。
  • 预言机问题:区块链仅能保证链上数据的完整性,无法保证从现实世界输入链上的数据的准确性。错误输入会产生不可篡改的错误结果。
  • 可扩展性三元悖论:去中心化、安全性、可扩展性——三者不可兼得,没有区块链能同时优化这三个维度。
  • 监管不确定性:区块链记录、智能合约和代币的法律地位因地区而异。上线前请咨询法务人员。

References

参考资料

  • For consensus mechanism comparison, see
    references/consensus-comparison.md
  • For blockchain decision framework, see
    references/decision-framework.md
  • 共识机制对比,请查看
    references/consensus-comparison.md
  • 区块链决策框架,请查看
    references/decision-framework.md