Skip to content

Commit 124cd2d

Browse files
committed
[FAB-1141] Updating TLS and gossip leader conf
Added TLS seetings to peer configuration. Correctly set gossip config to dynamic, and no more warnings. Removed prints in behave run. Modified case for sampleconfig dir during peer chaincode package command usage. Added copyright preamble to some python files. Now set orgleader to false by default, and user leader election true for all peers. Now send join channel to all peers. Added BlockValidation policy to orderer config. All warnings in orderer logs gone. Change-Id: Ic8cedba0c60f8ea191148cd2acb55600a236794d Signed-off-by: jeffgarratt <[email protected]>
1 parent 312d7e1 commit 124cd2d

7 files changed

+80
-11
lines changed

bddtests/docker-compose-next-4.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ services:
1717
service: vpNext
1818
environment:
1919
- CORE_PEER_ID=vp0
20+
- CORE_PEER_GOSSIP_BOOTSTRAP=peer1:7051
2021
- CORE_PEER_PROFILE_ENABLED=true
2122
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer0:7050
2223
- CORE_PEER_MSPCONFIGPATH=${PEER0_CORE_PEER_MSPCFGPATH}
2324
- CORE_PEER_LOCALMSPID=${PEER0_CORE_PEER_LOCALMSPID}
25+
- CORE_PEER_TLS_CERT_FILE=${PEER0_CORE_PEER_TLS_CERT_FILE}
26+
- CORE_PEER_TLS_KEY_FILE=${PEER0_CORE_PEER_TLS_KEY_FILE}
2427
depends_on:
2528
- orderer0
2629
# ports:
@@ -37,6 +40,8 @@ services:
3740
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer0:7050
3841
- CORE_PEER_MSPCONFIGPATH=${PEER1_CORE_PEER_MSPCFGPATH}
3942
- CORE_PEER_LOCALMSPID=${PEER1_CORE_PEER_LOCALMSPID}
43+
- CORE_PEER_TLS_CERT_FILE=${PEER1_CORE_PEER_TLS_CERT_FILE}
44+
- CORE_PEER_TLS_KEY_FILE=${PEER1_CORE_PEER_TLS_KEY_FILE}
4045
depends_on:
4146
- orderer0
4247
- peer0
@@ -47,10 +52,12 @@ services:
4752
service: vpNext
4853
environment:
4954
- CORE_PEER_ID=vp2
50-
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
55+
- CORE_PEER_GOSSIP_BOOTSTRAP=peer3:7051
5156
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer0:7050
5257
- CORE_PEER_MSPCONFIGPATH=${PEER2_CORE_PEER_MSPCFGPATH}
5358
- CORE_PEER_LOCALMSPID=${PEER2_CORE_PEER_LOCALMSPID}
59+
- CORE_PEER_TLS_CERT_FILE=${PEER2_CORE_PEER_TLS_CERT_FILE}
60+
- CORE_PEER_TLS_KEY_FILE=${PEER2_CORE_PEER_TLS_KEY_FILE}
5461
depends_on:
5562
- orderer0
5663
- peer0
@@ -61,10 +68,12 @@ services:
6168
service: vpNext
6269
environment:
6370
- CORE_PEER_ID=vp3
64-
- CORE_PEER_GOSSIP_BOOTSTRAP=peer0:7051
71+
- CORE_PEER_GOSSIP_BOOTSTRAP=peer2:7051
6572
- CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer0:7050
6673
- CORE_PEER_MSPCONFIGPATH=${PEER3_CORE_PEER_MSPCFGPATH}
6774
- CORE_PEER_LOCALMSPID=${PEER3_CORE_PEER_LOCALMSPID}
75+
- CORE_PEER_TLS_CERT_FILE=${PEER3_CORE_PEER_TLS_CERT_FILE}
76+
- CORE_PEER_TLS_KEY_FILE=${PEER3_CORE_PEER_TLS_KEY_FILE}
6877
depends_on:
6978
- orderer0
7079
- peer0

bddtests/docker-compose-next.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ services:
99
environment:
1010
- CORE_NEXT=true
1111
- CORE_PEER_ENDORSER_ENABLED=true
12+
- CORE_PEER_GOSSIP_ORGLEADER=false
13+
- CORE_PEER_GOSSIP_USELEADERELECTION=true
1214

bddtests/features/bootstrap.feature

+4
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,23 @@ Feature: Bootstrap
135135
When user "dev0Org0" using cert alias "dev0Org0App1" requests to join channel using genesis block "genesisBlockForMyNewChannel" on peers with result "joinChannelResult"
136136
| Peer |
137137
| peer0 |
138+
| peer1 |
138139

139140
Then user "dev0Org0" expects result code for "joinChannelResult" of "200" from peers:
140141
| Peer |
141142
| peer0 |
143+
| peer1 |
142144

143145
# This is entry point for joining an existing channel
144146
When user "dev0Org1" using cert alias "dev0Org1App1" requests to join channel using genesis block "genesisBlockForMyNewChannel" on peers with result "joinChannelResult"
145147
| Peer |
146148
| peer2 |
149+
| peer3 |
147150

148151
Then user "dev0Org1" expects result code for "joinChannelResult" of "200" from peers:
149152
| Peer |
150153
| peer2 |
154+
| peer3 |
151155

152156
# Entry point for invoking on an existing channel
153157
When user "dev0Org0" creates a chaincode spec "cc_spec" with name "example02" of type "GOLANG" for chaincode "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" with args

bddtests/steps/bootstrap_util.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ class BootstrapHelper:
387387
# AdminsPolicyKey is the key used for the admins policy
388388
KEY_POLICY_ADMINS = "Admins"
389389

390+
KEY_POLICY_BLOCK_VALIDATION = "BlockValidation"
391+
390392
# OrdererAddressesKey is the cb.ConfigItem type key name for the OrdererAddresses message
391393
KEY_ORDERER_ADDRESSES = "OrdererAddresses"
392394

@@ -691,6 +693,9 @@ def createChannelConfigGroup(directory, hashingAlgoName="SHA256", consensusType=
691693
rule=ruleAny, sub_policy=BootstrapHelper.KEY_POLICY_WRITERS).SerializeToString()))
692694
group.policies[BootstrapHelper.KEY_POLICY_ADMINS].policy.CopyFrom(Policy(type=typeImplicitMeta, policy=IMP(
693695
rule=ruleMajority, sub_policy=BootstrapHelper.KEY_POLICY_ADMINS).SerializeToString()))
696+
# Setting block validation policy for the orderer group
697+
channel.groups[OrdererGroup].policies[BootstrapHelper.KEY_POLICY_BLOCK_VALIDATION].policy.CopyFrom(Policy(type=typeImplicitMeta, policy=IMP(
698+
rule=ruleAny, sub_policy=BootstrapHelper.KEY_POLICY_WRITERS).SerializeToString()))
694699

695700
# Add the orderer org groups MSPConfig info
696701
for ordererOrg in [org for org in directory.getOrganizations().values() if Network.Orderer in org.networks]:
@@ -856,6 +861,21 @@ def getVolumePath(self, composition, pathType=PathType.Local):
856861
def getLocalMspConfigPath(self, composition, compose_service, pathType=PathType.Local):
857862
return "{0}/{1}/localMspConfig".format(self.getVolumePath(composition, pathType), compose_service)
858863

864+
def _getPathAndUserInfo(self, directory , composition, compose_service, nat_discriminator="Signer", pathType=PathType.Local):
865+
matchingNATs = [nat for nat in directory.getNamedCtxTuples() if ((compose_service in nat.user) and (nat_discriminator in nat.user) and ((compose_service in nat.nodeName)))]
866+
assert len(matchingNATs)==1, "Unexpected number of matching NodeAdminTuples: {0}".format(matchingNATs)
867+
localMspConfigPath = self.getLocalMspConfigPath(composition=composition, compose_service=compose_service,pathType=pathType)
868+
return (localMspConfigPath, matchingNATs[0].user)
869+
870+
def getLocalMspConfigPrivateKeyPath(self, directory , composition, compose_service, pathType=PathType.Local):
871+
(localMspConfigPath, user) = self._getPathAndUserInfo(directory=directory, composition=composition, compose_service=compose_service, pathType=pathType)
872+
return "{0}/keystore/{1}.pem".format(localMspConfigPath, user)
873+
874+
def getLocalMspConfigPublicCertPath(self, directory , composition, compose_service, pathType=PathType.Local):
875+
(localMspConfigPath, user) = self._getPathAndUserInfo(directory=directory, composition=composition, compose_service=compose_service, pathType=pathType)
876+
return "{0}/signcerts/{1}.pem".format(localMspConfigPath, user)
877+
878+
859879
def _writeMspFiles(self, directory , composition, compose_service, network):
860880
localMspConfigPath = self.getLocalMspConfigPath(composition, compose_service)
861881
os.makedirs("{0}/{1}".format(localMspConfigPath, "signcerts"))
@@ -967,7 +987,12 @@ def getEnv(self, composition, context, env):
967987
localMspConfigPath = self.getLocalMspConfigPath(composition, peerService, pathType=PathType.Container)
968988
env["{0}_CORE_PEER_MSPCFGPATH".format(peerService.upper())] = localMspConfigPath
969989
env["{0}_CORE_PEER_LOCALMSPID".format(peerService.upper())] = self._getMspId(compose_service=peerService, directory=directory)
970-
990+
# TLS Settings
991+
# env["{0}_CORE_PEER_TLS_ENABLED".format(peerService.upper())] = self._getMspId(compose_service=peerService, directory=directory)
992+
env["{0}_CORE_PEER_TLS_CERT_FILE".format(peerService.upper())] = self.getLocalMspConfigPublicCertPath(
993+
directory=directory, composition=composition, compose_service=peerService, pathType=PathType.Container)
994+
env["{0}_CORE_PEER_TLS_KEY_FILE".format(peerService.upper())] = self.getLocalMspConfigPrivateKeyPath(
995+
directory=directory, composition=composition, compose_service=peerService, pathType=PathType.Container)
971996

972997
def createChainCreationPolicyNames(context, chainCreationPolicyNames, chaindId):
973998
channel = common_dot_configtx_pb2.ConfigGroup()

bddtests/steps/contexthelper.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@ def isConfigEnabled(self, configName):
7272
return self.context.config.userdata.get(configName, "false") == "true"
7373

7474
def before_scenario(self, scenario):
75-
print("before_scenario: {0}".format(self))
75+
# print("before_scenario: {0}".format(self))
76+
pass
7677

7778
def after_scenario(self, scenario):
78-
print("after_scenario: {0}".format(self))
79-
79+
# print("after_scenario: {0}".format(self))
80+
pass
8081

8182
def before_step(self, step):
82-
print("before_step: {0}".format(self))
83-
print("")
83+
# print("before_step: {0}".format(self))
84+
pass
8485

8586
def after_step(self, step):
86-
print("after_step: {0}".format(self))
87-
print("")
87+
# print("after_step: {0}".format(self))
88+
pass
8889

8990
def registerComposition(self, composition):
9091
return composition

bddtests/steps/docgen.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright IBM Corp. 2016 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
115

216
from StringIO import StringIO
317
from itertools import chain

bddtests/steps/endorser_util.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright IBM Corp. 2016 All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
115

216
import os
317
import json
@@ -136,7 +150,7 @@ def getExample02ChaincodeSpec():
136150
def _createDeploymentSpecAsFile(ccSpec, outputPath):
137151
'''peer chaincode package -n myCC -c '{"Args":["init","a","100","b","200"]}' -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 --logging-level=DEBUG test.file'''
138152
myEnv = os.environ.copy()
139-
myEnv['CORE_PEER_MSPCONFIGPATH'] = "./../msp/sampleConfig"
153+
myEnv['CORE_PEER_MSPCONFIGPATH'] = "./../msp/sampleconfig"
140154
nameArgs = ["-n", ccSpec.chaincode_id.name]
141155
ctorArgs = ["-c", json.dumps({'Args' : [item for item in ccSpec.input.args]})]
142156
pathArgs = ["-p", ccSpec.chaincode_id.path]

0 commit comments

Comments
 (0)