Configtx.yaml is a Hyperledger Fabric block chain network operation and maintenance tool configtxgen used to generate channel creation blocks or channel transactions configuration files. The content of configtx.yaml directly determines the content of the generated generation blocks. This article will give a detailed Chinese description of configtx. yaml.
If you need to quickly grasp the chain code and application development of Fabric block chain, we recommend an online interactive tutorial to visit Huizhi.
Capabilities/Channel Capacity Configuration
The Capabilities section is used to define the capabilities of a fabric network. This is a new configuration segment introduced by version v1.0.0, which is not available when mixed with peer and sorting nodes of version v1.0.x.
The Capabilities section defines the features that a fabric program must support in order to join the network. For example, if a new MSP type is added, the updated program may identify and verify signatures based on that type, but the old version of the program cannot verify these transactions. This may lead to inconsistencies in the world state maintained in different versions of fabric programs.
Therefore, by defining the ability of the channel, it is clear that fabric s that do not meet the ability requirements will not be able to handle Transactions unless upgraded to a new version. For v1.0.x programs, if any capabilities are defined in the Capabilities section, even if it is declared that they do not need to be supported, it will cause them to crash intentionally.
Capabilities: # Global configuration is applied to both sorting and peer nodes, and must be supported by both nodes. # Setting this configuration item to ture indicates that the node is required to have this capability Global: &ChannelCapabilities V1_3: true # Orderer configuration is only applied to sorting nodes, without considering peer upgrade. Configuration item # Setting true indicates that the sorting node is required to have this capability Orderer: &OrdererCapabilities V1_1: true # Application configuration is only applied to peer-to-peer networks without considering the upgrade of sorted nodes. Configuration item # Setting true indicates that peer nodes are required to have this capability Application: &ApplicationCapabilities V1_3: true
Organizations/Organization configuration
The Organizations configuration section is used to define organizational entities for reference in subsequent configurations. For example, in the following configuration file, three institutions are defined that can be referenced using ExampleCom, Org1ExampleCom, and Org2ExampleCom, respectively:
Organizations: - &ExampleCom Name: ExampleCom ID: example.com AdminPrincipal: Role.ADMIN MSPDir: ./ordererOrganizations/example.com/msp Policies: Readers: Type: Signature Rule: OR('example.com.member') Writers: Type: Signature Rule: OR('example.com.member') Admins: Type: Signature Rule: OR('example.com.admin') Endorsement: Type: Signature Rule: OR('example.com.member') - &Org1ExampleCom Name: Org1ExampleCom ID: org1.example.com MSPDir: ./peerOrganizations/org1.example.com/msp AdminPrincipal: Role.ADMIN AnchorPeers: - Host: peer0.org1.example.com Port: 7051 Policies: Readers: Type: Signature Rule: OR('org1.example.com.member') Writers: Type: Signature Rule: OR('org1.example.com.member') Admins: Type: Signature Rule: OR('org1.example.com.admin') Endorsement: Type: Signature Rule: OR('org1.example.com.member') - &Org2ExampleCom Name: Org2ExampleCom ID: org2.example.com MSPDir: ./peerOrganizations/org2.example.com/msp AdminPrincipal: Role.ADMIN AnchorPeers: - Host: peer0.org2.example.com Port: 7051 Policies: Readers: Type: Signature Rule: OR('org2.example.com.member') Writers: Type: Signature Rule: OR('org2.example.com.member') Admins: Type: Signature Rule: OR('org2.example.com.admin') Endorsement: Type: Signature Rule: OR('org2.example.com.member')
Orderer/Sort Node Configuration
The Orderer configuration section defines the sort node parameters to be coded into Genesis blocks or channel transactions.
Orderer: &OrdererDefaults # The sort node type is used to specify the sort node implementation to be enabled, and different implementations correspond to different consensus algorithms. # Currently available types are solo and kafka OrdererType: solo Addresses: - orderer0.example.com:7050 BatchTimeout: 2s BatchSize: MaxMessageCount: 10 AbsoluteMaxBytes: 98 MB PreferredMaxBytes: 512 KB MaxChannels: 0 Kafka: Brokers: - kafka0:9092 - kafka1:9092 - kafka2:9092 - kafka3:9092 Organizations: # Define the ranking node policy at this level, whose authoritative path is / Channel / Orderer /< PolicyName > Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins # The BlockValidation configuration entry specifies which signatures must be included in the block for peer verification BlockValidation: Type: ImplicitMeta Rule: ANY Writers # Capabilities configuration describes the capability requirements at the ranking node level, which are directly referenced here # The Orderer Capabilities configuration item in the previous Capabilities configuration section Capabilities: <<: *OrdererCapabilities
Channel/Channel Configuration
The Channel configuration section defines channel parameters to be written to Genesis blocks or to configure transactions.
Channel: &ChannelDefaults # Define the channel access policy at this level with the authoritative path of / Channel /< PolicyName > Policies: Readers: Type: ImplicitMeta Rule: ANY Readers # Writes policy defines licensing rules for submitting transactions by calling Broadcast API Writers: Type: ImplicitMeta Rule: ANY Writers # The Admin policy defines permission rules for modifying the configuration at this level Admins: Type: ImplicitMeta Rule: MAJORITY Admins # Capabilities configuration describes the capability requirements at the channel level, which is directly referenced here # Channel Capabilities configuration items in the previous Capabilities configuration section Capabilities: <<: *ChannelCapabilities
Application/Application Configuration
The Application configuration section defines application parameters to be written to Genesis blocks or configuration transactions.
Application: &ApplicationDefaults ACLs: &ACLsDefault # The ACLs configuration section provides default policies for various resources in the system. # The "resource" here can be a function of system chain code, such as the GetBlockByNumber method of qscc system chain code. # It can also be other resources, such as who can receive block events. # This configuration segment is not used to define resources or API s, but simply to define access control policies for resources. # # Users can override these default policies in channel definitions #---New Lifecycle System Chaincode (_lifecycle) function to policy mapping for access control--# # _ ACL Definition of CommitChaincode Definition Function of lifecycle System Chain Code _lifecycle/CommitChaincodeDefinition: /Channel/Application/Writers # _ ACL Definition of Query Chaincode Definition Function of lifecycle System Chain Code _lifecycle/QueryChaincodeDefinition: /Channel/Application/Readers # _ ACL Definition of QueryNamespace Definitions Function of lifecycle System Chain Code _lifecycle/QueryNamespaceDefinitions: /Channel/Application/Readers #---Lifecycle System Chaincode (lscc) function to policy mapping for access control---# # ACL Definition of geted Function of lscc System Chain Code lscc/ChaincodeExists: /Channel/Application/Readers # ACL Definition of getdepspec Function of lscc System Chain Code lscc/GetDeploymentSpec: /Channel/Application/Readers # ACL Definition of getccdata Function of lscc System Chain Code lscc/GetChaincodeData: /Channel/Application/Readers # ACL Definition of getchaincodes Function of lscc System Chain Code lscc/GetInstantiatedChaincodes: /Channel/Application/Readers #---Query System Chaincode (qscc) function to policy mapping for access control---# # ACL Definition of GetChainInfo Function of Chain Code in qscc System qscc/GetChainInfo: /Channel/Application/Readers # ACL Definition of GetBlockByNumber Function of Chain Code in qscc System qscc/GetBlockByNumber: /Channel/Application/Readers # ACL Definition of GetBlockByHash Function of Chain Code in qscc System qscc/GetBlockByHash: /Channel/Application/Readers # ACL Definition of GetTransactionByID Function of qscc System Chain Code qscc/GetTransactionByID: /Channel/Application/Readers # ACL Definition of GetBlockByTxID Function of qscc System Chain Code qscc/GetBlockByTxID: /Channel/Application/Readers #---Configuration System Chaincode (cscc) function to policy mapping for access control---# # ACl Definition of GetConfigBlock Function for Chain Code of cscc System cscc/GetConfigBlock: /Channel/Application/Readers # ACL Definition of GetConfigTree Function of Chain Code of cscc System cscc/GetConfigTree: /Channel/Application/Readers # ACL Definition of SimulateConfigTreeUpdate Function for Chain Code of cscc System cscc/SimulateConfigTreeUpdate: /Channel/Application/Readers #---Miscellanesous peer function to policy mapping for access control---# # ACL Policy Definition for Accessing Chain Codes on Peer-to-Peer Nodes peer/Propose: /Channel/Application/Writers # ACL Policy Definition for Accessing Other Chain Codes from Chain Codes peer/ChaincodeToChaincode: /Channel/Application/Readers #---Events resource to policy mapping for access control###---# # ACL Policy Definition for Sending Block Events event/Block: /Channel/Application/Readers # ACL Policy Definition for Sending Filtered Block Events event/FilteredBlock: /Channel/Application/Readers # Organizations configuration lists the organizations participating in the network Organizations: # Define the application control strategy at this level, whose authoritative path is / Channel / Application /< PolicyName > Policies: &ApplicationDefaultPolicies Readers: Type: ImplicitMeta Rule: "ANY Readers" Writers: Type: ImplicitMeta Rule: "ANY Writers" Admins: Type: ImplicitMeta Rule: "MAJORITY Admins" LifecycleEndorsement: Type: ImplicitMeta Rule: "ANY Endorsement" Endorsement: Type: ImplicitMeta Rule: "ANY Endorsement" # Capabilities configuration describes capability requirements at the application level, which are directly referenced here # Application Capabilities Configuration Item in the previous Capabilities Configuration Section Capabilities: <<: *ApplicationCapabilities
Profiles / Configuration Entry
The Profiles configuration section defines the configuration entry for the configtxgen tool. Configuration entries containing consortium can be used to generate Genesis blocks for sorting nodes. If consortium members are correctly defined in the Genesis block of the sorting node, channel creation requests can be generated using only the name of the organization member and the name of the committee.
Profiles: # SampleInsecureSolo defines a simple configuration for sorting nodes using Solo SampleInsecureSolo: <<: *ChannelDefaults Orderer: <<: *OrdererDefaults Organizations: - *ExampleCom Capabilities: <<: *OrdererCapabilities Application: <<: *ApplicationDefaults Organizations: - *ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement Consortiums: SampleConsortium: Organizations: - *Org1ExampleCom - *Org2ExampleCom # Sample Insecure Kafka defines a configuration for sorting nodes using Kfaka SampleInsecureKafka: <<: *ChannelDefaults Orderer: <<: *OrdererDefaults OrdererType: kafka Addresses: - orderer0.example.com:7050 - orderer1.example.com:7050 - orderer2.example.com:7050 Organizations: - *ExampleCom Capabilities: <<: *OrdererCapabilities Application: <<: *ApplicationDefaults Organizations: - *ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement Consortiums: SampleConsortium: Organizations: - *ExampleCom - *Org1ExampleCom - *Org2ExampleCom # SampleSingleMSPSolo defines a configuration that uses Solo to sort nodes and contains a single MSP SampleSingleMSPSolo: Orderer: <<: *OrdererDefaults Organizations: - *ExampleCom Capabilities: <<: *OrdererCapabilities Application: <<: *ApplicationDefaults Organizations: - *ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement Consortiums: SampleConsortium: Organizations: - *ExampleCom - *Org1ExampleCom - *Org2ExampleCom # SampleEmpty Insecure Channel defines a channel that does not contain members and access control policies SampleEmptyInsecureChannel: Capabilities: <<: *ChannelCapabilities Consortium: SampleConsortium Application: Organizations: - *ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement # SysTest Channel defines a channel for testing SysTestChannel: <<: *ChannelDefaults Capabilities: <<: *ChannelCapabilities Consortium: SampleConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1ExampleCom - *Org2ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement # Sample Single MSPChannel defines a channel that contains only a single member organization. # This configuration is usually used in conjunction with SampleSingleMSPSolo or SampleSingleMSPKafka SampleSingleMSPChannel: <<: *ChannelDefaults Capabilities: <<: *ChannelCapabilities Consortium: SampleConsortium Application: <<: *ApplicationDefaults Organizations: - *Org1ExampleCom - *Org2ExampleCom Capabilities: <<: *ApplicationCapabilities Policies: Readers: Type: ImplicitMeta Rule: ANY Readers Writers: Type: ImplicitMeta Rule: ANY Writers Admins: Type: ImplicitMeta Rule: MAJORITY Admins LifecycleEndorsement: Type: ImplicitMeta Rule: ANY Endorsement Endorsement: Type: ImplicitMeta Rule: ANY Endorsement
Huizhi originally created, reproduced please indicate the source.