Skip to content

Commit 13bbcfe

Browse files
author
Jason Yellick
committed
[FAB-4337] Fix proto style in batchsize config msg
This is a proto message that slipped through the proto style normalization. It's a safe change from a go API perspective, and it is ABI compatible with the existing protos, so no existing consumers should be affected. This is important to fix however, because reconfiguration is finally available, and these field names are finally user visible. Fixing this soon should have minimal impact, but may have more impact in the future once more people are familiar with the config contents. Change-Id: I7b21f72776088e66be45c72ed869a43b7153b0d5 Signed-off-by: Jason Yellick <[email protected]>
1 parent 7717a2e commit 13bbcfe

File tree

5 files changed

+39
-36
lines changed

5 files changed

+39
-36
lines changed

examples/configtxupdate/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Reconfiguraing with configtxlator
1+
# Reconfiguring with configtxlator
22

33
## Overview
44

@@ -92,7 +92,7 @@ curl -X POST --data-binary @genesis_block.proto http://127.0.0.1:7059/protolator
9292
```
9393
Edit the `genesis_block.json` file in your favorite JSON editor, or manipulate it programatically, here, we use the JSON CLI tool `jq`. For simplicity, we are editing the batch size for the channel, because it is a single numeric field, but any edits, including policy and MSP edits may be made here.
9494
```
95-
$ export MAXBATCHSIZEPATH=".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.maxMessageCount"
95+
$ export MAXBATCHSIZEPATH=".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count"
9696
# Display the old batch size
9797
$ jq "$MAXBATCHSIZEPATH" genesis_block.json
9898
10
@@ -176,7 +176,7 @@ jq .data.data[0].payload.data.config config_block.json > config.json
176176
Edit the config, saving it as a new `updated_config.json`. Here, we set the batch size to 30.
177177

178178
```
179-
jq ".channel_group.groups.Orderer.values.BatchSize.value.maxMessageCount = 30" config.json > updated_config.json
179+
jq ".channel_group.groups.Orderer.values.BatchSize.value.max_message_count = 30" config.json > updated_config.json
180180
```
181181

182182
Re-encode both the original config, and the updated config into proto.

examples/configtxupdate/bootstrapping/script.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ curl -X POST --data-binary @genesis_block.proto http://127.0.0.1:7059/protolator
2929

3030
bigMsg "Updating genesis config"
3131

32-
jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.maxMessageCount" genesis_block.json > updated_genesis_block.json
32+
jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count = 20" genesis_block.json > updated_genesis_block.json
3333

3434
bigMsg "Re-encoding the updated genesis block"
3535

examples/configtxupdate/reconfig/script.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
CHANNEL=testchainid
4+
35
die() {
46
echo "$1"
57
exit 1
@@ -21,7 +23,7 @@ PEER=../../../build/bin/peer
2123

2224
bigMsg "Fetching current config block"
2325

24-
$PEER channel fetch config config_block.proto -o 127.0.0.1:7050 -c testchainid || die "Unable to fetch config block"
26+
$PEER channel fetch config config_block.proto -o 127.0.0.1:7050 -c $CHANNEL || die "Unable to fetch config block"
2527

2628
bigMsg "Decoding current config block"
2729

@@ -33,10 +35,10 @@ jq .data.data[0].payload.data.config config_block.json > config.json || die "Una
3335

3436
bigMsg "Generating new config"
3537

36-
OLD_BATCH_SIZE=$(jq ".channel_group.groups.Orderer.values.BatchSize.value.maxMessageCount" config.json)
38+
OLD_BATCH_SIZE=$(jq ".channel_group.groups.Orderer.values.BatchSize.value.max_message_count" config.json)
3739
NEW_BATCH_SIZE=$(($OLD_BATCH_SIZE+1))
3840

39-
jq ".channel_group.groups.Orderer.values.BatchSize.value.maxMessageCount = $NEW_BATCH_SIZE" config.json > updated_config.json || die "Error updating batch size"
41+
jq ".channel_group.groups.Orderer.values.BatchSize.value.max_message_count = $NEW_BATCH_SIZE" config.json > updated_config.json || die "Error updating batch size"
4042

4143
bigMsg "Translating original config to proto"
4244

@@ -48,22 +50,22 @@ curl -X POST --data-binary @updated_config.json http://127.0.0.1:7059/protolator
4850

4951
bigMsg "Computing config update"
5052

51-
curl -X POST -F [email protected] -F updated=@updated_config.proto http://127.0.0.1:7059/configtxlator/compute/update-from-configs -F channel=testchainid > config_update.proto || die "Error computing config update"
53+
curl -X POST -F [email protected] -F updated=@updated_config.proto http://127.0.0.1:7059/configtxlator/compute/update-from-configs -F channel=$CHANNEL > config_update.proto || die "Error computing config update"
5254

5355
bigMsg "Decoding config update"
5456

5557
curl -X POST --data-binary @config_update.proto http://127.0.0.1:7059/protolator/decode/common.ConfigUpdate > config_update.json || die "Error decoding config update"
5658

5759
bigMsg "Generating config update envelope"
5860

59-
echo '{"payload":{"header":{"channel_header":{"channel_id":"testchainid", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' > config_update_as_envelope.json || die "Error creating config update envelope"
61+
echo '{"payload":{"header":{"channel_header":{"channel_id":"'$CHANNEL'", "type":2}},"data":{"config_update":'$(cat config_update.json)'}}}' > config_update_as_envelope.json || die "Error creating config update envelope"
6062

6163
bigMsg "Encoding config update envelope"
6264

6365
curl -X POST --data-binary @config_update_as_envelope.json http://127.0.0.1:7059/protolator/encode/common.Envelope > config_update_as_envelope.proto || die "Error converting envelope to proto"
6466

6567
bigMsg "Sending config update to channel"
6668

67-
$PEER channel update -f config_update_as_envelope.proto -c testchainid -o 127.0.0.1:7050 || die "Error updating channel"
69+
$PEER channel update -f config_update_as_envelope.proto -c $CHANNEL -o 127.0.0.1:7050 || die "Error updating channel"
6870

6971
bigMsg "Config Update Successful!"

protos/orderer/configuration.pb.go

+24-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protos/orderer/configuration.proto

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ message ConsensusType {
3535
message BatchSize {
3636
// Simply specified as number of messages for now, in the future
3737
// we may want to allow this to be specified by size in bytes
38-
uint32 maxMessageCount = 1;
38+
uint32 max_message_count = 1;
3939
// The byte count of the serialized messages in a batch cannot
4040
// exceed this value.
41-
uint32 absoluteMaxBytes = 2;
41+
uint32 absolute_max_bytes = 2;
4242
// The byte count of the serialized messages in a batch should not
4343
// exceed this value.
44-
uint32 preferredMaxBytes = 3;
44+
uint32 preferred_max_bytes = 3;
4545
}
4646

4747
message BatchTimeout {

0 commit comments

Comments
 (0)