Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit a4641aa

Browse files
cdaughtrharrisob
authored andcommitted
node-sdk Implement new cc install / deploy
Need to implement new remote install and deploy replacing the prior sendDeploymentProposal with sendInstallProposal and sendDeploymentProposal. Protos also needed to be updated to sync up with latest changes in fabric. Change-Id: I69ac98a39292eb20c71cfa2bab74e558522f84b4 Signed-off-by: cdaughtr <cdaughtr@us.ibm.com> Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
1 parent 59a96ce commit a4641aa

20 files changed

+687
-235
lines changed

fabric-client/lib/Chain.js

Lines changed: 235 additions & 60 deletions
Large diffs are not rendered by default.

fabric-client/lib/EventHub.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,23 @@ var EventHub = class {
124124
eh.blockRegistrants.forEach(function(cb) {
125125
cb(event.block);
126126
});
127-
event.block.Data.Data.forEach(function(transaction) {
127+
event.block.data.data.forEach(function(transaction) {
128128
try {
129129
var env = _common.Envelope.decode(transaction);
130130
var payload = _common.Payload.decode(env.payload);
131-
if (payload.header.chainHeader.type == _common.HeaderType.ENDORSER_TRANSACTION) {
131+
if (payload.header.channel_header.type == _common.HeaderType.ENDORSER_TRANSACTION) {
132132
var tx = _transProto.Transaction.decode(payload.data);
133133
var chaincodeActionPayload = _ccTransProto.ChaincodeActionPayload.decode(tx.actions[0].payload);
134134
var propRespPayload = _responseProto.ProposalResponsePayload
135-
.decode(chaincodeActionPayload.action.proposalResponsePayload);
135+
.decode(chaincodeActionPayload.action.proposal_response_payload);
136136
var caPayload = _ccProposalProto.ChaincodeAction.decode(propRespPayload.extension);
137137
var ccEvent = _ccEventProto.ChaincodeEvent.decode(caPayload.events);
138-
var cbtable = eh.chaincodeRegistrants.get(ccEvent.chaincodeID);
138+
var cbtable = eh.chaincodeRegistrants.get(ccEvent.chaincode_id);
139139
if (!cbtable) {
140140
return;
141141
}
142142
cbtable.forEach(function(cbe) {
143-
if (cbe.eventNameFilter.test(ccEvent.eventName)) {
143+
if (cbe.eventNameFilter.test(ccEvent.event_name)) {
144144
cbe.cb(ccEvent);
145145
}
146146
});
@@ -287,17 +287,17 @@ var EventHub = class {
287287
txCallback(block) {
288288
logger.debug('txCallback block=%j', block);
289289
var eh = this;
290-
block.Data.Data.forEach(function(transaction) {
290+
block.data.data.forEach(function(transaction) {
291291
try {
292292
var env = _common.Envelope.decode(transaction);
293293
var payload = _common.Payload.decode(env.payload);
294294
} catch (err) {
295295
logger.error('Error unmarshalling transaction from block=', err);
296296
}
297-
logger.debug('txid=' + payload.header.chainHeader.txID);
298-
var cb = eh.txRegistrants.get(payload.header.chainHeader.txID);
297+
logger.debug('txid=' + payload.header.channel_header.tx_id);
298+
var cb = eh.txRegistrants.get(payload.header.channel_header.tx_id);
299299
if (cb)
300-
cb(transaction.txid);
300+
cb(payload.header.channel_header.tx_id);
301301
});
302302
};
303303
};

fabric-client/lib/protos/common/common.proto

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ enum Status {
3636

3737
enum HeaderType {
3838
MESSAGE = 0; // Used for messages which are signed but opaque
39-
CONFIGURATION_TRANSACTION = 1; // Used for messages which reconfigure the chain
40-
CONFIGURATION_ITEM = 2; // Used inside of the the reconfiguration message for signing over ConfigurationItems
39+
CONFIG = 1; // Used for messages which express the channel config
40+
CONFIG_UPDATE = 2; // Used for transactions which update the channel config
4141
ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions
4242
ORDERER_TRANSACTION = 4; // Used internally by the orderer for management
4343
DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
@@ -46,14 +46,14 @@ enum HeaderType {
4646
// This enum enlists indexes of the block metadata array
4747
enum BlockMetadataIndex {
4848
SIGNATURES = 0; // Block metadata array position for block signatures
49-
LAST_CONFIGURATION = 1; // Block metadata array poistion to store last configuration block sequence number
49+
LAST_CONFIG = 1; // Block metadata array poistion to store last configuration block sequence number
5050
TRANSACTIONS_FILTER = 2; // Block metadata array poistion to store serialized bit array filter of invalid transactions
5151
ORDERER = 3; // Block metadata array position to store operational metadata for orderers
5252
// e.g. For Kafka, this is where we store the last offset written to the local ledger.
5353
}
5454

55-
// LastConfiguration is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index
56-
message LastConfiguration {
55+
// LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index
56+
message LastConfig {
5757
uint64 index = 1;
5858
}
5959

@@ -64,17 +64,17 @@ message Metadata {
6464
}
6565

6666
message MetadataSignature {
67-
bytes signatureHeader = 1; // An encoded SignatureHeader
67+
bytes signature_header = 1; // An encoded SignatureHeader
6868
bytes signature = 2; // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header
6969
}
7070

7171
message Header {
72-
ChainHeader chainHeader = 1;
73-
SignatureHeader signatureHeader = 2;
72+
ChannelHeader channel_header = 1;
73+
SignatureHeader signature_header = 2;
7474
}
7575

7676
// Header is a generic replay prevention and identity message to include in a signed payload
77-
message ChainHeader {
77+
message ChannelHeader {
7878
int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType
7979

8080
// Version indicates message protocol version
@@ -84,16 +84,16 @@ message ChainHeader {
8484
// by the sender
8585
google.protobuf.Timestamp timestamp = 3;
8686

87-
// Identifier of the chain this message is bound for
88-
string chainID = 4;
87+
// Identifier of the channel this message is bound for
88+
string channel_id = 4;
8989

9090
// An unique identifier that is used end-to-end.
9191
// - set by higher layers such as end user or SDK
9292
// - passed to the endorser (which will check for uniqueness)
9393
// - as the header is passed along unchanged, it will be
9494
// be retrieved by the committer (uniqueness check here as well)
9595
// - to be stored in the ledger
96-
string txID = 5;
96+
string tx_id = 5;
9797

9898
// The epoch in which this header was generated, where epoch is defined based on block height
9999
// Epoch in which the response has been generated. This field identifies a
@@ -140,24 +140,24 @@ message Envelope {
140140
// in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but
141141
// the Metadata is not.
142142
message Block {
143-
BlockHeader Header = 1;
144-
BlockData Data = 2;
145-
BlockMetadata Metadata = 3;
143+
BlockHeader header = 1;
144+
BlockData data = 2;
145+
BlockMetadata metadata = 3;
146146
}
147147

148148
// BlockHeader is the element of the block which forms the block chain
149149
// The block header is hashed using the configured chain hashing algorithm
150150
// over the ASN.1 encoding of the BlockHeader
151151
message BlockHeader {
152-
uint64 Number = 1; // The position in the blockchain
153-
bytes PreviousHash = 2; // The hash of the previous block header
154-
bytes DataHash = 3; // The hash of the BlockData, by MerkleTree
152+
uint64 number = 1; // The position in the blockchain
153+
bytes previous_hash = 2; // The hash of the previous block header
154+
bytes data_hash = 3; // The hash of the BlockData, by MerkleTree
155155
}
156156

157157
message BlockData {
158-
repeated bytes Data = 1;
158+
repeated bytes data = 1;
159159
}
160160

161161
message BlockMetadata {
162-
repeated bytes Metadata = 1;
162+
repeated bytes metadata = 1;
163163
}

fabric-client/lib/protos/common/configtx.proto

Lines changed: 74 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,97 @@ limitations under the License.
2020
syntax = "proto3";
2121

2222
import "common.proto";
23+
import "policies.proto";
2324

2425
option go_package = "github.com/hyperledger/fabric/protos/common";
2526

2627
package common;
2728

28-
// ConfigurationEnvelope is designed to contain _all_ configuration for a chain with no dependency
29+
// ConfigEnvelope is designed to contain _all_ configuration for a chain with no dependency
2930
// on previous configuration transactions.
3031
//
3132
// It is generated with the following scheme:
3233
// 1. Retrieve the existing configuration
33-
// 2. Note the highest configuration sequence number, store it and increment it by one
34-
// 3. Modify desired ConfigurationItems, setting each LastModified to the stored and incremented sequence number
35-
// a) Note that the ConfigurationItem has a ChainHeader header attached to it, who's type is set to CONFIGURATION_ITEM
36-
// 4. Update SignedConfigurationItem with appropriate signatures over the modified ConfigurationItem
37-
// a) Each signature is of type ConfigurationSignature
38-
// b) The ConfigurationSignature signature is over the concatenation of signatureHeader and the ConfigurationItem bytes (which includes a ChainHeader)
39-
// 5. Submit new Configuration for ordering in Envelope signed by submitter
40-
// a) The Envelope Payload has data set to the marshaled ConfigurationEnvelope
41-
// b) The Envelope Payload has a header of type Header.Type.CONFIGURATION_TRANSACTION
34+
// 2. Note the config properties (ConfigValue, ConfigPolicy, ConfigGroup) to be modified
35+
// 3. Add any intermediate ConfigGroups to the ConfigUpdate.read_set (sparsely)
36+
// 4. Add any additional desired dependencies to ConfigUpdate.read_set (sparsely)
37+
// 5. Modify the config properties, incrementing each version by 1, set them in the ConfigUpdate.write_set
38+
// Note: any element not modified but specified should already be in the read_set, so may be specified sparsely
39+
// 6. Create ConfigUpdate message and marshal it into ConfigUpdateEnvelope.update and encode the required signatures
40+
// a) Each signature is of type ConfigSignature
41+
// b) The ConfigSignature signature is over the concatenation of signature_header and the ConfigUpdate bytes (which includes a ChainHeader)
42+
// 5. Submit new Config for ordering in Envelope signed by submitter
43+
// a) The Envelope Payload has data set to the marshaled ConfigEnvelope
44+
// b) The Envelope Payload has a header of type Header.Type.CONFIG_UPDATE
4245
//
4346
// The configuration manager will verify:
44-
// 1. All configuration items and the envelope refer to the correct chain
45-
// 2. Some configuration item has been added or modified
46-
// 3. No existing configuration item has been ommitted
47-
// 4. All configuration changes have a LastModification of one more than the last configuration's highest LastModification number
48-
// 5. All configuration changes satisfy the corresponding modification policy
49-
message ConfigurationEnvelope {
50-
repeated SignedConfigurationItem Items = 1;
51-
52-
// XXX This needs to be signed over, purely temporary pending completion of https://jira.hyperledger.org/browse/FAB-1880
53-
ChainHeader header = 2;
47+
// 1. All items in the read_set exist at the read versions
48+
// 2. All items in the write_set at a different version than, or not in, the read_set have been appropriately signed according to their mod_policy
49+
// 3. The new configuration satisfies the ConfigSchema
50+
message ConfigEnvelope {
51+
Config config = 1; // A marshaled Config structure
52+
ConfigUpdateEnvelope last_update = 2; // The most recent ConfigUpdateEnvelope whose diff generated the current config
5453
}
5554

56-
// ConfigurationTemplate is used as a serialization format to share configuration templates
57-
// The orderer supplies a configuration template to the user to use when constructing a new
58-
// chain creation transaction, so this is used to facilitate that.
59-
message ConfigurationTemplate {
60-
repeated ConfigurationItem Items = 1;
55+
message ConfigGroupSchema {
56+
map<string, ConfigGroupSchema> groups = 1;
57+
map<string, ConfigValueSchema> values = 2;
58+
map<string, ConfigPolicySchema> policies = 3;
6159
}
6260

63-
// This message may change slightly depending on the finalization of signature schemes for transactions
64-
message SignedConfigurationItem {
65-
bytes ConfigurationItem = 1;
66-
repeated ConfigurationSignature Signatures = 2;
61+
message ConfigValueSchema {}
62+
63+
message ConfigPolicySchema {}
64+
65+
// Config represents the config for a particular channel
66+
message Config {
67+
ChannelHeader header = 1;
68+
ConfigGroup channel = 2;
69+
}
70+
71+
message ConfigUpdateEnvelope {
72+
bytes config_update = 1; // A marshaled ConfigUpdate structure
73+
repeated ConfigSignature signatures = 2; // Signatures over the config_update
74+
}
75+
76+
// ConfigUpdate is used to submit a subset of config and to have the orderer apply to Config
77+
// it is always submitted inside a ConfigUpdateEnvelope which allows the addition of signatures
78+
// resulting in a new total configuration. The update is applied as follows:
79+
// 1. The versions from all of the elements in the read_set is verified against the versions in the existing config.
80+
// If there is a mismatch in the read versions, then the config update fails and is rejected.
81+
// 2. Any elements in the write_set with the same version as the read_set are ignored.
82+
// 3. The corresponding mod_policy for every remaining element in the write_set is collected.
83+
// 4. Each policy is checked against the signatures from the ConfigUpdateEnvelope, any failing to verify are rejected
84+
// 5. The write_set is applied to the Config and the ConfigGroupSchema verifies that the updates were legal
85+
message ConfigUpdate {
86+
ChannelHeader header = 1; // Header scopes the update to a particular Channel
87+
ConfigGroup read_set = 2; // ReadSet explicitly lists the portion of the config which was read, this should be sparse with only Version set
88+
ConfigGroup write_set = 3; // WriteSet lists the portion of the config which was written, this should included updated Versions
89+
}
90+
91+
// ConfigGroup is the hierarchical data structure for holding config
92+
message ConfigGroup {
93+
uint64 version = 1;
94+
map<string,ConfigGroup> groups = 2;
95+
map<string,ConfigValue> values = 3;
96+
map<string,ConfigPolicy> policies = 4;
97+
string mod_policy = 5;
98+
}
99+
100+
// ConfigValue represents an individual piece of config data
101+
message ConfigValue {
102+
uint64 version = 1;
103+
bytes value = 2;
104+
string mod_policy = 3;
67105
}
68106

69-
message ConfigurationItem {
70-
enum ConfigurationType {
71-
Policy = 0; // Implies that the Value is a marshaled Policy message, and may be referred to by Key as a ModificationPolicy
72-
Chain = 1; // Marshaled format for this type is yet to be determined
73-
Orderer = 2; // Marshaled format for this type is yet to be determined
74-
Peer = 3; // Marshaled format for this type is yet to be determined
75-
MSP = 4; // Marshaled MSPConfig proto
76-
}
77-
ConfigurationType Type = 1; // The type of configuration this is.
78-
uint64 LastModified = 2; // The Sequence number in the ConfigurationEnvelope this item was last modified
79-
string ModificationPolicy = 3; // What policy to check before allowing modification
80-
string Key = 4; // A unique ID, unique scoped by Type, to reference the value by
81-
bytes Value = 5; // The byte representation of this configuration, usually a marshaled message
107+
message ConfigPolicy {
108+
uint64 version = 1;
109+
Policy policy = 2;
110+
string mod_policy = 3;
82111
}
83112

84-
message ConfigurationSignature {
85-
bytes signatureHeader = 1; // A marshaled SignatureHeader
86-
bytes signature = 2; // Signature over the concatenation of configurationItem bytes and signatureHeader bytes
113+
message ConfigSignature {
114+
bytes signature_header = 1; // A marshaled SignatureHeader
115+
bytes signature = 2; // Signature over the concatenation signatureHeader bytes and config bytes
87116
}

fabric-client/lib/protos/common/msp_principal.proto

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ package common;
4949
message MSPPrincipal {
5050

5151
enum Classification {
52-
ByMSPRole = 0; // Represents the one of the dedicated MSP roles, the
52+
ROLE = 0; // Represents the one of the dedicated MSP roles, the
5353
// one of a member of MSP network, and the one of an
5454
// administrator of an MSP network
55-
ByOrganizationUnit = 1; // Denotes a finer grained (affiliation-based)
55+
ORGANIZATION_UNIT = 1; // Denotes a finer grained (affiliation-based)
5656
// groupping of entities, per MSP affiliation
5757
// E.g., this can well be represented by an MSP's
5858
// Organization unit
59-
ByIdentity = 2; // Denotes a principal that consists of a single
59+
IDENTITY = 2; // Denotes a principal that consists of a single
6060
// identity
6161
}
6262

@@ -67,14 +67,14 @@ message MSPPrincipal {
6767
// "Principal" contains a specific identity. Default value
6868
// denotes that Principal contains one of the groups by
6969
// default supported by all MSPs ("admin" or "member").
70-
Classification PrincipalClassification = 1;
70+
Classification principal_classification = 1;
7171

7272
// Principal completes the policy principal definition. For the default
7373
// principal types, Principal can be either "Admin" or "Member".
7474
// For the ByOrganizationUnit/ByIdentity values of Classification,
7575
// PolicyPrincipal acquires its value from an organization unit or
7676
// identity, respectively.
77-
bytes Principal = 2;
77+
bytes principal = 2;
7878
}
7979

8080

@@ -85,11 +85,11 @@ message OrganizationUnit {
8585

8686
// MSPIdentifier represents the identifier of the MSP this organization unit
8787
// refers to
88-
string MSPIdentifier = 1;
88+
string msp_identifier = 1;
8989

9090
// OrganizationUnitIdentifier defines the organization unit under the
9191
// MSP identified with MSPIdentifier
92-
string OrganizationUnitIdentifier = 2;
92+
string organizational_unit_identifier = 2;
9393

9494
}
9595

@@ -100,11 +100,11 @@ message MSPRole {
100100

101101
// MSPIdentifier represents the identifier of the MSP this principal
102102
// refers to
103-
string MSPIdentifier = 1;
103+
string msp_identifier = 1;
104104

105105
enum MSPRoleType {
106-
Member = 0; // Represents an MSP Member
107-
Admin = 1; // Represents an MSP Admin
106+
MEMBER = 0; // Represents an MSP Member
107+
ADMIN = 1; // Represents an MSP Admin
108108
}
109109

110110
// MSPRoleType defines which of the available, pre-defined MSP-roles

fabric-client/lib/protos/common/policies.proto

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
syntax = "proto3";
1818

19+
import "common.proto";
1920
import "msp_principal.proto";
2021

2122
option go_package = "github.com/hyperledger/fabric/protos/common";
@@ -36,9 +37,9 @@ message Policy {
3637

3738
// SignaturePolicyEnvelope wraps a SignaturePolicy and includes a version for future enhancements
3839
message SignaturePolicyEnvelope {
39-
int32 Version = 1;
40-
SignaturePolicy Policy = 2;
41-
repeated MSPPrincipal Identities = 3;
40+
int32 version = 1;
41+
SignaturePolicy policy = 2;
42+
repeated MSPPrincipal identities = 3;
4243
}
4344

4445
// SignaturePolicy is a recursive message structure which defines a featherweight DSL for describing
@@ -50,10 +51,10 @@ message SignaturePolicyEnvelope {
5051
message SignaturePolicy {
5152
message NOutOf {
5253
int32 N = 1;
53-
repeated SignaturePolicy Policies = 2;
54+
repeated SignaturePolicy policies = 2;
5455
}
5556
oneof Type {
56-
int32 SignedBy = 1;
57-
NOutOf From = 2;
57+
int32 signed_by = 1;
58+
NOutOf from = 2;
5859
}
5960
}

0 commit comments

Comments
 (0)