Skip to content

Commit

Permalink
FABN-1415 NodeSDK update protos
Browse files Browse the repository at this point in the history
Pull in new protos and make code updates to use
the new policy type location.

Signed-off-by: Bret Harrison <[email protected]>
Change-Id: I8d75dabdef72073c62a40b24aea630011d07acd9
  • Loading branch information
harrisob committed Nov 13, 2019
1 parent ca321d1 commit e41f3b2
Show file tree
Hide file tree
Showing 41 changed files with 203 additions and 50 deletions.
3 changes: 2 additions & 1 deletion fabric-client/lib/Chaincode.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Policy = require('./Policy.js');
const CollectionConfig = require('./SideDB.js');
const TransactionID = require('./TransactionID');
const fabric_protos = require('fabric-protos').protos;
const fabric_common_protos = require('fabric-protos').common;
const lifecycle_protos = require('fabric-protos').lifecycle;

/**
Expand Down Expand Up @@ -384,7 +385,7 @@ const Chaincode = class {
const method = 'setEndorsementPolicyDefinition';
logger.debug('%s - start', method);

const application_policy = new fabric_protos.ApplicationPolicy();
const application_policy = new fabric_common_protos.ApplicationPolicy();

if (typeof policy === 'string') {
logger.debug('%s - have a policy reference :: %s', method, policy);
Expand Down
156 changes: 124 additions & 32 deletions fabric-protos/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,32 @@
}
]
},
{
"name": "ApplicationPolicy",
"syntax": "proto3",
"fields": [
{
"rule": "optional",
"type": "SignaturePolicyEnvelope",
"name": "signature_policy",
"id": 1,
"oneof": "Type"
},
{
"rule": "optional",
"type": "string",
"name": "channel_config_policy_reference",
"id": 2,
"oneof": "Type"
}
],
"oneofs": {
"Type": [
1,
2
]
}
},
{
"name": "CollectionConfigPackage",
"syntax": "proto3",
Expand Down Expand Up @@ -953,6 +979,12 @@
"type": "bool",
"name": "member_only_write",
"id": 7
},
{
"rule": "optional",
"type": "ApplicationPolicy",
"name": "endorsement_policy",
"id": 8
}
]
},
Expand All @@ -974,36 +1006,6 @@
]
}
},
{
"name": "CollectionCriteria",
"syntax": "proto3",
"fields": [
{
"rule": "optional",
"type": "string",
"name": "channel",
"id": 1
},
{
"rule": "optional",
"type": "string",
"name": "tx_id",
"id": 2
},
{
"rule": "optional",
"type": "string",
"name": "collection",
"id": 3
},
{
"rule": "optional",
"type": "string",
"name": "namespace",
"id": 4
}
]
},
{
"name": "LastConfig",
"syntax": "proto3",
Expand Down Expand Up @@ -1738,7 +1740,8 @@
"fields": [],
"syntax": "proto2",
"options": {
"go_package": "github.com/hyperledger/fabric-protos-go/gossip"
"go_package": "github.com/hyperledger/fabric-protos-go/gossip",
"java_package": "org.hyperledger.fabric.protos.gossip"
},
"messages": [
{
Expand Down Expand Up @@ -3027,7 +3030,8 @@
"fields": [],
"syntax": "proto2",
"options": {
"go_package": "github.com/hyperledger/fabric-protos-go/discovery"
"go_package": "github.com/hyperledger/fabric-protos-go/discovery",
"java_package": "org.hyperledger.fabric.protos.discovery"
},
"messages": [
{
Expand Down Expand Up @@ -4654,6 +4658,78 @@
}
]
},
{
"name": "CDSData",
"syntax": "proto3",
"fields": [
{
"rule": "optional",
"type": "bytes",
"name": "hash",
"id": 1
},
{
"rule": "optional",
"type": "bytes",
"name": "metadatahash",
"id": 2
}
]
},
{
"name": "ChaincodeData",
"syntax": "proto3",
"fields": [
{
"rule": "optional",
"type": "string",
"name": "name",
"id": 1
},
{
"rule": "optional",
"type": "string",
"name": "version",
"id": 2
},
{
"rule": "optional",
"type": "string",
"name": "escc",
"id": 3
},
{
"rule": "optional",
"type": "string",
"name": "vscc",
"id": 4
},
{
"rule": "optional",
"type": "common.SignaturePolicyEnvelope",
"name": "policy",
"id": 5
},
{
"rule": "optional",
"type": "bytes",
"name": "data",
"id": 6
},
{
"rule": "optional",
"type": "bytes",
"name": "id",
"id": 7
},
{
"rule": "optional",
"type": "common.SignaturePolicyEnvelope",
"name": "instantiation_policy",
"id": 8
}
]
},
{
"name": "SignedProposal",
"syntax": "proto3",
Expand Down Expand Up @@ -5445,6 +5521,9 @@
{
"name": "ApplicationPolicy",
"syntax": "proto3",
"options": {
"deprecated": true
},
"fields": [
{
"rule": "optional",
Expand Down Expand Up @@ -5644,6 +5723,19 @@
}
}
},
{
"name": "Chaincode",
"options": {},
"rpc": {
"Connect": {
"request": "ChaincodeMessage",
"request_stream": true,
"response": "ChaincodeMessage",
"response_stream": true,
"options": {}
}
}
},
{
"name": "Endorser",
"options": {},
Expand Down
2 changes: 1 addition & 1 deletion fabric-protos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
],
"dependencies": {
"grpc": "1.23.3",
"protobufjs": "5.0.3"
"protobufjs": "^5.0.3"
},
"devDependencies": {
"cpx": "^1.5.0",
Expand Down
13 changes: 3 additions & 10 deletions fabric-protos/protos/common/collection.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ message StaticCollectionConfig {
// write the data (if set to false, for example if you want to implement more granular
// access logic in the chaincode)
bool member_only_write = 7;
// a reference to a policy residing / managed in the config block
// to define the endorsement policy for this collection
ApplicationPolicy endorsement_policy= 8;
}


Expand All @@ -76,13 +79,3 @@ message CollectionPolicyConfig {
// 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;
}
Empty file modified fabric-protos/protos/common/common.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/common/configtx.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/common/configuration.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/common/ledger.proto
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions fabric-protos/protos/common/policies.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,19 @@ message ImplicitMetaPolicy {
string sub_policy = 1;
Rule rule = 2;
}

// ApplicationPolicy captures the diffenrent policy types that
// are set and evaluted at the application level.
message ApplicationPolicy {
oneof Type {
// SignaturePolicy type is used if the policy is specified as
// a combination (using threshold gates) of signatures from MSP
// principals
SignaturePolicyEnvelope signature_policy = 1;

// ChannelConfigPolicyReference is used when the policy is
// specified as a string that references a policy defined in
// the configuration of the channel
string channel_config_policy_reference = 2;
}
}
3 changes: 2 additions & 1 deletion fabric-protos/protos/discovery/protocol.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric-protos-go/discovery" ;
option go_package = "github.com/hyperledger/fabric-protos-go/discovery";
option java_package = "org.hyperledger.fabric.protos.discovery";

package discovery;

Expand Down
3 changes: 2 additions & 1 deletion fabric-protos/protos/gossip/message.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

syntax = "proto3";

option go_package = "github.com/hyperledger/fabric-protos-go/gossip" ;
option go_package = "github.com/hyperledger/fabric-protos-go/gossip";
option java_package = "org.hyperledger.fabric.protos.gossip";

package gossip;

Expand Down
Empty file modified fabric-protos/protos/ledger/queryresult/kv_query_result.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/ledger/rwset/kvrwset/kv_rwset.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/ledger/rwset/rwset.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/msp/identities.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/msp/msp_config.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/msp/msp_principal.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/ab.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/cluster.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/configuration.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/etcdraft/configuration.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/etcdraft/metadata.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/orderer/kafka.proto
100644 → 100755
Empty file.
41 changes: 41 additions & 0 deletions fabric-protos/protos/peer/chaincode.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ option go_package = "github.com/hyperledger/fabric-protos-go/peer";

package protos;

import "common/policies.proto";

//ChaincodeID contains the path as specified by the deploy transaction
//that created it as well as the hashCode that is generated by the
//system for the path. From the user level (ie, CLI, REST API and so on)
Expand Down Expand Up @@ -85,3 +87,42 @@ message ChaincodeInvocationSpec {
message LifecycleEvent {
string chaincode_name = 1;
}

// CDSData is data stored in the LSCC on instantiation of a CC
// for CDSPackage. This needs to be serialized for ChaincodeData
// hence the protobuf format
message CDSData {
bytes hash = 1; // hash of ChaincodeDeploymentSpec.code_package
bytes metadatahash = 2; // hash of ChaincodeID.name + ChaincodeID.version
}

// ChaincodeData defines the datastructure for chaincodes to be serialized by proto
// Type provides an additional check by directing to use a specific package after instantiation
// Data is Type specific (see CDSPackage and SignedCDSPackage)
message ChaincodeData {

// Name of the chaincode
string name = 1;

// Version of the chaincode
string version = 2;

// Escc for the chaincode instance
string escc = 3;

// Vscc for the chaincode instance
string vscc = 4;

// Policy endorsement policy for the chaincode instance
common.SignaturePolicyEnvelope policy = 5;

// Data data specific to the package
bytes data = 6;

// Id of the chaincode that's the unique fingerprint for the CC This is not
// currently used anywhere but serves as a good eyecatcher
bytes id = 7;

// InstantiationPolicy for the chaincode
common.SignaturePolicyEnvelope instantiation_policy = 8;
}
Empty file modified fabric-protos/protos/peer/chaincode_event.proto
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions fabric-protos/protos/peer/chaincode_shim.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,9 @@ message StateMetadataResult {
service ChaincodeSupport {
rpc Register(stream ChaincodeMessage) returns (stream ChaincodeMessage);
}

// Chaincode as a server - peer establishes a connection to the chaincode as a client
// Currently only supports a stream connection.
service Chaincode {
rpc Connect(stream ChaincodeMessage) returns (stream ChaincodeMessage);
}
Empty file modified fabric-protos/protos/peer/configuration.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/events.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/lifecycle/chaincode_definition.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/lifecycle/db.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/lifecycle/lifecycle.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/peer.proto
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions fabric-protos/protos/peer/policy.proto
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "common/policies.proto";
// ApplicationPolicy captures the diffenrent policy types that
// are set and evaluted at the application level.
message ApplicationPolicy {
option deprecated = true;
oneof Type {
// SignaturePolicy type is used if the policy is specified as
// a combination (using threshold gates) of signatures from MSP
Expand Down
Empty file modified fabric-protos/protos/peer/proposal.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/proposal_response.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/query.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/resources.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/signed_cc_dep_spec.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/peer/transaction.proto
100644 → 100755
Empty file.
Empty file modified fabric-protos/protos/transientstore/transientstore.proto
100644 → 100755
Empty file.
Loading

0 comments on commit e41f3b2

Please sign in to comment.