Update docs
parent
a54f3c9f11
commit
0c0e044ae7
|
@ -41,11 +41,155 @@ And we can transform json to proto.
|
|||
$ curl -X POST --data-binary @businesschannel_0.json http://127.0.0.1:7059/protolator/encode/common.Block > businesschannel_0.block
|
||||
```
|
||||
|
||||
### Re-Configuration
|
||||
### Re-Configuration example
|
||||
|
||||
Refer to [create a new ordering system channel](http://hyperledger-fabric.readthedocs.io/en/latest/configtxlator.html#reconfiguration-example)
|
||||
1. here we will introduce how to re-configuration config.block, first fetch the block and translate it to json.
|
||||
|
||||
### [WIP]/configtxlator/compute/update-from-configs
|
||||
```bash
|
||||
$ ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
||||
|
||||
$ peer channel fetch config -o orderer.example.com:7050 -c businesschannel --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA|xargs mv true config_block.pb
|
||||
|
||||
### [WIP]/configtxlator/config/verify
|
||||
$ peer channel fetch config config_block.pb -o orderer.example.com:7050 -c businesschannel # with no-tls
|
||||
|
||||
$ curl -X POST --data-binary @config_block.pb http://127.0.0.1:7059/protolator/decode/common.Block > config_block.json
|
||||
```
|
||||
|
||||
2. Extract the config section from the block:
|
||||
|
||||
```bash
|
||||
$ apt-get install jq
|
||||
$ jq .data.data[0].payload.data.config config_block.json > config.json
|
||||
```
|
||||
|
||||
3. edit the config.json, set the batch size to 11, and saving it as update_config.json
|
||||
|
||||
```bash
|
||||
4. $ jq ".channel_group.groups.Orderer.values.BatchSize.value.max_message_count = 11" config.json > updated_config.json
|
||||
```
|
||||
|
||||
5. Re-encode both the original config, and the updated config into proto:
|
||||
|
||||
```bash
|
||||
$ curl -X POST --data-binary @config.json http://127.0.0.1:7059/protolator/encode/common.Config > config.pb
|
||||
$ curl -X POST --data-binary @updated_config.json http://127.0.0.1:7059/protolator/encode/common.Config > updated_config.pb
|
||||
```
|
||||
|
||||
6. send them to the configtxlator service to compute the config update which transitions between the two.
|
||||
|
||||
```bash
|
||||
$ 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=businesschannel > config_update.pb
|
||||
```
|
||||
|
||||
7. we decode the ConfigUpdate so that we may work with it as text:
|
||||
```bash
|
||||
$ curl -X POST --data-binary @config_update.pb http://127.0.0.1:7059/protolator/decode/common.ConfigUpdate > config_update.json
|
||||
```
|
||||
|
||||
8. Then, we wrap it in an envelope message:
|
||||
|
||||
```bash
|
||||
$ echo '{"payload":{"header":{"channel_header":{"channel_id":"businesschannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' > config_update_as_envelope.json
|
||||
```
|
||||
|
||||
9. Next, convert it back into the proto form of a full fledged config transaction:
|
||||
|
||||
```bash
|
||||
$ 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
|
||||
````
|
||||
|
||||
10. Finally, submit the config update transaction to ordering to perform a config update.
|
||||
|
||||
```bash
|
||||
$ CORE_PEER_LOCALMSPID=OrdererMSP
|
||||
$ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
|
||||
|
||||
$ peer channel update -o orderer.example.com:7050 -c businesschannel -f config_update_as_envelope.pb --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA
|
||||
$ peer channel update -f config_update_as_envelope.pb -o orderer.example.com:7050 -c businesschannel # with no-tls
|
||||
```
|
||||
|
||||
### [WIP]Add an organization
|
||||
|
||||
1. Execute `configtxgen` to generate `channel.tx`
|
||||
|
||||
```bash
|
||||
$ ORDERER_GENERAL_GENESISPROFILE=SampleDevModSolo #Change this env before start ordering service.
|
||||
```
|
||||
|
||||
```bash
|
||||
$ docker exec -it fabric-cli bash
|
||||
$ configtxgen -profile SampleDevModSolo -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID businesschannel
|
||||
```
|
||||
|
||||
2. create channel use channel.tx, then we will get block businesschannel.block
|
||||
|
||||
```bash
|
||||
$ peer channel create -o orderer.example.com:7050 -c businesschannel -f ./channel-artifacts/channel.tx
|
||||
```
|
||||
|
||||
3. Start configtxlator
|
||||
|
||||
```bash
|
||||
$ docker exec -it fabric-cli bash
|
||||
$ configtxlator start
|
||||
```
|
||||
|
||||
4. In a new window, decoding current genesis block
|
||||
|
||||
```bash
|
||||
$ curl -X POST --data-binary @businesschannel.block http://127.0.0.1:7059/protolator/decode/common.Block > businesschannel.json
|
||||
```
|
||||
|
||||
5. Extract current config
|
||||
|
||||
```bash
|
||||
jq .data.data[0].payload.data.config businesschannel.json > config.json
|
||||
```
|
||||
|
||||
6. generating new config
|
||||
|
||||
```bash
|
||||
jq '. * {"channel_group":{"groups":{"Application":{"groups":{"ExampleOrg": .channel_group.groups.Application.groups.SampleOrg}}}}}' config.json |
|
||||
jq '.channel_group.groups.Application.groups.ExampleOrg.values.MSP.value.config.name = "ExampleOrg"' > update_config.json
|
||||
```
|
||||
|
||||
7. Translate config.json and update_config.json to proto
|
||||
|
||||
```bash
|
||||
curl -X POST --data-binary @config.json http://127.0.0.1:7059/protolator/encode/common.Config > config.pb
|
||||
curl -X POST --data-binary @update_config.json http://127.0.0.1:7059/protolator/encode/common.Config > update_config.pb
|
||||
```
|
||||
|
||||
8. Computing config update
|
||||
|
||||
```bash
|
||||
curl -X POST -F original=@config.pb -F updated=@update_config.pb http://127.0.0.1:7059/configtxlator/compute/update-from-configs -F channel=businesschannel > config_update.pb
|
||||
```
|
||||
|
||||
9. Decoding config update
|
||||
|
||||
```bash
|
||||
curl -X POST --data-binary @config_update.pb http://127.0.0.1:7059/protolator/decode/common.ConfigUpdate > config_update.json
|
||||
```
|
||||
|
||||
10. Generating config update envelope
|
||||
|
||||
```bash
|
||||
echo '{"payload":{"header":{"channel_header":{"channel_id":"businesschannel", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' > config_update_in_envelope.json
|
||||
```
|
||||
|
||||
11. Next, convert it back into the proto form of a full fledged config transaction:
|
||||
|
||||
```bash
|
||||
curl -X POST --data-binary @config_update_in_envelope.json http://127.0.0.1:7059/protolator/encode/common.Envelope > config_update_in_envelope.pb
|
||||
```
|
||||
|
||||
12. Sending config update to channel
|
||||
|
||||
```bash
|
||||
$ CORE_PEER_LOCALMSPID=OrdererMSP
|
||||
$ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/users/Admin@example.com/msp
|
||||
|
||||
$ peer channel update -o orderer.example.com:7050 -c businesschannel -f config_update_in_envelope.pb --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA
|
||||
$ (optional)peer channel update -f config_update_as_envelope.pb -o orderer.example.com:7050 -c businesschannel # with no-tls
|
||||
```
|
|
@ -27,7 +27,7 @@ $ peer channel fetch newest -o orderer.example.com:7050 -c businesschannel
|
|||
When you set *TLS_ENABLED=true, then you can fetch blocks using following command:
|
||||
|
||||
```bash
|
||||
$ ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/cacerts/ca.example.com-cert.pem
|
||||
$ ORDERER_CA=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
|
||||
$ NUM= the block's num you want to fetch
|
||||
$ peer channel fetch $NUM -o orderer.example.com:7050 -c businesschannel --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA |xargs mv true businesschannel_$NUM.block
|
||||
$ peer channel fetch oldest -o orderer.example.com:7050 -c businesschannel --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA |xargs mv true businesschannel_oldest.block
|
||||
|
|
Loading…
Reference in New Issue