Skip to content

Commit e71eedd

Browse files
author
Simon Stone
committed
[FAB-16473] Copy proto files into source control
This is a temporary fix to get the builds working again. After we're back to a working state, I plan on updating the code to use protobufjs 6, so that we can just pull the latest protos in again. The patch-package hack Gari put into the SDK won't work here, as we'd need to patch the code on the users system. The ideal solution is to move the fabric-protos module out of fabric-sdk-node and integrate it into the new fabric-protos repository, but apparently any additional updates to that CI is blocked for now: "we are not building more into github/azure until after 2.0" I don't really want to add a chaincode -> SDK dependency as that is bound to cause us issues come release time. Signed-off-by: Simon Stone <sstone1@uk.ibm.com> Change-Id: I7c868a9f1e31decb93e5fd89819638b84392b965
1 parent ef4c7aa commit e71eedd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4096
-809
lines changed

.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ node_modules/*
44
fabric-contract-api/node_modules/*
55
fabric-shim/node_modules/*
66
fabric-shim-crypto/node_modules/*
7-
fabric-shim/lib/protos/common/*
8-
fabric-shim/lib/protos/msp/*
9-
fabric-shim/lib/protos/peer/*
10-
fabric-shim/lib/protos/ledger/*
11-
fabric-shim/lib/protos/token/*
127
npm-shrinkwrap.json
138
npm-debug.log
149
.DS_Store

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ The "src" folder contains the resources to become part of the npm package, inclu
1212

1313
The "build" folder contains the "build" steps. This being javascript there's no need to compile, but special build steps are still needed to accomplish the following:
1414
* linting: to make sure we enforce a somewhat consistent coding style
15-
* dependency sharing: the proto files needed by the fabric-shim are a subset of what the fabric defines in the "protos" folder. They need to get copied to the proper locations for things to work, including the "src/lib/protos" folder so the code can load them
1615

1716
The "test" folder contains the unit and integration tests, as well as artefacts used by the tests
1817

@@ -78,7 +77,6 @@ The resulting folder structure should be:
7877
Before you launch a fabric network, run these commands from the fabric-chaincode-node folder first:
7978
```
8079
npm install
81-
gulp protos
8280
```
8381

8482
Next run this single command to bring up a basic network of one orderer (using "SOLO"), one peer (using CouchDB as state database), then create a channel called "mychannel", and join the peer to that channel:
@@ -177,7 +175,6 @@ In the output of the command, you should see the following indicating successful
177175
Alternatively you can use the `peer` binary to test the node.js chaincode. Change directory to the fabric-chaincode-node folder. Before launching the chaincode, run these commands first:
178176
```
179177
npm install
180-
gulp protos
181178
```
182179

183180
Run the following command to launch the test (replacing "192.168.1.64" with the IP address of the target peer):

build/protos.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

build/test/unit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ gulp.task('typescript_check', shell.task([
3131
ignoreErrors: false // once compile failed, throw error
3232
}));
3333

34-
gulp.task('test-headless', gulp.series(['lint', 'typescript_check', 'instrument', 'protos', 'test-schema'], function() {
34+
gulp.task('test-headless', gulp.series(['lint', 'typescript_check', 'instrument', 'test-schema'], function() {
3535
// this is needed to avoid a problem in tape-promise with adding
3636
// too many listeners to the "unhandledRejection" event
3737
process.setMaxListeners(0);
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
syntax = "proto3";
8+
9+
import "common/policies.proto";
10+
11+
option go_package = "github.com/hyperledger/fabric/protos/common";
12+
option java_package = "org.hyperledger.fabric.protos.common";
13+
14+
package common;
15+
16+
// CollectionConfigPackage represents an array of CollectionConfig
17+
// messages; the extra struct is required because repeated oneof is
18+
// forbidden by the protobuf syntax
19+
message CollectionConfigPackage {
20+
repeated CollectionConfig config = 1;
21+
}
22+
23+
// CollectionConfig defines the configuration of a collection object;
24+
// it currently contains a single, static type.
25+
// Dynamic collections are deferred.
26+
message CollectionConfig {
27+
oneof payload {
28+
StaticCollectionConfig static_collection_config = 1;
29+
}
30+
}
31+
32+
33+
// StaticCollectionConfig constitutes the configuration parameters of a
34+
// static collection object. Static collections are collections that are
35+
// known at chaincode instantiation time, and that cannot be changed.
36+
// Dynamic collections are deferred.
37+
message StaticCollectionConfig {
38+
// the name of the collection inside the denoted chaincode
39+
string name = 1;
40+
// a reference to a policy residing / managed in the config block
41+
// to define which orgs have access to this collection’s private data
42+
CollectionPolicyConfig member_orgs_policy = 2;
43+
// The minimum number of peers private data will be sent to upon
44+
// endorsement. The endorsement would fail if dissemination to at least
45+
// this number of peers is not achieved.
46+
int32 required_peer_count = 3;
47+
// The maximum number of peers that private data will be sent to
48+
// upon endorsement. This number has to be bigger than required_peer_count.
49+
int32 maximum_peer_count = 4;
50+
// The number of blocks after which the collection data expires.
51+
// For instance if the value is set to 10, a key last modified by block number 100
52+
// will be purged at block number 111. A zero value is treated same as MaxUint64
53+
uint64 block_to_live = 5;
54+
// The member only read access denotes whether only collection member clients
55+
// can read the private data (if set to true), or even non members can
56+
// read the data (if set to false, for example if you want to implement more granular
57+
// access logic in the chaincode)
58+
bool member_only_read = 6;
59+
}
60+
61+
62+
// Collection policy configuration. Initially, the configuration can only
63+
// contain a SignaturePolicy. In the future, the SignaturePolicy may be a
64+
// more general Policy. Instead of containing the actual policy, the
65+
// configuration may in the future contain a string reference to a policy.
66+
message CollectionPolicyConfig {
67+
oneof payload {
68+
// Initially, only a signature policy is supported.
69+
SignaturePolicyEnvelope signature_policy = 1;
70+
// Later, the SignaturePolicy will be replaced by a Policy.
71+
// Policy policy = 1;
72+
// A reference to a Policy is planned to be added later.
73+
// string reference = 2;
74+
}
75+
}
76+
77+
78+
// CollectionCriteria defines an element of a private data that corresponds
79+
// to a certain transaction and collection
80+
message CollectionCriteria {
81+
string channel = 1;
82+
string tx_id = 2;
83+
string collection = 3;
84+
string namespace = 4;
85+
}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
syntax = "proto3";
18+
19+
import "google/protobuf/timestamp.proto";
20+
21+
option go_package = "github.com/hyperledger/fabric/protos/common";
22+
option java_package = "org.hyperledger.fabric.protos.common";
23+
24+
package common;
25+
26+
// These status codes are intended to resemble selected HTTP status codes
27+
enum Status {
28+
UNKNOWN = 0;
29+
SUCCESS = 200;
30+
BAD_REQUEST = 400;
31+
FORBIDDEN = 403;
32+
NOT_FOUND = 404;
33+
REQUEST_ENTITY_TOO_LARGE = 413;
34+
INTERNAL_SERVER_ERROR = 500;
35+
NOT_IMPLEMENTED = 501;
36+
SERVICE_UNAVAILABLE = 503;
37+
}
38+
39+
enum HeaderType {
40+
// Prevent removed tag re-use
41+
// Uncomment after fabric-baseimage moves to 3.5.1
42+
// reserved 7;
43+
// reserved "PEER_RESOURCE_UPDATE";
44+
45+
MESSAGE = 0; // Used for messages which are signed but opaque
46+
CONFIG = 1; // Used for messages which express the channel config
47+
CONFIG_UPDATE = 2; // Used for transactions which update the channel config
48+
ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions
49+
ORDERER_TRANSACTION = 4; // Used internally by the orderer for management
50+
DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
51+
CHAINCODE_PACKAGE = 6; // Used for packaging chaincode artifacts for install
52+
PEER_ADMIN_OPERATION = 8; // Used for invoking an administrative operation on a peer
53+
TOKEN_TRANSACTION = 9; // Used to denote transactions that invoke token management operations
54+
}
55+
56+
// This enum enlists indexes of the block metadata array
57+
enum BlockMetadataIndex {
58+
SIGNATURES = 0; // Block metadata array position for block signatures
59+
LAST_CONFIG = 1; // Block metadata array position to store last configuration block sequence number
60+
TRANSACTIONS_FILTER = 2; // Block metadata array position to store serialized bit array filter of invalid transactions
61+
ORDERER = 3; /* Block metadata array position to store operational metadata for orderers e.g. For Kafka,
62+
this is where we store the last offset written to the local ledger */
63+
COMMIT_HASH = 4; /* Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates,
64+
and the COMMIT_HASH of the previous block */
65+
}
66+
67+
// LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index
68+
message LastConfig {
69+
uint64 index = 1;
70+
}
71+
72+
// Metadata is a common structure to be used to encode block metadata
73+
message Metadata {
74+
bytes value = 1;
75+
repeated MetadataSignature signatures = 2;
76+
}
77+
78+
message MetadataSignature {
79+
bytes signature_header = 1; // An encoded SignatureHeader
80+
bytes signature = 2; // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header
81+
}
82+
83+
message Header {
84+
bytes channel_header = 1;
85+
bytes signature_header = 2;
86+
}
87+
88+
// Header is a generic replay prevention and identity message to include in a signed payload
89+
message ChannelHeader {
90+
int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType
91+
92+
// Version indicates message protocol version
93+
int32 version = 2;
94+
95+
// Timestamp is the local time when the message was created
96+
// by the sender
97+
google.protobuf.Timestamp timestamp = 3;
98+
99+
// Identifier of the channel this message is bound for
100+
string channel_id = 4;
101+
102+
// An unique identifier that is used end-to-end.
103+
// - set by higher layers such as end user or SDK
104+
// - passed to the endorser (which will check for uniqueness)
105+
// - as the header is passed along unchanged, it will be
106+
// be retrieved by the committer (uniqueness check here as well)
107+
// - to be stored in the ledger
108+
string tx_id = 5;
109+
110+
// The epoch in which this header was generated, where epoch is defined based on block height
111+
// Epoch in which the response has been generated. This field identifies a
112+
// logical window of time. A proposal response is accepted by a peer only if
113+
// two conditions hold:
114+
// 1. the epoch specified in the message is the current epoch
115+
// 2. this message has been only seen once during this epoch (i.e. it hasn't
116+
// been replayed)
117+
uint64 epoch = 6;
118+
119+
// Extension that may be attached based on the header type
120+
bytes extension = 7;
121+
122+
// If mutual TLS is employed, this represents
123+
// the hash of the client's TLS certificate
124+
bytes tls_cert_hash = 8;
125+
}
126+
127+
message SignatureHeader {
128+
// Creator of the message, a marshaled msp.SerializedIdentity
129+
bytes creator = 1;
130+
131+
// Arbitrary number that may only be used once. Can be used to detect replay attacks.
132+
bytes nonce = 2;
133+
}
134+
135+
// Payload is the message contents (and header to allow for signing)
136+
message Payload {
137+
138+
// Header is included to provide identity and prevent replay
139+
Header header = 1;
140+
141+
// Data, the encoding of which is defined by the type in the header
142+
bytes data = 2;
143+
}
144+
145+
// Envelope wraps a Payload with a signature so that the message may be authenticated
146+
message Envelope {
147+
// A marshaled Payload
148+
bytes payload = 1;
149+
150+
// A signature by the creator specified in the Payload header
151+
bytes signature = 2;
152+
}
153+
154+
// This is finalized block structure to be shared among the orderer and peer
155+
// Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded
156+
// in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but
157+
// the Metadata is not.
158+
message Block {
159+
BlockHeader header = 1;
160+
BlockData data = 2;
161+
BlockMetadata metadata = 3;
162+
}
163+
164+
// BlockHeader is the element of the block which forms the block chain
165+
// The block header is hashed using the configured chain hashing algorithm
166+
// over the ASN.1 encoding of the BlockHeader
167+
message BlockHeader {
168+
uint64 number = 1; // The position in the blockchain
169+
bytes previous_hash = 2; // The hash of the previous block header
170+
bytes data_hash = 3; // The hash of the BlockData, by MerkleTree
171+
}
172+
173+
message BlockData {
174+
repeated bytes data = 1;
175+
}
176+
177+
message BlockMetadata {
178+
repeated bytes metadata = 1;
179+
}
180+
181+
// OrdererBlockMetadata defines metadata that is set by the ordering service.
182+
message OrdererBlockMetadata {
183+
LastConfig last_config = 1;
184+
bytes consenter_metadata = 2;
185+
}

0 commit comments

Comments
 (0)