Skip to content

Commit

Permalink
FAB-9769 NodeSDK - update protos
Browse files Browse the repository at this point in the history
Update to latest protos

Change-Id: Iecbf787866f0eecb5dc6d929b1c72e6dde39742f
Signed-off-by: Bret Harrison <[email protected]>
  • Loading branch information
harrisob authored and zhaochy1990 committed May 3, 2018
1 parent 7401007 commit 2c127cb
Show file tree
Hide file tree
Showing 14 changed files with 796 additions and 58 deletions.
18 changes: 9 additions & 9 deletions fabric-client/lib/ChannelEventHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -1064,8 +1064,8 @@ var ChannelEventHub = class {

if(block.number) {
logger.debug('_processTxEvents filtered block num=%s', block.number);
if(block.filtered_tx) for(let index in block.filtered_tx) {
let filtered_transaction = block.filtered_tx[index];
if(block.filtered_transactions) for(let index in block.filtered_transactions) {
let filtered_transaction = block.filtered_transactions[index];
this._callTransactionListener(filtered_transaction.txid,
filtered_transaction.tx_validation_code,
block.number);
Expand Down Expand Up @@ -1113,14 +1113,14 @@ var ChannelEventHub = class {
}

if(block.number) {
if(block.filtered_tx) for(let index in block.filtered_tx) {
let filtered_transaction = block.filtered_tx[index];
if(block.filtered_transactions) for(let index in block.filtered_transactions) {
let filtered_transaction = block.filtered_transactions[index];
if(filtered_transaction.transaction_actions) {
if(filtered_transaction.transaction_actions.chaincode_actions) {
for(let index in filtered_transaction.transaction_actions.chaincode_actions) {
let chaincode_action = filtered_transaction.transaction_actions.chaincode_actions[index];

this._callChaincodeListener(chaincode_action.ccEvent,
this._callChaincodeListener(chaincode_action.chaincode_event,
block.number,
filtered_transaction.txid,
filtered_transaction.tx_validation_code,
Expand All @@ -1143,14 +1143,14 @@ var ChannelEventHub = class {
let chaincodeActionPayload = tx.actions[action_index].payload;
let propRespPayload = chaincodeActionPayload.action.proposal_response_payload;
let caPayload = propRespPayload.extension;
let ccEvent = caPayload.events;
logger.debug('_processChaincodeEvents - ccEvent %s',ccEvent);
let chaincode_event = caPayload.events;
logger.debug('_processChaincodeEvents - chaincode_event %s',chaincode_event);

let txStatusCodes = block.metadata.metadata[_commonProto.BlockMetadataIndex.TRANSACTIONS_FILTER];
let channel_header = block.data.data[index].payload.header.channel_header;
let val_code = txStatusCodes[index];

this._callChaincodeListener(ccEvent,
this._callChaincodeListener(chaincode_event,
block.header.number,
channel_header.tx_id,
val_code,
Expand All @@ -1170,7 +1170,7 @@ var ChannelEventHub = class {
}

_callChaincodeListener(chaincode_event, block_num, tx_id, val_code, filtered) {
logger.debug('_callChaincodeListener - ccEvent %s',chaincode_event);
logger.debug('_callChaincodeListener - chaincode_event %s',chaincode_event);
let cbtable = this._chaincodeRegistrants[chaincode_event.chaincode_id];
if (!cbtable) {
logger.debug('_callChaincodeListener - no chaincode listeners found');
Expand Down
76 changes: 76 additions & 0 deletions fabric-client/lib/protos/common/collection.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

syntax = "proto3";

import "common/policies.proto";

option go_package = "github.com/hyperledger/fabric/protos/common";
option java_package = "org.hyperledger.fabric.protos.common";

package common;

// CollectionConfigPackage represents an array of CollectionConfig
// messages; the extra struct is required because repeated oneof is
// forbidden by the protobuf syntax
message CollectionConfigPackage {
repeated CollectionConfig config = 1;
}

// CollectionConfig defines the configuration of a collection object;
// it currently contains a single, static type.
// Dynamic collections are deferred.
message CollectionConfig {
oneof payload {
StaticCollectionConfig static_collection_config = 1;
}
}


// StaticCollectionConfig constitutes the configuration parameters of a
// static collection object. Static collections are collections that are
// known at chaincode instantiation time, and that cannot be changed.
// Dynamic collections are deferred.
message StaticCollectionConfig {
// the name of the collection inside the denoted chaincode
string name = 1;
// a reference to a policy residing / managed in the config block
// to define which orgs have access to this collection’s private data
CollectionPolicyConfig member_orgs_policy = 2;
// The minimum number of peers private data will be sent to upon
// endorsement. The endorsement would fail if dissemination to at least
// this number of peers is not achieved.
int32 required_peer_count = 3;
// The maximum number of peers that private data will be sent to
// upon endorsement. This number has to be bigger than required_peer_count.
int32 maximum_peer_count = 4;
}


// Collection policy configuration. Initially, the configuration can only
// contain a SignaturePolicy. In the future, the SignaturePolicy may be a
// more general Policy. Instead of containing the actual policy, the
// configuration may in the future contain a string reference to a policy.
message CollectionPolicyConfig {
oneof payload {
// Initially, only a signature policy is supported.
SignaturePolicyEnvelope signature_policy = 1;
// Later, the SignaturePolicy will be replaced by a Policy.
// Policy policy = 1;
// A reference to a Policy is planned to be added later.
// string reference = 2;
}
}


// CollectionCriteria defines an element of a private data that corresponds
// to a certain transaction and collection
message CollectionCriteria {
string channel = 1;
string tx_id = 2;
string collection = 3;
string namespace = 4;
}
1 change: 1 addition & 0 deletions fabric-client/lib/protos/common/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum HeaderType {
DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
CHAINCODE_PACKAGE = 6; // Used for packaging chaincode artifacts for install
PEER_RESOURCE_UPDATE = 7; // Used for encoding updates to the peer resource configuration
PEER_ADMIN_OPERATION = 8; // Used for invoking an administrative operation on a peer
}

// This enum enlists indexes of the block metadata array
Expand Down
226 changes: 226 additions & 0 deletions fabric-client/lib/protos/discovery/protocol.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
// Copyright IBM Corp. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
syntax = "proto3";

import "gossip/message.proto";
import "msp/msp_config.proto";
import "msp/identities.proto";

option go_package = "github.com/hyperledger/fabric/protos/discovery" ;

package discovery;

// Discovery defines a service that serves information about the fabric network
// like which peers, orderers, chaincodes, etc.
service Discovery {
// Discover receives a signed request, and returns a response.
rpc Discover (SignedRequest) returns (Response) {}
}

// SignedRequest contains a serialized Request in the payload field
// and a signature.
// The identity that is used to verify the signature
// can be extracted from the authentication field of type AuthInfo
// in the Request itself after deserializing it.
message SignedRequest {
bytes payload = 1;
bytes signature = 2;
}

// Request contains authentication info about the client that sent the request
// and the queries it wishes to query the service
message Request {
// authentication contains information that the service uses to check
// the client's eligibility for the queries.
AuthInfo authentication = 1;
// queries
repeated Query queries = 2;
}

message Response {
// The results are returned in the same order of the queries
repeated QueryResult results = 1;
}

// AuthInfo aggregates authentication information that the server uses
// to authenticate the client
message AuthInfo {
// This is the identity of the client that is used to verify the signature
// on the SignedRequest's payload.
// It is a msp.SerializedIdentity in bytes form
bytes client_identity = 1;

// This is the hash of the client's TLS cert.
// When the network is running with TLS, clients that don't include a certificate
// will be denied access to the service.
// Since the Request is encapsulated with a SignedRequest (which is signed),
// this binds the TLS session to the enrollement identity of the client and
// therefore both authenticates the client to the server,
// and also prevents the server from relaying the request message to another server.
bytes client_tls_cert_hash = 2;
}

// Query asks for information in the context of a specific channel
message Query {
string channel = 1;
oneof query {
// ConfigQuery is used to query for the configuration of the channel,
// such as FabricMSPConfig, and rorderer endpoints.
// The client has to query a peer it trusts as it doesn't have means to self-verify
// the authenticity of the returned result.
// The result is returned in the form of ConfigResult.
ConfigQuery config_query = 2;

// PeerMembershipQuery queries for peers in a channel context,
// and returns PeerMembershipResult
PeerMembershipQuery peer_query = 3;

// ChaincodeQuery queries for chaincodes by their name and version.
// An empty version means any version can by returned.
ChaincodeQuery cc_query = 4;

// LocalPeerQuery queries for peers in a non channel context,
// and returns PeerMembershipResult
LocalPeerQuery local_peers = 5;
}
}

// QueryResult contains a result for a given Query.
// The corresponding Query can be inferred by the index of the QueryResult from
// its enclosing Response message.
// QueryResults are ordered in the same order as the Queries are ordered in their enclosing Request.
message QueryResult {
oneof result {
// Error indicates failure or refusal to process the query
Error error = 1;

// ConfigResult contains the configuration of the channel,
// such as FabricMSPConfig and orderer endpoints
ConfigResult config_result = 2;

// ChaincodeQueryResult contains information about chaincodes,
// and their corresponding endorsers
ChaincodeQueryResult cc_query_res = 3;

// PeerMembershipResult contains information about peers,
// such as their identity, endpoints, and channel related state.
PeerMembershipResult members = 4;
}
}

// ConfigQuery requests a ConfigResult
message ConfigQuery {

}

message ConfigResult {
// msps is a map from MSP_ID to FabricMSPConfig
map<string, msp.FabricMSPConfig> msps = 1;
// orderers is a map from MSP_ID to endpoint lists of orderers
map<string, Endpoints> orderers = 2;
}

// PeerMembershipQuery requests PeerMembershipResult
message PeerMembershipQuery {

}

// PeerMembershipResult contains peers mapped by their organizations (MSP_ID)
message PeerMembershipResult {
map<string, Peers> peers_by_org = 1;
}

// ChaincodeQuery requests ChaincodeQueryResults for a given
// list of chaincode invocations.
// Each invocation is a separate one, and the endorsement policy
// is evaluated independantly for each given interest.
message ChaincodeQuery {
repeated ChaincodeInterest interests = 1;
}

// ChaincodeInterest defines an interest about an endorsement
// for a specific single chaincode invocation.
// Multiple chaincode names indicate chaincode to chaincode invocations.
// Collections indicate the chaincode invocation includes collections.
message ChaincodeInterest {
repeated string chaincode_names = 1;
repeated string collection_names = 2;
}

// ChaincodeQueryResult contains EndorsementDescriptors for
// chaincodes
message ChaincodeQueryResult {
repeated EndorsementDescriptor content = 1;
}

// LocalPeerQuery queries for peers in a non channel context
message LocalPeerQuery {
}

// EndorsementDescriptor contains information about which peers can be used
// to request endorsement from, such that the endorsement policy would be fulfilled.
// Here is how to compute a set of peers to ask an endorsement from, given an EndorsementDescriptor:
// Let e: G --> P be the endorsers_by_groups field that maps a group to a set of peers.
// Note that applying e on a group g yields a set of peers.
// 1) Select a layout l: G --> N out of the layouts given.
// l is the quantities_by_group field of a Layout, and it maps a group to an integer.
// 2) R = {} (an empty set of peers)
// 3) For each group g in the layout l, compute n = l(g)
// 3.1) Denote P_g as a set of n random peers {p0, p1, ... p_n} selected from e(g)
// 3.2) R = R U P_g (add P_g to R)
// 4) The set of peers R is the peers the client needs to request endorsements from
message EndorsementDescriptor {
string chaincode = 1;
// Specifies the endorsers, separated to groups.
map<string, Peers> endorsers_by_groups = 2;

// Specifies options of fulfulling the endorsement policy.
// Each option lists the group names, and the amount of signatures needed
// from each group.
repeated Layout layouts = 3;
}

// Layout contains a mapping from a group name to number of peers
// that are needed for fulfilling an endorsement policy
message Layout {
// Specifies how many non repeated signatures of each group
// are needed for endorsement
map<string, uint32> quantities_by_group = 1;
}

// Peers contains a list of Peer(s)
message Peers {
repeated Peer peers = 1;
}

// Peer contains information about the peer such as its channel specific
// state, and membership information.
message Peer {
// This is an Envelope of a GossipMessage with a gossip.StateInfo message
gossip.Envelope state_info = 1;
// This is an Envelope of a GossipMessage with a gossip.AliveMessage message
gossip.Envelope membership_info = 2;

// This is the msp.SerializedIdentity of the peer, represented in bytes.
bytes identity = 3;
}

// Error denotes that something went wrong and contains the error message
message Error {
string content = 1;
}

// Endpoints is a list of Endpoint(s)
message Endpoints {
repeated Endpoint endpoint = 1;
}

// Endpoint is a combination of a host and a port
message Endpoint {
string host = 1;
uint32 port = 2;
}


Loading

0 comments on commit 2c127cb

Please sign in to comment.