You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 9, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+14-27Lines changed: 14 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ _chaintool_ is a toolchain to assist in various phases of [Hyperledger Fabric](h
8
8
9
9
### Why?
10
10
11
-
Current chaincode development is rather unstructured outside of the coarse-level callbacks for invoke or query passing a {function-name, argument-array} string-based tuple. The result of this is that input translation/validation is a manual, explicit, and likely fragile process in each chaincode function. Additionally, any potential chaincode consumer needs to study the chaincode source in order to ascertain its API.
11
+
Current chaincode development is rather unstructured outside of the coarse-level callbacks for Invoke() passing opaque bytes. The result of this is that input translation/validation is a manual, explicit, and likely fragile process in each chaincode function. Additionally, any potential chaincode consumer needs to study the chaincode source in order to ascertain its API.
12
12
13
13
Consider that some chaincode applications may employ confidentiality to hide their source, while others may wish to employ alternative programming languages. This aside, chaincode deployment lifecycles may be long enough to require us to be aware of managing potential API incompatibilities between the chaincode and its clients. It starts to become clear that there are some advantages to allowing chaincode to express its API interfaces in a way that is independent from the underlying implementation/language and in a manner that supports some form of schema management.
14
14
@@ -30,7 +30,7 @@ _chaintool_ provides some other benefits too, such as consistent language-neutra
@@ -60,7 +60,7 @@ In all cases, you may obtain subcommand specific help by invoking "chaintool _$s
60
60
61
61
```
62
62
$ chaintool package -h
63
-
chaintool version: v0.7
63
+
chaintool version: v0.10.1
64
64
65
65
Description: chaintool package - Package the chaincode into a CAR file for deployment
66
66
@@ -210,7 +210,7 @@ The only core requirement is that both _chaintool_ and the chosen Hyperledger ne
210
210
211
211
#### Interface Declarations
212
212
213
-
Interfaces (as included in ./src/interfaces) may be in one or two categories: Provided or Consumed. _Provided_ means that the chaincode implements the interface and supports having clients or other chaincode invoke methods as declared. Likewise, _consumed_ indicates that the chaincode expects to perform inter-chaincode invoke/query operations to a disparate chaincode instance that provides the interface. It is perfectly fine (though perhaps uncommon) for a chaincode to both provide and consume a given interface (such as for proxy contracts which may accept operations in a polymorphic manner before passing operations on to a concrete instance).
213
+
Interfaces (as included in ./src/interfaces) may be in one or two categories: Provided or Consumed. _Provided_ means that the chaincode implements the interface and supports having clients or other chaincode invoke methods as declared. Likewise, _consumed_ indicates that the chaincode expects to perform inter-chaincode invoke operations to a disparate chaincode instance that provides the interface. It is perfectly fine (though perhaps uncommon) for a chaincode to both provide and consume a given interface (such as for proxy contracts which may accept operations in a polymorphic manner before passing operations on to a concrete instance).
214
214
215
215
Both Provides and Consumes are expressed as an array of 1 or more entries. For example:
216
216
@@ -273,20 +273,14 @@ message BalanceResult {
273
273
int32 balance = 1;
274
274
}
275
275
276
-
transactions {
276
+
functions {
277
277
void MakePayment(PaymentParams) = 1;
278
278
void DeleteAccount(Entity) = 2;
279
-
}
280
-
281
-
queries {
282
-
BalanceResult CheckBalance(Entity) = 1;
279
+
BalanceResult CheckBalance(Entity) = 3;
283
280
}
284
281
```
285
282
286
-
The _message_ definitions are almost 1:1 with protobuf grammar. The largest divergence is w.r.t. the _transactions_ and _queries_ sections. These two are similar to one another as well as to the notion of service/rpc in protobuf grammar. The reason we diverged is for a few different reasons:
287
-
288
-
- Chaincode has a strong delineation between and invoke and a query, and it was important for the parser to be able to understand the breakdown so that the proper code could be emitted
289
-
- It was felt that the lack of "field indices" in the protobuf service/rpc grammar was a large shortcoming in ABI compatibility. Therefore, the grammar used here retains the notion of indices even for function calls.
283
+
The _message_ definitions are almost 1:1 with protobuf grammar. The largest divergence is w.r.t. the _functions_ section. This section is similiar to the notion of service/rpc in protobuf grammar. We diverged from the protobuf/grpc grammar because it was felt that the lack of "field indices" was a large shortcoming in ABI compatibility. Therefore, the grammar used here retains the notion of indices even for function calls.
290
284
291
285
The main purpose of the grammar is to define RPC functions. For reasons of ABI stability, it was decided that all RPCs will have the following properties:
292
286
- Be indexed (e.g. ABI depends on index stability, not function name)
@@ -316,23 +310,16 @@ message ChaincodeInput {
316
310
317
311
}
318
312
```
319
-
Chaintool deterministically maps transactions/queries declared within a CCI to an [encoded function name](#function-encoding), and expects the corresponding input parameter to be a base64 encoded protobuf message as the first and only arg string.
313
+
Chaintool deterministically maps functions declared within a CCI to an [encoded function name](#function-encoding), and expects the corresponding input parameter to be a base64 encoded protobuf message as the first and only arg string.
Function naming follows the convention *interface-name/method-type/method-index*. For instance, invoking *MakePayment* from our [example](./examples/example02/app/src/interfaces/org.hyperledger.chaincode.example02.cci) would be *org.hyperledger.chaintool.example02/txn/1*. Because its transaction #1 in the org.hyperledger.chaintool.example02 interface.
329
-
330
-
##### Method Types
331
-
332
-
There are two types of methods: transactions and queries. We therefore have two values in the function name that correspond to the underlying method type:
333
-
334
-
- "txn" - transactions
335
-
- "query" - queries
322
+
Function naming follows the convention *interface-name/method-type/method-index*. For instance, invoking *MakePayment* from our [example](./examples/example02/app/src/interfaces/org.hyperledger.chaincode.example02.cci) would be *org.hyperledger.chaintool.example02/fcn/1*. Because its function #1 in the org.hyperledger.chaintool.example02 interface.
336
323
337
324
### Output Protocol
338
325
@@ -368,9 +355,9 @@ message PaymentParams {
368
355
//
369
356
// Available RPC functions exported by this interface
Copy file name to clipboardExpand all lines: examples/example02/README.md
+23-35Lines changed: 23 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,48 +14,36 @@ This directory contains an implementation of the chaincode application called "e
14
14
│ ├── appinit.cci
15
15
│ └── org.hyperledger.chaincode.example02.cci
16
16
└── client
17
-
├── rest
18
-
│ ├── cljs
19
-
│ │ ├── Makefile
20
-
│ │ ├── appinit.proto
21
-
│ │ ├── org.hyperledger.chaincode.example02.proto
22
-
│ │ ├── project.clj
23
-
│ │ └── src
24
-
│ │ └── example02
25
-
│ │ ├── core.cljs
26
-
│ │ ├── main.cljs
27
-
│ │ └── rpc.cljs
28
-
│ └── nodejs
29
-
│ ├── appinit.proto
30
-
│ ├── index.js
31
-
│ ├── org.hyperledger.chaincode.example02.proto
32
-
│ └── package.json
33
-
└── sdk
34
-
├── Makefile
17
+
├── cljs
18
+
│ ├── Makefile
19
+
│ ├── appinit.proto
20
+
│ ├── org.hyperledger.chaincode.example02.proto
21
+
│ ├── project.clj
22
+
│ └── src
23
+
│ └── example02
24
+
│ ├── core.cljs
25
+
│ ├── hlc
26
+
│ │ ├── core.cljs
27
+
│ │ └── user.cljs
28
+
│ ├── main.cljs
29
+
│ ├── rpc.cljs
30
+
│ └── util.cljs
31
+
└── nodejs
35
32
├── appinit.proto
33
+
├── index.js
34
+
├── util.js
36
35
├── org.hyperledger.chaincode.example02.proto
37
-
├── project.clj
38
-
└── src
39
-
└── example02
40
-
├── core.cljs
41
-
├── hlc
42
-
│ ├── core.cljs
43
-
│ └── user.cljs
44
-
├── main.cljs
45
-
├── rpc.cljs
46
-
└── util.cljs
36
+
└── package.json
47
37
```
48
38
* app - contains a org.hyperledger.chaincode.golang platform based chaincode application.
49
39
* This is the code deployed to the blockchain
50
40
* client - client applications for interacting with the chaincode application
51
-
* rest - REST api based clients
52
-
* nodejs - A simple demonstration of using nodejs+REST.
53
-
* cljs - A complete client for example02 over REST written in ClojureScript
54
-
* sdk - SDK based client, written in ClojureScript
41
+
* nodejs - A simple demonstration of using nodejs.
42
+
* cljs - A complete client for example02 written in ClojureScript
55
43
56
44
## Deploying and interacting with the example02
57
45
### Step 1 - Fabric environment
58
-
You will need a functioning peer that has chaintool v0.7 or higher available in the $PATH. You may check the version of chaintool you have with 'chaintool -h'. Once confirmed, start the peer with _peer node start_ as you normally would. It is advised to keep the configuration as simple as possible (1 VP, no security, noops consensus)
46
+
You will need a functioning peer that has chaintool v0.10.1 or higher available in the $PATH. You may check the version of chaintool you have with 'chaintool -h'. Once confirmed, start the peer with _peer node start_ as you normally would. It is advised to keep the configuration as simple as possible (1 VP, no security, noops consensus)
59
47
60
48
### Step 2 - Package the chaincode application
61
49
Run 'chaintool package' from the app folder, noting the CAR output path
The _chaintool package_ command is designed to package for deployment, not development. If you started your node with _peer node start --peer-chaincodedev_, run _chaintool build_ instead. This is analogous to building non-chaintool chaincode using _go build_. The output will be placed in the _app/build/bin/_ directory.
0 commit comments