Skip to content

Commit

Permalink
[FAB-1141] Incorporate latest changes to protos
Browse files Browse the repository at this point in the history
Regenerated orderer proto files.

Removed references to ingress/egress policies.

Added default policies for all groups.

Now sign all envelopes.

Added readers/writers/admins to each group.

Now use SerializedIdentity as opposed to cert as PEM for
certChain.

Added value for BlockDataHashingDataStructure.width for channel
configs.

Removed peerOrg2 for now.  Will add later.

Addressed non-deterministic issue with lccc and MSP id sorting
for default endorsement policy handling.

Change-Id: I60b177ea6cf8464b3d35e85b45ef3f250941acdf
Signed-off-by: jeffgarratt <[email protected]>
  • Loading branch information
jeffgarratt committed Mar 8, 2017
1 parent 23872a2 commit 692effe
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 210 deletions.
2 changes: 1 addition & 1 deletion bddtests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def after_scenario(context, scenario):

# stop any running peer that could get in the way before starting the tests
def before_all(context):
cli_call(["../build/bin/peer", "node", "stop"], expect_success=False)
pass

# stop any running peer that could get in the way before starting the tests
def after_all(context):
Expand Down
28 changes: 18 additions & 10 deletions bddtests/features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,36 @@ Feature: Bootstrap
Scenario Outline: Bootstrap a development network with 4 peers (2 orgs) and 1 orderer (1 org), each having a single independent root of trust (No fabric-ca, just openssl)
#creates 1 self-signed key/cert pair per orderer organization
Given the orderer network has organizations:
| Organization |
| ordererOrg0 |
| Organization | Readers | Writers | Admins |
| ordererOrg0 | member | member | admin |

And user requests role of orderer admin by creating a key and csr for orderer and acquires signed certificate from organization:
| User | Orderer | Organization |
| orderer0Signer | orderer0 | ordererOrg0 |


# Rolenames : MspPrincipal.proto
And the peer network has organizations:
| Organization |
| peerOrg0 |
| peerOrg1 |
| peerOrg2 |
| Organization | Readers | Writers | Admins |
| peerOrg0 | member | member | admin |
| peerOrg1 | member | member | admin |
# | peerOrg2 | member | member | admin |



And a ordererBootstrapAdmin is identified and given access to all public certificates and orderer node info

And the ordererBootstrapAdmin creates a cert alias "bootstrapCertAlias" for orderer network bootstrap purposes for organizations
| Organization |
| ordererOrg0 |

And the ordererBootstrapAdmin generates a GUUID to identify the orderer system chain and refer to it by name as "OrdererSystemChainId"

And the ordererBootstrapAdmin creates a chain creators policy "chainCreatePolicy1" (network name) for peer orgs who wish to form a network using orderer system chain "OrdererSystemChainId":
| Organization |
| peerOrg0 |
| peerOrg1 |
| peerOrg2 |
# | peerOrg2 |

And the ordererBoostrapAdmin creates the chain creation policy names "chainCreationPolicyNames" for orderer system chain "OrdererSystemChainId" with policies:
|PolicyName |
Expand All @@ -50,7 +58,7 @@ Feature: Bootstrap

# Order info includes orderer admin/orderer information and address (host:port) from previous steps
# Only the peer organizations can vary.
And the ordererBootstrapAdmin creates the genesis block "ordererGenesisBlock" for chain "OrdererSystemChainId" for network config policy "<PolicyType>" and consensus "<ConsensusType>" using chain creators policies:
And the ordererBootstrapAdmin using cert alias "bootstrapCertAlias" creates the genesis block "ordererGenesisBlock" for chain "OrdererSystemChainId" for network config policy "<PolicyType>" and consensus "<ConsensusType>" using chain creators policies:
| ConfigGroup Names |
| chainCreatePolicy1 |
| chainCreationPolicyNames |
Expand Down Expand Up @@ -108,14 +116,14 @@ Feature: Bootstrap
| peerOrg0 |
| peerOrg1 |

And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1"
And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using cert alias "dev0Org0App1" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1"

And the user "dev0Org0" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "orderer0" to create channel "com.acme.blockchain.jdoe.Channel1"

# Sleep as the deliver takes a bit to have the first block ready
And I wait "2" seconds

When user "dev0Org0" connects to deliver function on orderer "orderer0"
When user "dev0Org0" using cert alias "dev0Org0App1" connects to deliver function on orderer "orderer0"
And user "dev0Org0" sends deliver a seek request on orderer "orderer0" with properties:
| ChainId | Start | End |
| com.acme.blockchain.jdoe.Channel1 | 0 | 0 |
Expand Down
3 changes: 1 addition & 2 deletions bddtests/orderer/ab_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities

import common.common_pb2 as common_dot_common__pb2
import orderer.ab_pb2 as orderer_dot_ab__pb2
import common.common_pb2 as common_dot_common__pb2
import orderer.ab_pb2 as orderer_dot_ab__pb2


class AtomicBroadcastStub(object):
Expand Down
88 changes: 5 additions & 83 deletions bddtests/orderer/configuration_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bddtests/orderer/configuration_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities
Expand Down
1 change: 1 addition & 0 deletions bddtests/orderer/kafka_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities as face_utilities
Expand Down
67 changes: 36 additions & 31 deletions bddtests/steps/bootstrap_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@
import compose
import time

class ChannelCreationInfo:
'Used to store the information needed to construct Config TX for orderer broadcast to create a new channel'
def __init__(self, channelId, channelCreationPolicyName, signedConfigEnvelope):
self.channelId = channelId
self.channelCreationPolicyName = channelCreationPolicyName
self.config_update_envelope = signedConfigEnvelope

def __repr__(self):
return "channelId = {0}\nchannelCreationPolicyName={1}\nconfigUpdateEnvelope={2}\n".format(self.channelId,
self.channelCreationPolicyName,
str(
self.config_update_envelope))



@given(u'the orderer network has organizations')
def step_impl(context):
assert 'table' in context, "Expected table of orderer organizations"
Expand Down Expand Up @@ -75,8 +60,9 @@ def step_impl(context):
# Simply create the user
bootstrap_util.getOrdererBootstrapAdmin(context, shouldCreate=True)

@given(u'the ordererBootstrapAdmin creates the genesis block "{ordererGenesisBlockName}" for chain "{ordererSystemChainIdName}" for network config policy "{networkConfigPolicy}" and consensus "{consensusType}" using chain creators policies')
def step_impl(context, ordererGenesisBlockName, ordererSystemChainIdName, networkConfigPolicy, consensusType):
@given(u'the ordererBootstrapAdmin using cert alias "{certAlias}" creates the genesis block "{ordererGenesisBlockName}" for chain "{ordererSystemChainIdName}" for network config policy "{networkConfigPolicy}" and consensus "{consensusType}" using chain creators policies')
def step_impl(context, certAlias, ordererGenesisBlockName, ordererSystemChainIdName, networkConfigPolicy, consensusType):
directory = bootstrap_util.getDirectory(context=context)
ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName]
# Now collect the named signed config items
Expand All @@ -87,7 +73,11 @@ def step_impl(context, ordererGenesisBlockName, ordererSystemChainIdName, networ
# Concatenate signedConfigItems

# Construct block
(genesisBlock,envelope) = bootstrap_util.createGenesisBlock(context, ordererSystemChainIdGUUID, consensusType, signedConfigItems=configGroups)
nodeAdminTuple = ordererBootstrapAdmin.tags[certAlias]
bootstrapCert = directory.findCertForNodeAdminTuple(nodeAdminTuple=nodeAdminTuple)
(genesisBlock, envelope) = bootstrap_util.createGenesisBlock(context, ordererSystemChainIdGUUID, consensusType,
nodeAdminTuple=nodeAdminTuple,
signedConfigItems=configGroups)
ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName, genesisBlock)
bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock)
bootstrap_util.PeerCompositionCallback(context)
Expand Down Expand Up @@ -170,7 +160,7 @@ def step_impl(context, userName, createChannelSignedConfigEnvelope):
#NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way
config_update_envelope = bootstrap_util.createConfigUpdateEnvelope(channelConfigGroup=channel_config_groups, chainId=channelID, chainCreationPolicyName=chainCreationPolicyName)

user.setTagValue(createChannelSignedConfigEnvelope, ChannelCreationInfo(channelID, chainCreationPolicyName, config_update_envelope))
user.setTagValue(createChannelSignedConfigEnvelope, config_update_envelope)

# Construct TX Config Envelope, broadcast, expect success, and then connect to deliver to revtrieve block.
# Make sure the blockdata exactly the TxConfigEnvelope I submitted.
Expand All @@ -192,23 +182,26 @@ def step_impl(context, userName, createChannelSignedConfigEnvelopeName):
assert 'table' in context, "Expected table of peer organizations"
directory = bootstrap_util.getDirectory(context)
user = directory.getUser(userName=userName)
# Get the ChannelCreationInfo object that holds the signedConfigEnvelope
channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName]
config_update_envelope = channelCreationInfo.config_update_envelope
config_update_envelope = user.tags[createChannelSignedConfigEnvelopeName]
for row in context.table.rows:
org = directory.getOrganization(row['Organization'])
assert bootstrap_util.Network.Peer in org.networks, "Organization '{0}' not in Peer network".format(org.name)
bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(config_update_envelope, (org, org.getSelfSignedCert()))
# print("Signatures for signedConfigEnvelope:\n {0}\n".format(signedConfigEnvelope.Items[0]))

@given(u'the user "{userName}" creates a ConfigUpdate Tx "{configUpdateTxName}" using signed ConfigUpdateEnvelope "{createChannelSignedConfigEnvelopeName}"')
def step_impl(context, userName, configUpdateTxName, createChannelSignedConfigEnvelopeName):
@given(u'the user "{userName}" creates a ConfigUpdate Tx "{configUpdateTxName}" using cert alias "{certAlias}" using signed ConfigUpdateEnvelope "{createChannelSignedConfigEnvelopeName}"')
def step_impl(context, userName, certAlias, configUpdateTxName, createChannelSignedConfigEnvelopeName):
directory = bootstrap_util.getDirectory(context)
user = directory.getUser(userName=userName)
channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName]
#TODO: this is temporary until partial update is supported. Normally you would just return
# this message and send directly to broadcast.
envelope_for_config_update = bootstrap_util.createConfigUpdateTxEnvelope(channelCreationInfo.channelId, channelCreationInfo.config_update_envelope)
namedAdminTuple = user.tags[certAlias]
cert = directory.findCertForNodeAdminTuple(namedAdminTuple)
config_update_envelope = user.tags[createChannelSignedConfigEnvelopeName]
config_update = bootstrap_util.getChannelIdFromConfigUpdateEnvelope(config_update_envelope)
envelope_for_config_update = bootstrap_util.createEnvelopeForMsg(directory=directory,
nodeAdminTuple=namedAdminTuple,
chainId=config_update.channel_id,
msg=config_update_envelope,
typeAsString="CONFIG_UPDATE")
user.setTagValue(configUpdateTxName, envelope_for_config_update)

@given(u'the user "{userName}" broadcasts ConfigUpdate Tx "{configTxName}" to orderer "{orderer}" to create channel "{channelId}"')
Expand All @@ -226,11 +219,13 @@ def step_impl(context, userName, transactionAlias, orderer, channelId):
bootstrap_util.broadcastCreateChannelConfigTx(context=context, composeService=orderer, chainId=channelId, user=user, configTxEnvelope=transaction)


@when(u'user "{userName}" connects to deliver function on orderer "{composeService}"')
def step_impl(context, userName, composeService):
@when(u'user "{userName}" using cert alias "{certAlias}" connects to deliver function on orderer "{composeService}"')
def step_impl(context, userName, certAlias, composeService):
directory = bootstrap_util.getDirectory(context)
user = directory.getUser(userName=userName)
user.connectToDeliverFunction(context, composeService)
nodeAdminTuple = user.tags[certAlias]
cert = directory.findCertForNodeAdminTuple(nodeAdminTuple)
user.connectToDeliverFunction(context, composeService, cert, nodeAdminTuple=nodeAdminTuple)

@when(u'user "{userName}" sends deliver a seek request on orderer "{composeService}" with properties')
def step_impl(context, userName, composeService):
Expand Down Expand Up @@ -336,3 +331,13 @@ def step_impl(context, userNameSource, objectAlias, userNameTarget):
userSource = directory.getUser(userName=userNameSource)
userTarget = directory.getUser(userName=userNameTarget)
userTarget.setTagValue(objectAlias, userSource.tags[objectAlias])

@given(u'the ordererBootstrapAdmin creates a cert alias "{certAlias}" for orderer network bootstrap purposes for organizations')
def step_impl(context, certAlias):
assert "table" in context, "Expected table of Organizations"
directory = bootstrap_util.getDirectory(context)
ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
assert len(context.table.rows) == 1, "Only support single orderer orgnaization at moment"
for row in context.table.rows:
nodeAdminNamedTuple = directory.registerOrdererAdminTuple(ordererBootstrapAdmin.name, "ordererBootstrapAdmin", row['Organization'])
ordererBootstrapAdmin.setTagValue(certAlias, nodeAdminNamedTuple)
Loading

0 comments on commit 692effe

Please sign in to comment.