github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/docs/update-config.md (about)

     1  
     2  ## overview
     3  
     4  The configtxlator tool was created to support reconfiguration independent of SDKs.
     5  
     6  The standard usage is expected to be configtxlator:
     7  
     8  1. Proto translation
     9  2. Config update computation
    10  
    11  
    12  The binary will start an http server listening on the designated port(7059) and is now ready to process request.
    13  
    14  First prepare some tools:
    15  
    16  ```bash
    17  
    18  apt-get update && apt-get install vim && apt-get install jq
    19  ```
    20  
    21  ## To start the configtxlator server
    22  
    23  docker exec -it cli bash
    24  
    25  configtxlator start &
    26  
    27  ## Dynamically modify the maximum number txs and block  of each block / block time
    28  
    29  
    30  lounch a new terminal.
    31  
    32  1. here we will introduce how to re-configuration config.block, first fetch the block and translate it to json.
    33  
    34  ```bash
    35  ORDERER_CA=/opt/gopath/src/github.com/inklabsfoundation/inkchain/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
    36  CHANNEL_NAME=mychannel
    37  
    38  peer channel fetch config config_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
    39  
    40  curl -X POST --data-binary @config_block.pb http://127.0.0.1:7059/protolator/decode/common.Block > config_block.json
    41  ```
    42  
    43  2. Extract the config section from the block:
    44  
    45  ```bash
    46  jq .data.data[0].payload.data.config config_block.json > config.json
    47  ```
    48  
    49  3. edit the config.json, set the batch size to 20, or reset timeout=5s and saving it as update_config.json
    50  
    51  ```bash
    52  jq ".channel_group.groups.Orderer.values.BatchSize.value.max_message_count = 20" config.json  > updated_config.json
    53  
    54  jq ".channel_group.groups.Orderer.values.BatchTimeout.value.timeout=\"5s\"" config.json > updated_config.json
    55  ```
    56  
    57  4. Re-encode both the original config, and the updated config into proto:
    58  
    59  ```bash
    60  curl -X POST --data-binary @config.json http://127.0.0.1:7059/protolator/encode/common.Config > config.pb
    61  curl -X POST --data-binary @updated_config.json http://127.0.0.1:7059/protolator/encode/common.Config > updated_config.pb
    62  ```
    63  
    64  5. send them to the configtxlator service to compute the config update which transitions between the two.
    65  
    66  ```bash
    67  curl -X POST -F original=@config.pb -F updated=@updated_config.pb http://127.0.0.1:7059/configtxlator/compute/update-from-configs -F channel=mychannel > config_update.pb
    68  ```
    69  
    70  6. we decode the ConfigUpdate so that we may work with it as text:
    71  ```bash
    72  curl -X POST --data-binary @config_update.pb http://127.0.0.1:7059/protolator/decode/common.ConfigUpdate > config_update.json
    73  ```
    74  
    75  7. Then, we wrap it in an envelope message:
    76  
    77  ```bash
    78  echo '{"payload":{"header":{"channel_header":{"channel_id":"mychannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' > config_update_as_envelope.json
    79  ```
    80  
    81  8. Next, convert it back into the proto form of a full fledged config transaction:
    82  
    83  ```bash
    84  curl -X POST --data-binary @config_update_as_envelope.json http://127.0.0.1:7059/protolator/encode/common.Envelope > config_update_as_envelope.pb
    85  ````
    86  
    87  9. Finally, submit the config update transaction to ordering to perform a config update.
    88  
    89  ```bash
    90  CORE_PEER_LOCALMSPID=OrdererMSP
    91  CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/inklabsfoundation/inkchain/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
    92  
    93  peer channel update -o orderer.example.com:7050 -c mychannel -f config_update_as_envelope.pb --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA
    94  ```
    95  
    96  10. verify
    97  
    98  export MAXBATCHSIZEPATH=".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count"
    99  export MAXTIMEOUT=".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchTimeout.value.timeout"
   100  
   101  peer channel fetch config config_new_block.pb -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA
   102  
   103  curl -X POST --data-binary @config_new_block.pb http://127.0.0.1:7059/protolator/decode/common.Block > config_new_block.json
   104  
   105  jq $MAXTIMEOUT config_new_block.json
   106  
   107  jq $MAXBATCHSIZEPATH config_new_block.json