Hyperledger-Fabric-1.0-架构与开发

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

HyperledgerFabric1.0架构与开发华东师范大学数据科学与工程学院邵奇峰shao@zzti.edu.cn2报告提纲IntroductionHyperledgerProjectsHyperledgerFabricArchitectureHyperledgerFabricDevelopment基于区块链的可信仓单平台HyperledgerFabricDeployment3Introduction4区块链(Blockchain)区块链是一种去中心化、去信任、不可篡改、可追溯、多方共同维护的分布式数据库。关系数据库=NoSQL=Blockchain5BitcoinBlock6BitcoinBlock#476522NumberOfTx1932OutputTotal11,824.61691753BTCTransactionFees1.22238693BTCTimestamp2017/7/1911:58Bits402742748Size999.135KBNonce680199806BlockReward12.5BTCHash000000000000000000c03…PreviousBlock00000000000000000136…MerkleRootf6a57b63731929b2ae37…7Transaction8TransactionHowitworks9TraditionalDatabaseRegulatorCarLeasingBusinessNetworkOwnershipTransfer“Inhouse”(ledger)Synchronisation:×Slow×Errorprone×Multipleledgers×Whoownswhat,when,couldgetconfused?1.Manufacturer“Inhouse”(ledger)2.Dealer“Inhouse”(ledger)3.LeasingCompany“Inhouse”(ledger)“Inhouse”(ledger)4.Lessee5.ScrapMerchant“Inhouse”(ledger)1110Blockchain11比特币的局限• LimitedThroughput• SlowTransactionConfirmation• NoSettlementFinality• DesignedforCryptocurrency• PoorGovernance• NoPrivacy12HyperledgerProjects13HyperledgerProjects• SinceDec17,2015• Apachev2License• 36/142China/Members• 8TopProjects• 200+Contributors• 10000+Commits14HyperledgerProjects15HyperledgerFabric• Open-sourcedatDec,2015• ProposedbyIBMandDAH• WritteninGolang• 90+contributors• 5000+commits• Corecode(loc):v0.6:~49k;v1.0:~91k• 1.0isReleasedatJuly111617HyperledgerFabricArchitecture18Architecture1920Ledger(Blocks+States)7 LedgerforFabricv1.0 { asset_name:marble1, owner:”jerry, date:9/6/2016, } Txn Reads[] Writes[] Txn Reads[] Writes[] Txn Reads[] Writes[] Txn Reads[] Writes[] State Database Blockchain (File system) Latest wri*en key/values for use in transac5on simula5on Immutable source of truth Indexes point to block storage loca`on blockNum à block file + offset blockHash à block file + offset txId à block file + offset blockNum:txNumà block file + offset Block index LevelDB (embedded KV DB) ‘Materialized view’ of the blockchain data, organized by key for efficient queries. Two op5ons: • LevelDB (default embedded KV DB) supports keyed queries, composite key queries, key range queries •  CouchDB (external op`on) supports keyed queries, composite key queries, key range queries, plus full data rich queries Beta in v1 History index LevelDB (embedded KV DB) ‘Index’ of the blockchain to track history of a key key:marble1 value: ns:key:blockNum:txNum à []byte{} 21SmartContract(Chaincode)22Consensus-Submission11 How a PBFT Network Works (1/4) – Submission V VL V V N N N N N Non-validaUng peer V ValidaUng peer VL ValidaUng Leader 456 TransacUon submi,ed to network 123 TransacUon submi,ed to network 789 TransacUon submi,ed to network … 789 123 456 … 456 789 123 … 456 123 789 … 123 456 789 23Consensus-Ordering12 How a PBFT Network Works (2/4) – Ordering V VL V V N N N N N Non-validaUng peer V ValidaUng peer VL ValidaUng Leader 456 123 789 … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 Consensus network establishes order as 24Consensus-Execution13 How a PBFT Network Works (3/4) – Execu@on V VL V V N N N N N Non-validaUng peer V ValidaUng peer VL ValidaUng Leader … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 Consensus network establishes order as Δ Δ Δ Δ 25Consensus-Distribution14 How a PBFT Network Works (4/4) – Distribu@on V VL V V N N N N N Non-validaUng peer V ValidaUng peer VL ValidaUng Leader … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 … 123 456 789 Consensus network establishes order as 26ByzantineFault-Tolerant(BFT)• 1989/1998,LamportL.Thepart-timeparliament• 1982,LamportL,ShostakR,PeaseM.TheByzantinegeneralsproblem• 2002,CastroM,LiskovB.PracticalByzantinefaulttoleranceandproactiverecovery• 1999,Proof-of-Work(PoW)27Consensus-PBFTOrdering:Solo,Kafka,SBFT28SimplifiedByzantineFaultTolerance(SBFT)29Fabric1.0DeploymentScenarios25VP0VP1VP2VP3NVPNVPNVPNVPNVPNVPNVPNVPv0.6EOOOOOrdererCCCEECCv1.0MemberServiceCASDKApeercanbeaE&Cphysically.30Architecture31TransactionLifecycle8 LedgerforFabricv1.0 Endorsing Peer (subset of peers) Commijng Peer (all peers) Ordering Service Transac9on Reads[] Writes[] 2) Execute chaincode to simulate proposal in peer • Query State DB for reads • Build RWSet Applica`on (SDK) 4) Submit transac`on (includes RWSet) Transac9on Reads[] Writes[] Transac9on Reads[] Writes[] Transac9on Reads[] Writes[] 7) Validate each transac`on and commit block • Validate endorsement policy (VSCC) • Validate ReadSet versions in State DB (MVCC) • Commit block to blockchain • Commit valid trans to State DB • Commit history index of valid trans to goleveldb 5) Ordering service creates batch (block) of transac`ons Transactionlifecycleandinteractionwithledgers32TransactionFlow33Multi-Channel/Chain34FabricCA35FabricCA• IdentityRegistrationManagement• EnrollmentCert(Ecert)• TransactionCert(Tcert,notsupportedin1.0)36FabricCA(PKI)37BlocktypeBlockstruct{Header*BlockHeaderData*BlockDataMetadata

1 / 75
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功