Skip to content

Commit

Permalink
Added: node CC and metadata support, node CC examples
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Klenik <[email protected]>
  • Loading branch information
aklenik committed Jul 11, 2018
1 parent d437bc1 commit 1e5fc4a
Show file tree
Hide file tree
Showing 24 changed files with 2,051 additions and 18 deletions.
42 changes: 42 additions & 0 deletions benchmark/marbles/config-fabric-go.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"blockchain": {
"type": "fabric",
"config": "benchmark/marbles/fabric-go.json"
},
"command" : {
"start": "docker-compose -f network/fabric/2-org-1-peer/docker-compose-tls.yaml up -d",
"end" : "docker-compose -f network/fabric/2-org-1-peer/docker-compose-tls.yaml down;docker rm $(docker ps -aq);docker rmi $(docker images dev* -q)"
},
"test": {
"clients": {
"type": "local",
"number": 5
},
"rounds": [{
"label" : "init",
"txNumber" : [500, 500, 500],
"rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 25}}, {"type": "fixed-rate", "opts": {"tps" : 50}}, {"type": "fixed-rate", "opts": {"tps" : 75}}],
"callback" : "benchmark/marbles/init.js"
},
{
"label" : "query",
"txNumber" : [15, 15],
"rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 5}}, {"type": "fixed-rate", "opts": {"tps" : 5}}],
"callback" : "benchmark/marbles/query.js"
}]
},
"monitor": {
"type": ["docker", "process"],
"docker":{
"name": ["all"]
},
"process": [
{
"command" : "node",
"arguments" : "local-client.js",
"multiOutput" : "avg"
}
],
"interval": 1
}
}
42 changes: 42 additions & 0 deletions benchmark/marbles/config-fabric-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"blockchain": {
"type": "fabric",
"config": "benchmark/marbles/fabric-node.json"
},
"command" : {
"start": "docker-compose -f network/fabric/2-org-1-peer/docker-compose-tls.yaml up -d",
"end" : "docker-compose -f network/fabric/2-org-1-peer/docker-compose-tls.yaml down;docker rm $(docker ps -aq);docker rmi $(docker images dev* -q)"
},
"test": {
"clients": {
"type": "local",
"number": 5
},
"rounds": [{
"label" : "init",
"txNumber" : [500, 500, 500],
"rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 25}}, {"type": "fixed-rate", "opts": {"tps" : 50}}, {"type": "fixed-rate", "opts": {"tps" : 75}}],
"callback" : "benchmark/marbles/init.js"
},
{
"label" : "query",
"txNumber" : [15, 15],
"rateControl" : [{"type": "fixed-rate", "opts": {"tps" : 5}}, {"type": "fixed-rate", "opts": {"tps" : 5}}],
"callback" : "benchmark/marbles/query.js"
}]
},
"monitor": {
"type": ["docker", "process"],
"docker":{
"name": ["all"]
},
"process": [
{
"command" : "node",
"arguments" : "local-client.js",
"multiOutput" : "avg"
}
],
"interval": 1
}
}
91 changes: 91 additions & 0 deletions benchmark/marbles/fabric-go.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"fabric": {
"cryptodir": "network/fabric/config/crypto-config",
"network": {
"orderer": {
"url": "grpcs://localhost:7050",
"mspid": "OrdererMSP",
"user": {
"key": "network/fabric/config/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore/key.pem",
"cert": "network/fabric/config/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/signcerts/[email protected]"
},
"server-hostname": "orderer.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
},
"org1": {
"name": "peerOrg1",
"mspid": "Org1MSP",
"user": {
"key": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/key.pem",
"cert": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
},
"ca": {
"url": "https://localhost:7054",
"name": "ca-org1"
},
"peer1": {
"requests": "grpcs://localhost:7051",
"events": "grpcs://localhost:7053",
"server-hostname": "peer0.org1.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
}
},
"org2": {
"name": "peerOrg2",
"mspid": "Org2MSP",
"ca": {
"url": "https://localhost:8054",
"name": "ca-org2"
},
"peer1": {
"requests": "grpcs://localhost:8051",
"events": "grpcs://localhost:8053",
"server-hostname": "peer0.org2.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
}
}
},
"channel": [
{
"name": "mychannel",
"config": "network/fabric/config/mychannel.tx",
"organizations": ["org1", "org2"],
"deployed": false
}
],
"chaincodes": [{"id": "marbles", "path": "contract/fabric/marbles/go", "language":"golang", "version": "v1", "channel": "mychannel", "metadataPath": "src/contract/fabric/marbles/go/metadata"}],
"endorsement-policy": {
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
},
{
"role": {
"name": "member",
"mspId": "Org2MSP"
}
},
{
"role": {
"name": "admin",
"mspId": "Org1MSP"
}
}
],
"policy": { "2-of": [{"signed-by": 0}, {"signed-by": 1}]}
},
"context": {
"init": "mychannel",
"query": "mychannel"
}
},
"info" : {
"Version": "1.1.0",
"Size": "2 Peers",
"Orderer": "Solo",
"Distribution": "Single Host"
}
}
91 changes: 91 additions & 0 deletions benchmark/marbles/fabric-node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"fabric": {
"cryptodir": "network/fabric/config/crypto-config",
"network": {
"orderer": {
"url": "grpcs://localhost:7050",
"mspid": "OrdererMSP",
"user": {
"key": "network/fabric/config/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/keystore/key.pem",
"cert": "network/fabric/config/crypto-config/ordererOrganizations/example.com/users/[email protected]/msp/signcerts/[email protected]"
},
"server-hostname": "orderer.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
},
"org1": {
"name": "peerOrg1",
"mspid": "Org1MSP",
"user": {
"key": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/key.pem",
"cert": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
},
"ca": {
"url": "https://localhost:7054",
"name": "ca-org1"
},
"peer1": {
"requests": "grpcs://localhost:7051",
"events": "grpcs://localhost:7053",
"server-hostname": "peer0.org1.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
}
},
"org2": {
"name": "peerOrg2",
"mspid": "Org2MSP",
"ca": {
"url": "https://localhost:8054",
"name": "ca-org2"
},
"peer1": {
"requests": "grpcs://localhost:8051",
"events": "grpcs://localhost:8053",
"server-hostname": "peer0.org2.example.com",
"tls_cacerts": "network/fabric/config/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt"
}
}
},
"channel": [
{
"name": "mychannel",
"config": "network/fabric/config/mychannel.tx",
"organizations": ["org1", "org2"],
"deployed": false
}
],
"chaincodes": [{"id": "marbles", "path": "src/contract/fabric/marbles/node", "language":"node", "version": "v1", "channel": "mychannel", "metadataPath": "src/contract/fabric/marbles/node/metadata"}],
"endorsement-policy": {
"identities": [
{
"role": {
"name": "member",
"mspId": "Org1MSP"
}
},
{
"role": {
"name": "member",
"mspId": "Org2MSP"
}
},
{
"role": {
"name": "admin",
"mspId": "Org1MSP"
}
}
],
"policy": { "2-of": [{"signed-by": 0}, {"signed-by": 1}]}
},
"context": {
"init": "mychannel",
"query": "mychannel"
}
},
"info" : {
"Version": "1.1.0",
"Size": "2 Peers",
"Orderer": "Solo",
"Distribution": "Single Host"
}
}
43 changes: 43 additions & 0 deletions benchmark/marbles/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

module.exports.info = 'Creating marbles.';

let txIndex = 0;
let colors = ['red', 'blue', 'green', 'black', 'white', 'pink', 'rainbow'];
let owners = ['Alice', 'Bob', 'Claire', 'David'];
let bc, contx;
module.exports.init = function(blockchain, context, args) {
bc = blockchain;
contx = context;
return Promise.resolve();
};

module.exports.run = function() {
txIndex++;
return bc.invokeSmartContract(contx, 'marbles', 'v1',
{
verb: 'initMarble',
name: 'marble_' + txIndex.toString() + '_' + process.pid.toString(),
color: colors[txIndex % colors.length],
size: (((txIndex % 10) + 1) * 10).toString(), // [10, 100]
owner: owners[txIndex % owners.length]
}, 30);
};

module.exports.end = function(results) {
return Promise.resolve();
};
Loading

0 comments on commit 1e5fc4a

Please sign in to comment.