configtx.yaml是Hyperledger Fabric區塊鏈網絡運維工具configtxgen用于生成通道創世塊或通道交易的配置文件,configtx.yaml的內容直接決定了所生成的創世區塊的內容。本文將給出configtx.yaml的詳細中文說明。
如果需要快速掌握Fabric區塊鏈的鏈碼與應用開發,推薦訪問匯智網的在線互動教程:
- Fabric區塊鏈Java開發詳解
- Fabric區塊鏈NodeJS開發詳解
Capabilities / 通道能力配置
Capabilities段用來定義fabric網絡的能力。這是版本v1.0.0引入的一個新的配置段,當與版本v1.0.x的對等節點與排序節點混合組網時不可使用。
Capabilities段定義了fabric程序要加入網絡所必須支持的特性。例如,如果添加了一個新的MSP類型,那么更新的程序可能會根據該類型識別并驗證簽名,但是老版本的程序就沒有辦法驗證這些交易。這可能導致不同版本的fabric程序中維護的世界狀態不一致。
因此,通過定義通道的能力,就明確了不滿足該能力要求的fabric程序,將無法處理交易,除非升級到新的版本。對于v1.0.x的程序而言,如果在Capabilities段定義了任何能力,即使聲明不需要支持這些能力,都會導致其有意崩潰。
Capabilities:# Global配置同時應用于排序節點和對等節點,并且必須被兩種節點同時支持。# 將該配置項設置為ture表明要求節點具備該能力Global: &ChannelCapabilitiesV1_3: true# Orderer配置僅應用于排序節點,不需考慮對等節點的升級。將該配置項# 設置為true表明要求排序節點具備該能力Orderer: &OrdererCapabilitiesV1_1: true# Application配置僅應用于對等網絡,不需考慮排序節點的升級。將該配置項# 設置為true表明要求對等節點具備該能力Application: &ApplicationCapabilitiesV1_3: true
Organizations / 組織機構配置
Organizations配置段用來定義組織機構實體,以便在后續配置中引用。例如,下面的配置文件中,定義了三個機構,可以分別使用ExampleCom、Org1ExampleCom和Org2ExampleCom引用其配置:
Organizations:- &ExampleComName: ExampleComID: example.comAdminPrincipal: Role.ADMINMSPDir: ./ordererOrganizations/example.com/mspPolicies:Readers:Type: SignatureRule: OR('example.com.member')Writers:Type: SignatureRule: OR('example.com.member')Admins:Type: SignatureRule: OR('example.com.admin')Endorsement:Type: SignatureRule: OR('example.com.member')- &Org1ExampleComName: Org1ExampleComID: org1.example.comMSPDir: ./peerOrganizations/org1.example.com/mspAdminPrincipal: Role.ADMINAnchorPeers:- Host: peer0.org1.example.comPort: 7051Policies:Readers:Type: SignatureRule: OR('org1.example.com.member')Writers:Type: SignatureRule: OR('org1.example.com.member')Admins:Type: SignatureRule: OR('org1.example.com.admin')Endorsement:Type: SignatureRule: OR('org1.example.com.member')- &Org2ExampleComName: Org2ExampleComID: org2.example.comMSPDir: ./peerOrganizations/org2.example.com/mspAdminPrincipal: Role.ADMINAnchorPeers:- Host: peer0.org2.example.comPort: 7051Policies:Readers:Type: SignatureRule: OR('org2.example.com.member')Writers:Type: SignatureRule: OR('org2.example.com.member')Admins:Type: SignatureRule: OR('org2.example.com.admin')Endorsement:Type: SignatureRule: OR('org2.example.com.member')
Orderer / 排序節點配置
Orderer配置段用來定義要編碼寫入創世區塊或通道交易的排序節點參數。
Orderer: &OrdererDefaults# 排序節點類型用來指定要啟用的排序節點實現,不同的實現對應不同的共識算法。# 目前可用的類型為:solo和kafkaOrdererType: soloAddresses:- orderer0.example.com:7050BatchTimeout: 2sBatchSize:MaxMessageCount: 10AbsoluteMaxBytes: 98 MBPreferredMaxBytes: 512 KBMaxChannels: 0Kafka:Brokers:- kafka0:9092- kafka1:9092- kafka2:9092- kafka3:9092Organizations:# 定義本層級的排序節點策略,其權威路徑為 /Channel/Orderer/<PolicyName>Policies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY Admins# BlockValidation配置項指定了哪些簽名必須包含在區塊中,以便對等節點進行驗證BlockValidation:Type: ImplicitMetaRule: ANY Writers# Capabilities配置描述排序節點層級的能力需求,這里直接引用# 前面Capabilities配置段中的OrdererCapabilities配置項Capabilities:<<: *OrdererCapabilities
Channel / 通道配置
Channel配置段用來定義要寫入創世區塊或配置交易的通道參數。
Channel: &ChannelDefaults# 定義本層級的通道訪問策略,其權威路徑為 /Channel/<PolicyName>Policies:Readers:Type: ImplicitMetaRule: ANY Readers# Writes策略定義了調用Broadcast API提交交易的許可規則Writers:Type: ImplicitMetaRule: ANY Writers# Admin策略定義了修改本層級配置的許可規則Admins:Type: ImplicitMetaRule: MAJORITY Admins# Capabilities配置描通道層級的能力需求,這里直接引用# 前面Capabilities配置段中的ChannelCapabilities配置項Capabilities:<<: *ChannelCapabilities
Application / 應用配置
Application配置段用來定義要寫入創世區塊或配置交易的應用參數。
Application: &ApplicationDefaultsACLs: &ACLsDefault# ACLs配置段為系統中各種資源提供默認的策略。# 這里所說的“資源”,可以是系統鏈碼的函數,例如qscc系統鏈碼的GetBlockByNumber方法# 也可以是其他資源,例如誰可以接收區塊事件。# 這個配置段不是用來定義資源或API,而僅僅是定義資源的訪問控制策略# # 用戶可以在通道定義中重寫這些默認策略#---New Lifecycle System Chaincode (_lifecycle) function to policy mapping for access control--## _lifecycle系統鏈碼CommitChaincodeDefinition函數的ACL定義_lifecycle/CommitChaincodeDefinition: /Channel/Application/Writers# _lifecycle系統鏈碼的QueryChaincodeDefinition函數的ACL定義_lifecycle/QueryChaincodeDefinition: /Channel/Application/Readers# _lifecycle系統鏈碼的QueryNamespaceDefinitions函數的ACL定義_lifecycle/QueryNamespaceDefinitions: /Channel/Application/Readers#---Lifecycle System Chaincode (lscc) function to policy mapping for access control---## lscc系統鏈碼的getid函數的ACL定義lscc/ChaincodeExists: /Channel/Application/Readers# lscc系統鏈碼的getdepspec函數的ACL定義lscc/GetDeploymentSpec: /Channel/Application/Readers# lscc系統鏈碼的getccdata函數的ACL定義lscc/GetChaincodeData: /Channel/Application/Readers# lscc系統鏈碼的getchaincodes函數的ACL定義lscc/GetInstantiatedChaincodes: /Channel/Application/Readers#---Query System Chaincode (qscc) function to policy mapping for access control---## qscc系統鏈碼的GetChainInfo函數的ACL定義qscc/GetChainInfo: /Channel/Application/Readers# qscc系統鏈碼的GetBlockByNumber函數的ACL定義qscc/GetBlockByNumber: /Channel/Application/Readers# qscc系統 鏈碼的GetBlockByHash函數的ACL定義qscc/GetBlockByHash: /Channel/Application/Readers# qscc系統鏈碼的GetTransactionByID函數的ACL定義qscc/GetTransactionByID: /Channel/Application/Readers# qscc系統鏈碼GetBlockByTxID函數的ACL定義qscc/GetBlockByTxID: /Channel/Application/Readers#---Configuration System Chaincode (cscc) function to policy mapping for access control---## cscc系統鏈碼的GetConfigBlock函數的ACl定義cscc/GetConfigBlock: /Channel/Application/Readers# cscc系統鏈碼的GetConfigTree函數的ACL定義cscc/GetConfigTree: /Channel/Application/Readers# cscc系統鏈碼的SimulateConfigTreeUpdate函數的ACL定義cscc/SimulateConfigTreeUpdate: /Channel/Application/Readers#---Miscellanesous peer function to policy mapping for access control---## 訪問對等節點上的鏈碼的ACL策略定義peer/Propose: /Channel/Application/Writers# 從鏈碼中訪問其他鏈碼的ACL策略定義peer/ChaincodeToChaincode: /Channel/Application/Readers#---Events resource to policy mapping for access control###---## 發送區塊事件的ACL策略定義event/Block: /Channel/Application/Readers# 發送過濾的區塊事件的ACL策略定義event/FilteredBlock: /Channel/Application/Readers# Organizations配置列出參與到網絡中的機構清單Organizations:# 定義本層級的應用控制策略,其權威路徑為 /Channel/Application/<PolicyName>Policies: &ApplicationDefaultPoliciesReaders:Type: ImplicitMetaRule: "ANY Readers"Writers:Type: ImplicitMetaRule: "ANY Writers"Admins:Type: ImplicitMetaRule: "MAJORITY Admins"LifecycleEndorsement:Type: ImplicitMetaRule: "ANY Endorsement"Endorsement:Type: ImplicitMetaRule: "ANY Endorsement"# Capabilities配置描述應用層級的能力需求,這里直接引用# 前面Capabilities配置段中的ApplicationCapabilities配置項Capabilities:<<: *ApplicationCapabilities
Profiles / 配置入口
Profiles配置段用來定義用于configtxgen工具的配置入口。包含委員會(consortium)的配置入口可以用來生成排序節點的創世區塊。如果在排序節點的創世區塊中正確定義了consortium的成員,那么可以僅使用機構成員名稱和委員會的名稱來生成通道創建請求。
Profiles:# SampleInsecureSolo定義了一個使用Solo排序節點的簡單配置SampleInsecureSolo:<<: *ChannelDefaultsOrderer:<<: *OrdererDefaultsOrganizations:- *ExampleComCapabilities:<<: *OrdererCapabilitiesApplication:<<: *ApplicationDefaultsOrganizations:- *ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY EndorsementConsortiums:SampleConsortium:Organizations:- *Org1ExampleCom- *Org2ExampleCom# SampleInsecureKafka定義了一個使用Kfaka排序節點的配置SampleInsecureKafka:<<: *ChannelDefaultsOrderer:<<: *OrdererDefaultsOrdererType: kafkaAddresses:- orderer0.example.com:7050- orderer1.example.com:7050- orderer2.example.com:7050Organizations:- *ExampleComCapabilities:<<: *OrdererCapabilitiesApplication:<<: *ApplicationDefaultsOrganizations:- *ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY EndorsementConsortiums:SampleConsortium:Organizations:- *ExampleCom- *Org1ExampleCom- *Org2ExampleCom# SampleSingleMSPSolo定義了一個使用Solo排序節點、包含單一MSP的配置SampleSingleMSPSolo:Orderer:<<: *OrdererDefaultsOrganizations:- *ExampleComCapabilities:<<: *OrdererCapabilitiesApplication:<<: *ApplicationDefaultsOrganizations:- *ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY EndorsementConsortiums:SampleConsortium:Organizations:- *ExampleCom- *Org1ExampleCom- *Org2ExampleCom# SampleEmptyInsecureChannel定義了一個不包含成員與訪問控制策略的通道SampleEmptyInsecureChannel:Capabilities:<<: *ChannelCapabilitiesConsortium: SampleConsortiumApplication:Organizations:- *ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY Endorsement# SysTestChannel定義了一個用于測試的通道SysTestChannel:<<: *ChannelDefaultsCapabilities:<<: *ChannelCapabilitiesConsortium: SampleConsortiumApplication:<<: *ApplicationDefaultsOrganizations:- *Org1ExampleCom- *Org2ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY Endorsement# SampleSingleMSPChannel定義了一個僅包含單一成員機構的通道。# 該配置通常與SampleSingleMSPSolo或SampleSingleMSPKafka同時使用SampleSingleMSPChannel:<<: *ChannelDefaultsCapabilities:<<: *ChannelCapabilitiesConsortium: SampleConsortiumApplication:<<: *ApplicationDefaultsOrganizations:- *Org1ExampleCom- *Org2ExampleComCapabilities:<<: *ApplicationCapabilitiesPolicies:Readers:Type: ImplicitMetaRule: ANY ReadersWriters:Type: ImplicitMetaRule: ANY WritersAdmins:Type: ImplicitMetaRule: MAJORITY AdminsLifecycleEndorsement:Type: ImplicitMetaRule: ANY EndorsementEndorsement:Type: ImplicitMetaRule: ANY Endorsement
匯智網原創,轉載請標明出處。
轉載于:https://blog.51cto.com/xxzhi/2384780