github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/docs/source/configtxgen.rst (about) 1 Channel Configuration (configtxgen) 2 =================================== 3 4 This document describe the usage for the ``configtxgen`` utility for 5 manipulating Hyperledger Fabric channel configuration. 6 7 For now, the tool is primarily focused on generating the genesis block 8 for bootstrapping the orderer, but it is intended to be enhanced in the 9 future for generating new channel configurations as well as 10 reconfiguring existing channels. 11 12 Configuration Profiles 13 ---------------------- 14 15 The configuration parameters supplied to the ``configtxgen`` tool are 16 primarily provided by the ``configtx.yaml`` file. This file is located 17 at ``fabric/sampleconfig/configtx.yaml`` in the fabric.git 18 repository. 19 20 This configuration file is split primarily into three pieces. 21 22 1. The ``Profiles`` section. By default, this section includes some 23 sample configurations which can be used for development or testing 24 scenarios, and refer to crypto material present in the fabric.git 25 tree. These profiles can make a good starting point for construction 26 a real deployment profile. The ``configtxgen`` tool allows you to 27 specify the profile it is operating under by passing the ``-profile`` 28 flag. Profiles may explicitly declare all configuration, but usually 29 inherit configuration from the defaults in (3) below. 30 2. The ``Organizations`` section. By default, this section includes a 31 single reference to the sampleconfig MSP definition. For production 32 deployments, the sample organization should be removed, and the MSP 33 definitions of the network members should be referenced and defined 34 instead. Each element in the ``Organizations`` section should be 35 tagged with an anchor label such as ``&orgName`` which will allow the 36 definition to be referenced in the ``Profiles`` sections. 37 3. The default sections. There are default sections for ``Orderer`` and 38 ``Application`` configuration, these include attributes like 39 ``BatchTimeout`` and are generally used as the base inherited values 40 for the profiles. 41 42 This configuration file may be edited, or, individual properties may be 43 overridden by setting environment variables, such as 44 ``CONFIGTX_ORDERER_ORDERERTYPE=kafka``. Note that the ``Profiles`` 45 element and profile name do not need to be specified. 46 47 Bootstrapping the orderer 48 ------------------------- 49 50 After creating a configuration profile as desired, simply invoke 51 52 :: 53 54 configtxgen -profile <profile_name> -outputBlock orderer_genesisblock.pb 55 56 This will produce an ``orderer_genesisblock.pb`` file in the current directory. 57 This genesis block is used to bootstrap the ordering system channel, which the 58 orderers use to authorize and orchestrate creation of other channels. By 59 default, the channel ID encoded into the genesis block by ``configtxgen`` will be 60 ``testchainid``. It is recommended that you modify this identifier to something 61 which will be globally unique. 62 63 Then, to utilize this genesis block, before starting the orderer, simply 64 specify ``ORDERER_GENERAL_GENESISMETHOD=file`` and 65 ``ORDERER_GENERAL_GENESISFILE=$PWD/orderer_genesisblock.pb`` or modify the 66 ``orderer.yaml`` file to encode these values. 67 68 Creating a channel 69 ------------------ 70 71 The tool can also output a channel creation tx by executing 72 73 :: 74 75 configtxgen -profile <profile_name> -channelID <channel_name> -outputCreateChannelTx <tx_filename> 76 77 This will output a marshaled ``Envelope`` message which may be sent to 78 broadcast to create a channel. 79 80 Reviewing a configuration 81 ------------------------- 82 83 In addition to creating configuration, the ``configtxgen`` tool is also 84 capable of inspecting configuration. 85 86 It supports inspecting both configuration blocks, and configuration 87 transactions. You may use the inspect flags ``-inspectBlock`` and 88 ``-inspectChannelCreateTx`` respectively with the path to a file to 89 inspect to output a human readable (JSON) representation of the 90 configuration. 91 92 You may even wish to combine the inspection with generation. For 93 example: 94 95 :: 96 97 $ build/bin/configtxgen -channelID foo -outputBlock foo_genesisblock.pb -inspectBlock foo_genesisblock.pb 98 2017-11-02 17:56:04.489 EDT [common/tools/configtxgen] main -> INFO 001 Loading configuration 99 2017-11-02 17:56:04.564 EDT [common/tools/configtxgen] doOutputBlock -> INFO 002 Generating genesis block 100 2017-11-02 17:56:04.564 EDT [common/tools/configtxgen] doOutputBlock -> INFO 003 Writing genesis block 101 2017-11-02 17:56:04.564 EDT [common/tools/configtxgen] doInspectBlock -> INFO 004 Inspecting block 102 2017-11-02 17:56:04.564 EDT [common/tools/configtxgen] doInspectBlock -> INFO 005 Parsing genesis block 103 { 104 "data": { 105 "data": [ 106 { 107 "payload": { 108 "data": { 109 "config": { 110 "channel_group": { 111 "groups": { 112 "Consortiums": { 113 "groups": { 114 "SampleConsortium": { 115 "mod_policy": "/Channel/Orderer/Admins", 116 "values": { 117 "ChannelCreationPolicy": { 118 "mod_policy": "/Channel/Orderer/Admins", 119 "value": { 120 "type": 3, 121 "value": { 122 "rule": "ANY", 123 "sub_policy": "Admins" 124 } 125 }, 126 "version": "0" 127 } 128 }, 129 "version": "0" 130 } 131 }, 132 "mod_policy": "/Channel/Orderer/Admins", 133 "policies": { 134 "Admins": { 135 "mod_policy": "/Channel/Orderer/Admins", 136 "policy": { 137 "type": 1, 138 "value": { 139 "rule": { 140 "n_out_of": { 141 "n": 0 142 } 143 }, 144 "version": 0 145 } 146 }, 147 "version": "0" 148 } 149 }, 150 "version": "0" 151 }, 152 "Orderer": { 153 "mod_policy": "Admins", 154 "policies": { 155 "Admins": { 156 "mod_policy": "Admins", 157 "policy": { 158 "type": 3, 159 "value": { 160 "rule": "MAJORITY", 161 "sub_policy": "Admins" 162 } 163 }, 164 "version": "0" 165 }, 166 "BlockValidation": { 167 "mod_policy": "Admins", 168 "policy": { 169 "type": 3, 170 "value": { 171 "rule": "ANY", 172 "sub_policy": "Writers" 173 } 174 }, 175 "version": "0" 176 }, 177 "Readers": { 178 "mod_policy": "Admins", 179 "policy": { 180 "type": 3, 181 "value": { 182 "rule": "ANY", 183 "sub_policy": "Readers" 184 } 185 }, 186 "version": "0" 187 }, 188 "Writers": { 189 "mod_policy": "Admins", 190 "policy": { 191 "type": 3, 192 "value": { 193 "rule": "ANY", 194 "sub_policy": "Writers" 195 } 196 }, 197 "version": "0" 198 } 199 }, 200 "values": { 201 "BatchSize": { 202 "mod_policy": "Admins", 203 "value": { 204 "absolute_max_bytes": 10485760, 205 "max_message_count": 10, 206 "preferred_max_bytes": 524288 207 }, 208 "version": "0" 209 }, 210 "BatchTimeout": { 211 "mod_policy": "Admins", 212 "value": { 213 "timeout": "2s" 214 }, 215 "version": "0" 216 }, 217 "ChannelRestrictions": { 218 "mod_policy": "Admins", 219 "version": "0" 220 }, 221 "ConsensusType": { 222 "mod_policy": "Admins", 223 "value": { 224 "type": "solo" 225 }, 226 "version": "0" 227 } 228 }, 229 "version": "0" 230 } 231 }, 232 "mod_policy": "Admins", 233 "policies": { 234 "Admins": { 235 "mod_policy": "Admins", 236 "policy": { 237 "type": 3, 238 "value": { 239 "rule": "MAJORITY", 240 "sub_policy": "Admins" 241 } 242 }, 243 "version": "0" 244 }, 245 "Readers": { 246 "mod_policy": "Admins", 247 "policy": { 248 "type": 3, 249 "value": { 250 "rule": "ANY", 251 "sub_policy": "Readers" 252 } 253 }, 254 "version": "0" 255 }, 256 "Writers": { 257 "mod_policy": "Admins", 258 "policy": { 259 "type": 3, 260 "value": { 261 "rule": "ANY", 262 "sub_policy": "Writers" 263 } 264 }, 265 "version": "0" 266 } 267 }, 268 "values": { 269 "BlockDataHashingStructure": { 270 "mod_policy": "Admins", 271 "value": { 272 "width": 4294967295 273 }, 274 "version": "0" 275 }, 276 "HashingAlgorithm": { 277 "mod_policy": "Admins", 278 "value": { 279 "name": "SHA256" 280 }, 281 "version": "0" 282 }, 283 "OrdererAddresses": { 284 "mod_policy": "/Channel/Orderer/Admins", 285 "value": { 286 "addresses": [ 287 "127.0.0.1:7050" 288 ] 289 }, 290 "version": "0" 291 } 292 }, 293 "version": "0" 294 }, 295 "sequence": "0", 296 "type": 0 297 } 298 }, 299 "header": { 300 "channel_header": { 301 "channel_id": "foo", 302 "epoch": "0", 303 "timestamp": "2017-11-02T21:56:04.000Z", 304 "tx_id": "6acfe1257c23a4f844cc299cbf53acc7bf8fa8bcf8aae8d049193098fe982eab", 305 "type": 1, 306 "version": 1 307 }, 308 "signature_header": { 309 "nonce": "eZOKru6jmeiWykBtSDwnkGjyQt69GwuS" 310 } 311 } 312 } 313 } 314 ] 315 }, 316 "header": { 317 "data_hash": "/86I/7NScbH/bHcDcYG0/9qTmVPWVoVVfSN8NKMARKI=", 318 "number": "0" 319 }, 320 "metadata": { 321 "metadata": [ 322 "", 323 "", 324 "", 325 "" 326 ] 327 } 328 } 329 330 .. Licensed under Creative Commons Attribution 4.0 International License 331 https://creativecommons.org/licenses/by/4.0/