matiru

Blockchain-Based Supply Chain Transparency for Agricultural Produce
commit cb8374c5f03f1ab536f427b5af761080917072c6
parent 436335025e608e1bdc15cbaea9ff4f794fa25e35
Author: maydayv7 <maydayv7@gmail.com>
Date:   Wed,  8 Oct 2025 17:20:39 +0530

refactor(fabric): Simplify network

Diffstat:
Mbackend/package-lock.json | 315+------------------------------------------------------------------------------
Mbackend/package.json | 5++---
Mdocs/INSTALL.md | 18++++--------------
Mfabric/network/.gitignore | 6++----
Dfabric/network/addOrg3/addOrg3.sh | 263-------------------------------------------------------------------------------
Dfabric/network/addOrg3/ccp-generate.sh | 36------------------------------------
Dfabric/network/addOrg3/ccp-template.json | 49-------------------------------------------------
Dfabric/network/addOrg3/ccp-template.yaml | 34----------------------------------
Dfabric/network/addOrg3/configtx.yaml | 38--------------------------------------
Dfabric/network/addOrg3/docker/docker-compose-ca-org3.yaml | 27---------------------------
Dfabric/network/addOrg3/docker/docker-compose-couch-org3.yaml | 42------------------------------------------
Dfabric/network/addOrg3/docker/docker-compose-org3.yaml | 52----------------------------------------------------
Dfabric/network/addOrg3/fabric-ca/org3/fabric-ca-server-config.yaml | 406-------------------------------------------------------------------------------
Dfabric/network/addOrg3/fabric-ca/registerEnroll.sh | 87-------------------------------------------------------------------------------
Dfabric/network/addOrg3/org3-crypto.yaml | 21---------------------
Dfabric/network/addOrg4/addOrg4.sh | 263-------------------------------------------------------------------------------
Dfabric/network/addOrg4/ccp-generate.sh | 36------------------------------------
Dfabric/network/addOrg4/ccp-template.json | 49-------------------------------------------------
Dfabric/network/addOrg4/ccp-template.yaml | 34----------------------------------
Dfabric/network/addOrg4/configtx.yaml | 38--------------------------------------
Dfabric/network/addOrg4/docker/docker-compose-ca-org4.yaml | 27---------------------------
Dfabric/network/addOrg4/docker/docker-compose-couch-org4.yaml | 42------------------------------------------
Dfabric/network/addOrg4/docker/docker-compose-org4.yaml | 52----------------------------------------------------
Dfabric/network/addOrg4/fabric-ca/org4/fabric-ca-server-config.yaml | 406-------------------------------------------------------------------------------
Dfabric/network/addOrg4/fabric-ca/registerEnroll.sh | 87-------------------------------------------------------------------------------
Dfabric/network/addOrg4/org4-crypto.yaml | 21---------------------
Mfabric/network/configtx/configtx.yaml | 478++++++++++++++++++++++++++++---------------------------------------------------
Mfabric/network/docker/docker-compose-ca.yaml | 54+++++++++++++++++++++++++++++++++++++++++-------------
Mfabric/network/docker/docker-compose-couch.yaml | 73++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Afabric/network/docker/docker-compose-network.yaml | 213+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dfabric/network/docker/docker-compose-test-net.yaml | 156-------------------------------------------------------------------------------
Mfabric/network/network.sh | 242+++++++------------------------------------------------------------------------
Mfabric/network/organizations/ccp-generate.sh | 18++++++++++++++++++
Mfabric/network/organizations/ccp-template.json | 86++++++++++++++++++++++++++++++++++++++-----------------------------------------
Mfabric/network/organizations/ccp-template.yaml | 12++++++------
Mfabric/network/organizations/cryptogen/crypto-config-orderer.yaml | 14--------------
Dfabric/network/organizations/cryptogen/crypto-config-org1.yaml | 61-------------------------------------------------------------
Dfabric/network/organizations/cryptogen/crypto-config-org2.yaml | 61-------------------------------------------------------------
Afabric/network/organizations/cryptogen/crypto-config-orgs.yaml | 37+++++++++++++++++++++++++++++++++++++
Mfabric/network/organizations/fabric-ca/registerEnroll.sh | 163+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Mfabric/network/scripts/configUpdate.sh | 14+-------------
Mfabric/network/scripts/createChannel.sh | 18+++++++++---------
Mfabric/network/scripts/deployCC.sh | 110+++++--------------------------------------------------------------------------
Dfabric/network/scripts/deployCC_2org.sh | 328-------------------------------------------------------------------------------
Mfabric/network/scripts/envVar.sh | 26+++-----------------------
Dfabric/network/scripts/org3-scripts/joinChannel.sh | 70----------------------------------------------------------------------
Dfabric/network/scripts/org3-scripts/updateChannelConfig.sh | 52----------------------------------------------------
Dfabric/network/scripts/org4-scripts/joinChannel.sh | 70----------------------------------------------------------------------
Dfabric/network/scripts/org4-scripts/updateChannelConfig.sh | 53-----------------------------------------------------
Mfabric/network/scripts/setAnchorPeer.sh | 14+-------------
Mfabric/network/scripts/utils.sh | 88++++++++++---------------------------------------------------------------------
51 files changed, 773 insertions(+), 4192 deletions(-)

diff --git a/backend/package-lock.json b/backend/package-lock.json @@ -1,11 +1,11 @@ { - "name": "matiru-backend", + "name": "matiru-server", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "matiru-backend", + "name": "matiru-server", "version": "1.0.0", "dependencies": { "bcryptjs": "^3.0.2", @@ -16,8 +16,7 @@ "fs-extra": "^11.3.2", "jsonwebtoken": "^9.0.2", "morgan": "^1.10.1", - "multer": "^2.0.2", - "nodemon": "^3.1.10" + "multer": "^2.0.2" } }, "node_modules/@grpc/grpc-js": { @@ -161,19 +160,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/append-field": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", @@ -203,12 +189,6 @@ "proxy-from-env": "^1.1.0" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "license": "MIT" - }, "node_modules/basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", @@ -236,18 +216,6 @@ "bcrypt": "bin/bcrypt" } }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/bn.js": { "version": "4.12.2", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", @@ -274,28 +242,6 @@ "node": ">=18" } }, - "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", @@ -371,30 +317,6 @@ "node": "*" } }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -448,12 +370,6 @@ "node": ">= 0.8" } }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "license": "MIT" - }, "node_modules/concat-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", @@ -809,18 +725,6 @@ "node": ">=10.13.0" } }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/finalhandler": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", @@ -927,20 +831,6 @@ "node": ">=14.14" } }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -996,18 +886,6 @@ "node": ">= 0.4" } }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -1026,15 +904,6 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "license": "ISC" }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/has-symbols": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", @@ -1132,12 +1001,6 @@ "node": ">=0.10.0" } }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "license": "ISC" - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -1162,27 +1025,6 @@ "node": ">= 0.10" } }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1192,27 +1034,6 @@ "node": ">=8" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, "node_modules/is-promise": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", @@ -1418,18 +1239,6 @@ "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", "license": "MIT" }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/minimist": { "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", @@ -1650,43 +1459,6 @@ "integrity": "sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==", "license": "MIT" }, - "node_modules/nodemon": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz", - "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==", - "license": "MIT", - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nodemon" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1757,18 +1529,6 @@ "url": "https://opencollective.com/express" } }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/pkcs11js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkcs11js/-/pkcs11js-1.3.1.tgz", @@ -1836,12 +1596,6 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "license": "MIT" }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "license": "MIT" - }, "node_modules/qs": { "version": "6.14.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", @@ -1911,18 +1665,6 @@ "node": ">= 6" } }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2107,18 +1849,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/sjcl": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/sjcl/-/sjcl-1.0.8.tgz", @@ -2189,30 +1919,6 @@ "node": ">=8" } }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -2222,15 +1928,6 @@ "node": ">=0.6" } }, - "node_modules/touch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", - "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", - "license": "ISC", - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, "node_modules/type-is": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", @@ -2251,12 +1948,6 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "license": "MIT" }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "license": "MIT" - }, "node_modules/undici-types": { "version": "7.13.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.13.0.tgz", diff --git a/backend/package.json b/backend/package.json @@ -4,7 +4,7 @@ "description": "Matiru Backend", "main": "server.js", "scripts": { - "start": "npx nodemon server.js", + "start": "node server.js", "init": "node initUsers.js" }, "dependencies": { @@ -16,7 +16,6 @@ "fs-extra": "^11.3.2", "jsonwebtoken": "^9.0.2", "morgan": "^1.10.1", - "multer": "^2.0.2", - "nodemon": "^3.1.10" + "multer": "^2.0.2" } } diff --git a/docs/INSTALL.md b/docs/INSTALL.md @@ -24,11 +24,7 @@ npm install ``` cd ../network ./network.sh up createChannel -ca -c CHANNEL_NAME -cd addOrg3 -./addOrg3.sh up -c CHANNEL_NAME -cd ../addOrg4 -./addOrg4.sh up -c CHANNEL_NAME -cd .. +./network.sh deployCC -c CHANNEL_NAME -ccn CHAINCODE_NAME -ccp /path/to/chaincode -ccl javascript ``` After initial setup, you can use the following commands: @@ -38,13 +34,7 @@ After initial setup, you can use the following commands: ./network.sh down # Reset everything -> Need to setup again ``` -5. Deploy Chaincode: - -``` -./network.sh deployCC -c CHANNEL_NAME -ccn CHAINCODE_NAME -ccp /path/to/chaincode -ccl javascript -``` - -6. Wallet Creation: +5. Wallet Creation: ``` DIR=../../backend/connections @@ -61,7 +51,7 @@ node initWallet.js org3 ../fabric/network/organizations/peerOrganizations/org3.e node initWallet.js org4 ../fabric/network/organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp ./wallet admin-org4 ``` -7. The `.env` file must be created in `backend` like so: +6. The `.env` file must be created in `backend` like so: ``` # Backend server @@ -89,7 +79,7 @@ CCP_PATH_ORG4="./connections/connection-org4.json" Make sure the port is not blocked by a firewall -8. Start `backend`: +7. Start `backend`: ``` npm install diff --git a/fabric/network/.gitignore b/fabric/network/.gitignore @@ -1,13 +1,11 @@ /channel-artifacts/*.tx /channel-artifacts/*.block -/ledgers -/ledgers-backup /channel-artifacts/*.json -/org3-artifacts/crypto-config/* -/org4-artifacts/crypto-config/* organizations/fabric-ca/ordererOrg/* organizations/fabric-ca/org1/* organizations/fabric-ca/org2/* +organizations/fabric-ca/org3/* +organizations/fabric-ca/org4/* organizations/ordererOrganizations/* organizations/peerOrganizations/* system-genesis-block/* diff --git a/fabric/network/addOrg3/addOrg3.sh b/fabric/network/addOrg3/addOrg3.sh @@ -1,263 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script extends the Hyperledger Fabric test network by adding -# adding a third organization to the network -# - -# prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries -# this may be commented out to resolve installed version of tools if desired -export PATH=${PWD}/../../bin:${PWD}:$PATH -export FABRIC_CFG_PATH=${PWD} -export VERBOSE=false - -. ../scripts/utils.sh - -# Print the usage message -function printHelp () { - echo "Usage: " - echo " addOrg3.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]" - echo " addOrg3.sh -h|--help (print this message)" - echo " <mode> - one of 'up', 'down', or 'generate'" - echo " - 'up' - add org3 to the sample network. You need to bring up the test network and create a channel first." - echo " - 'down' - bring down the test network and org3 nodes" - echo " - 'generate' - generate required certificates and org definition" - echo " -c <channel name> - test network channel name (defaults to \"mychannel\")" - echo " -ca <use CA> - Use a CA to generate the crypto material" - echo " -t <timeout> - CLI timeout duration in seconds (defaults to 10)" - echo " -d <delay> - delay duration in seconds (defaults to 3)" - echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb" - echo " -verbose - verbose mode" - echo - echo "Typically, one would first generate the required certificates and " - echo "genesis block, then bring up the network. e.g.:" - echo - echo " addOrg3.sh generate" - echo " addOrg3.sh up" - echo " addOrg3.sh up -c mychannel -s couchdb" - echo " addOrg3.sh down" - echo - echo "Taking all defaults:" - echo " addOrg3.sh up" - echo " addOrg3.sh down" -} - -# We use the cryptogen tool to generate the cryptographic material -# (x509 certs) for the new org. After we run the tool, the certs will -# be put in the organizations folder with org1 and org2 - -# Create Organziation crypto material using cryptogen or CAs -function generateOrg3() { - # Create crypto material using cryptogen - if [ "$CRYPTO" == "cryptogen" ]; then - which cryptogen - if [ "$?" -ne 0 ]; then - fatalln "cryptogen tool not found. exiting" - fi - infoln "Generating certificates using cryptogen tool" - - infoln "Creating Org3 Identities" - - set -x - cryptogen generate --config=org3-crypto.yaml --output="../organizations" - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - fatalln "Failed to generate certificates..." - fi - - fi - - # Create crypto material using Fabric CA - if [ "$CRYPTO" == "Certificate Authorities" ]; then - fabric-ca-client version > /dev/null 2>&1 - if [[ $? -ne 0 ]]; then - echo "ERROR! fabric-ca-client binary not found.." - echo - echo "Follow the instructions in the Fabric docs to install the Fabric Binaries:" - echo "https://hyperledger-fabric.readthedocs.io/en/latest/install.html" - exit 1 - fi - - infoln "Generating certificates using Fabric CA" - docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1 - - . fabric-ca/registerEnroll.sh - - sleep 10 - - infoln "Creating Org3 Identities" - createOrg3 - - fi - - infoln "Generating CCP files for Org3" - ./ccp-generate.sh -} - -# Generate channel configuration transaction -function generateOrg3Definition() { - which configtxgen - if [ "$?" -ne 0 ]; then - fatalln "configtxgen tool not found. exiting" - fi - infoln "Generating Org3 organization definition" - export FABRIC_CFG_PATH=$PWD - set -x - configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - fatalln "Failed to generate Org3 organization definition..." - fi -} - -function Org3Up () { - # start org3 nodes - if [ "${DATABASE}" == "couchdb" ]; then - docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1 - else - docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 - fi - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to start Org3 network" - fi -} - -# Generate the needed certificates, the genesis block and start the network. -function addOrg3 () { - # If the test network is not up, abort - if [ ! -d ../organizations/ordererOrganizations ]; then - fatalln "ERROR: Please, run ./network.sh up createChannel first." - fi - - # generate artifacts if they don't exist - if [ ! -d "../organizations/peerOrganizations/org3.example.com" ]; then - generateOrg3 - generateOrg3Definition - fi - - infoln "Bringing up Org3 peer" - Org3Up - - # Use the CLI container to create the configuration transaction needed to add - # Org3 to the network - infoln "Generating and submitting config tx to add Org3" - docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to create config tx" - fi - - infoln "Joining Org3 peers to network" - docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to join Org3 peers to network" - fi -} - -# Tear down running network -function networkDown () { - cd .. - ./network.sh down -} - -# Using crpto vs CA. default is cryptogen -CRYPTO="cryptogen" -# timeout duration - the duration the CLI should wait for a response from -# another container before giving up -CLI_TIMEOUT=10 -#default for delay -CLI_DELAY=3 -# channel name defaults to "mychannel" -CHANNEL_NAME="mychannel" -# use this as the docker compose couch file -COMPOSE_FILE_COUCH_ORG3=docker/docker-compose-couch-org3.yaml -# use this as the default docker-compose yaml definition -COMPOSE_FILE_ORG3=docker/docker-compose-org3.yaml -# certificate authorities compose file -COMPOSE_FILE_CA_ORG3=docker/docker-compose-ca-org3.yaml -# database -DATABASE="leveldb" - -# Parse commandline args - -## Parse mode -if [[ $# -lt 1 ]] ; then - printHelp - exit 0 -else - MODE=$1 - shift -fi - -# parse flags - -while [[ $# -ge 1 ]] ; do - key="$1" - case $key in - -h ) - printHelp - exit 0 - ;; - -c ) - CHANNEL_NAME="$2" - shift - ;; - -ca ) - CRYPTO="Certificate Authorities" - ;; - -t ) - CLI_TIMEOUT="$2" - shift - ;; - -d ) - CLI_DELAY="$2" - shift - ;; - -s ) - DATABASE="$2" - shift - ;; - -verbose ) - VERBOSE=true - shift - ;; - * ) - errorln "Unknown flag: $key" - printHelp - exit 1 - ;; - esac - shift -done - - -# Determine whether starting, stopping, restarting or generating for announce -if [ "$MODE" == "up" ]; then - infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" - echo -elif [ "$MODE" == "down" ]; then - EXPMODE="Stopping network" -elif [ "$MODE" == "generate" ]; then - EXPMODE="Generating certs and organization definition for Org3" -else - printHelp - exit 1 -fi - -#Create the network using docker compose -if [ "${MODE}" == "up" ]; then - addOrg3 -elif [ "${MODE}" == "down" ]; then ## Clear the network - networkDown -elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts - generateOrg3 - generateOrg3Definition -else - printHelp - exit 1 -fi diff --git a/fabric/network/addOrg3/ccp-generate.sh b/fabric/network/addOrg3/ccp-generate.sh @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -function one_line_pem { - echo "`awk 'NF {sub(/\\n/, ""); printf "%s\\\\\\\n",$0;}' $1`" -} - -function json_ccp { - local PP=$(one_line_pem $4) - local CP=$(one_line_pem $5) - sed -e "s/\${ORG}/$1/" \ - -e "s/\${P0PORT}/$2/" \ - -e "s/\${CAPORT}/$3/" \ - -e "s#\${PEERPEM}#$PP#" \ - -e "s#\${CAPEM}#$CP#" \ - ccp-template.json -} - -function yaml_ccp { - local PP=$(one_line_pem $4) - local CP=$(one_line_pem $5) - sed -e "s/\${ORG}/$1/" \ - -e "s/\${P0PORT}/$2/" \ - -e "s/\${CAPORT}/$3/" \ - -e "s#\${PEERPEM}#$PP#" \ - -e "s#\${CAPEM}#$CP#" \ - ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g' -} - -ORG=3 -P0PORT=11051 -CAPORT=11054 -PEERPEM=../organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem -CAPEM=../organizations/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem - -echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ../organizations/peerOrganizations/org3.example.com/connection-org3.json -echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ../organizations/peerOrganizations/org3.example.com/connection-org3.yaml diff --git a/fabric/network/addOrg3/ccp-template.json b/fabric/network/addOrg3/ccp-template.json @@ -1,49 +0,0 @@ -{ - "name": "test-network-org${ORG}", - "version": "1.0.0", - "client": { - "organization": "Org${ORG}", - "connection": { - "timeout": { - "peer": { - "endorser": "300" - } - } - } - }, - "organizations": { - "Org${ORG}": { - "mspid": "Org${ORG}MSP", - "peers": [ - "peer0.org${ORG}.example.com" - ], - "certificateAuthorities": [ - "ca.org${ORG}.example.com" - ] - } - }, - "peers": { - "peer0.org${ORG}.example.com": { - "url": "grpcs://localhost:${P0PORT}", - "tlsCACerts": { - "pem": "${PEERPEM}" - }, - "grpcOptions": { - "ssl-target-name-override": "peer0.org${ORG}.example.com", - "hostnameOverride": "peer0.org${ORG}.example.com" - } - } - }, - "certificateAuthorities": { - "ca.org${ORG}.example.com": { - "url": "https://localhost:${CAPORT}", - "caName": "ca-org${ORG}", - "tlsCACerts": { - "pem": "${CAPEM}" - }, - "httpOptions": { - "verify": false - } - } - } -} diff --git a/fabric/network/addOrg3/ccp-template.yaml b/fabric/network/addOrg3/ccp-template.yaml @@ -1,34 +0,0 @@ ---- -name: test-network-org${ORG} -version: 1.0.0 -client: - organization: Org${ORG} - connection: - timeout: - peer: - endorser: '300' -organizations: - Org${ORG}: - mspid: Org${ORG}MSP - peers: - - peer0.org${ORG}.example.com - certificateAuthorities: - - ca.org${ORG}.example.com -peers: - peer0.org${ORG}.example.com: - url: grpcs://localhost:${P0PORT} - tlsCACerts: - pem: | - ${PEERPEM} - grpcOptions: - ssl-target-name-override: peer0.org${ORG}.example.com - hostnameOverride: peer0.org${ORG}.example.com -certificateAuthorities: - ca.org${ORG}.example.com: - url: https://localhost:${CAPORT} - caName: ca-org${ORG} - tlsCACerts: - pem: | - ${CAPEM} - httpOptions: - verify: false diff --git a/fabric/network/addOrg3/configtx.yaml b/fabric/network/addOrg3/configtx.yaml @@ -1,38 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - ---- -################################################################################ -# -# Section: Organizations -# -# - This section defines the different organizational identities which will -# be referenced later in the configuration. -# -################################################################################ -Organizations: - - &Org3 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org3MSP - - # ID to load the MSP definition as - ID: Org3MSP - - MSPDir: ../organizations/peerOrganizations/org3.example.com/msp - - Policies: - Readers: - Type: Signature - Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org3MSP.admin', 'Org3MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org3MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org3MSP.peer')" diff --git a/fabric/network/addOrg3/docker/docker-compose-ca-org3.yaml b/fabric/network/addOrg3/docker/docker-compose-ca-org3.yaml @@ -1,27 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -networks: - test: - name: fabric_test - -services: - ca_org3: - image: hyperledger/fabric-ca:latest - labels: - service: hyperledger-fabric - environment: - - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - - FABRIC_CA_SERVER_CA_NAME=ca-org3 - - FABRIC_CA_SERVER_TLS_ENABLED=true - - FABRIC_CA_SERVER_PORT=11054 - ports: - - "11054:11054" - command: sh -c 'fabric-ca-server start -b admin:adminpw -d' - volumes: - - ../fabric-ca/org3:/etc/hyperledger/fabric-ca-server - container_name: ca_org3 diff --git a/fabric/network/addOrg3/docker/docker-compose-couch-org3.yaml b/fabric/network/addOrg3/docker/docker-compose-couch-org3.yaml @@ -1,42 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -networks: - test: - name: fabric_test - -services: - couchdb4: - container_name: couchdb4 - image: couchdb:3.1.1 - labels: - service: hyperledger-fabric - # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password - # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. - environment: - - COUCHDB_USER=admin - - COUCHDB_PASSWORD=adminpw - # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, - # for example map it to utilize Fauxton User Interface in dev environments. - ports: - - "9984:5984" - networks: - - test - - peer0.org3.example.com: - environment: - - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb4:5984 - # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD - # provide the credentials for ledger to connect to CouchDB. The username and password must - # match the username and password set for the associated CouchDB. - - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin - - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw - depends_on: - - couchdb4 - networks: - - test diff --git a/fabric/network/addOrg3/docker/docker-compose-org3.yaml b/fabric/network/addOrg3/docker/docker-compose-org3.yaml @@ -1,52 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -volumes: - peer0.org3.example.com: - -networks: - test: - name: fabric_test - -services: - - peer0.org3.example.com: - container_name: peer0.org3.example.com - image: hyperledger/fabric-peer:latest - labels: - service: hyperledger-fabric - environment: - #Generic peer variables - - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_test - - FABRIC_LOGGING_SPEC=INFO - #- FABRIC_LOGGING_SPEC=DEBUG - - CORE_PEER_TLS_ENABLED=true - - CORE_PEER_PROFILE_ENABLED=true - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - # Peer specific variabes - - CORE_PEER_ID=peer0.org3.example.com - - CORE_PEER_ADDRESS=peer0.org3.example.com:11051 - - CORE_PEER_LISTENADDRESS=0.0.0.0:11051 - - CORE_PEER_CHAINCODEADDRESS=peer0.org3.example.com:11052 - - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052 - - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.example.com:11051 - - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.example.com:11051 - - CORE_PEER_LOCALMSPID=Org3MSP - volumes: - - /var/run/docker.sock:/host/var/run/docker.sock - - ../../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp - - ../../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls - - peer0.org3.example.com:/var/hyperledger/production - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: peer node start - ports: - - 11051:11051 - networks: - - test diff --git a/fabric/network/addOrg3/fabric-ca/org3/fabric-ca-server-config.yaml b/fabric/network/addOrg3/fabric-ca/org3/fabric-ca-server-config.yaml @@ -1,406 +0,0 @@ -############################################################################# -# This is a configuration file for the fabric-ca-server command. -# -# COMMAND LINE ARGUMENTS AND ENVIRONMENT VARIABLES -# ------------------------------------------------ -# Each configuration element can be overridden via command line -# arguments or environment variables. The precedence for determining -# the value of each element is as follows: -# 1) command line argument -# Examples: -# a) --port 443 -# To set the listening port -# b) --ca.keyfile ../mykey.pem -# To set the "keyfile" element in the "ca" section below; -# note the '.' separator character. -# 2) environment variable -# Examples: -# a) FABRIC_CA_SERVER_PORT=443 -# To set the listening port -# b) FABRIC_CA_SERVER_CA_KEYFILE="../mykey.pem" -# To set the "keyfile" element in the "ca" section below; -# note the '_' separator character. -# 3) configuration file -# 4) default value (if there is one) -# All default values are shown beside each element below. -# -# FILE NAME ELEMENTS -# ------------------ -# The value of all fields whose name ends with "file" or "files" are -# name or names of other files. -# For example, see "tls.certfile" and "tls.clientauth.certfiles". -# The value of each of these fields can be a simple filename, a -# relative path, or an absolute path. If the value is not an -# absolute path, it is interpretted as being relative to the location -# of this configuration file. -# -############################################################################# - -# Version of config file -version: 1.2.0 - -# Server's listening port (default: 7054) -port: 11054 - -# Enables debug logging (default: false) -debug: false - -# Size limit of an acceptable CRL in bytes (default: 512000) -crlsizelimit: 512000 - -############################################################################# -# TLS section for the server's listening port -# -# The following types are supported for client authentication: NoClientCert, -# RequestClientCert, RequireAnyClientCert, VerifyClientCertIfGiven, -# and RequireAndVerifyClientCert. -# -# Certfiles is a list of root certificate authorities that the server uses -# when verifying client certificates. -############################################################################# -tls: - # Enable TLS (default: false) - enabled: true - # TLS for the server's listening port - certfile: - keyfile: - clientauth: - type: noclientcert - certfiles: - -############################################################################# -# The CA section contains information related to the Certificate Authority -# including the name of the CA, which should be unique for all members -# of a blockchain network. It also includes the key and certificate files -# used when issuing enrollment certificates (ECerts) and transaction -# certificates (TCerts). -# The chainfile (if it exists) contains the certificate chain which -# should be trusted for this CA, where the 1st in the chain is always the -# root CA certificate. -############################################################################# -ca: - # Name of this CA - name: Org3CA - # Key file (is only used to import a private key into BCCSP) - keyfile: - # Certificate file (default: ca-cert.pem) - certfile: - # Chain file - chainfile: - -############################################################################# -# The gencrl REST endpoint is used to generate a CRL that contains revoked -# certificates. This section contains configuration options that are used -# during gencrl request processing. -############################################################################# -crl: - # Specifies expiration for the generated CRL. The number of hours - # specified by this property is added to the UTC time, the resulting time - # is used to set the 'Next Update' date of the CRL. - expiry: 24h - -############################################################################# -# The registry section controls how the fabric-ca-server does two things: -# 1) authenticates enrollment requests which contain a username and password -# (also known as an enrollment ID and secret). -# 2) once authenticated, retrieves the identity's attribute names and -# values which the fabric-ca-server optionally puts into TCerts -# which it issues for transacting on the Hyperledger Fabric blockchain. -# These attributes are useful for making access control decisions in -# chaincode. -# There are two main configuration options: -# 1) The fabric-ca-server is the registry. -# This is true if "ldap.enabled" in the ldap section below is false. -# 2) An LDAP server is the registry, in which case the fabric-ca-server -# calls the LDAP server to perform these tasks. -# This is true if "ldap.enabled" in the ldap section below is true, -# which means this "registry" section is ignored. -############################################################################# -registry: - # Maximum number of times a password/secret can be reused for enrollment - # (default: -1, which means there is no limit) - maxenrollments: -1 - - # Contains identity information which is used when LDAP is disabled - identities: - - name: admin - pass: adminpw - type: client - affiliation: "" - attrs: - hf.Registrar.Roles: "*" - hf.Registrar.DelegateRoles: "*" - hf.Revoker: true - hf.IntermediateCA: true - hf.GenCRL: true - hf.Registrar.Attributes: "*" - hf.AffiliationMgr: true - -############################################################################# -# Database section -# Supported types are: "sqlite3", "postgres", and "mysql". -# The datasource value depends on the type. -# If the type is "sqlite3", the datasource value is a file name to use -# as the database store. Since "sqlite3" is an embedded database, it -# may not be used if you want to run the fabric-ca-server in a cluster. -# To run the fabric-ca-server in a cluster, you must choose "postgres" -# or "mysql". -############################################################################# -db: - type: sqlite3 - datasource: fabric-ca-server.db - tls: - enabled: false - certfiles: - client: - certfile: - keyfile: - -############################################################################# -# LDAP section -# If LDAP is enabled, the fabric-ca-server calls LDAP to: -# 1) authenticate enrollment ID and secret (i.e. username and password) -# for enrollment requests; -# 2) To retrieve identity attributes -############################################################################# -ldap: - # Enables or disables the LDAP client (default: false) - # If this is set to true, the "registry" section is ignored. - enabled: false - # The URL of the LDAP server - url: ldap://<adminDN>:<adminPassword>@<host>:<port>/<base> - # TLS configuration for the client connection to the LDAP server - tls: - certfiles: - client: - certfile: - keyfile: - # Attribute related configuration for mapping from LDAP entries to Fabric CA attributes - attribute: - # 'names' is an array of strings containing the LDAP attribute names which are - # requested from the LDAP server for an LDAP identity's entry - names: ['uid','member'] - # The 'converters' section is used to convert an LDAP entry to the value of - # a fabric CA attribute. - # For example, the following converts an LDAP 'uid' attribute - # whose value begins with 'revoker' to a fabric CA attribute - # named "hf.Revoker" with a value of "true" (because the boolean expression - # evaluates to true). - # converters: - # - name: hf.Revoker - # value: attr("uid") =~ "revoker*" - converters: - - name: - value: - # The 'maps' section contains named maps which may be referenced by the 'map' - # function in the 'converters' section to map LDAP responses to arbitrary values. - # For example, assume a user has an LDAP attribute named 'member' which has multiple - # values which are each a distinguished name (i.e. a DN). For simplicity, assume the - # values of the 'member' attribute are 'dn1', 'dn2', and 'dn3'. - # Further assume the following configuration. - # converters: - # - name: hf.Registrar.Roles - # value: map(attr("member"),"groups") - # maps: - # groups: - # - name: dn1 - # value: peer - # - name: dn2 - # value: client - # The value of the user's 'hf.Registrar.Roles' attribute is then computed to be - # "peer,client,dn3". This is because the value of 'attr("member")' is - # "dn1,dn2,dn3", and the call to 'map' with a 2nd argument of - # "group" replaces "dn1" with "peer" and "dn2" with "client". - maps: - groups: - - name: - value: - -############################################################################# -# Affiliations section. Fabric CA server can be bootstrapped with the -# affiliations specified in this section. Affiliations are specified as maps. -# For example: -# businessunit1: -# department1: -# - team1 -# businessunit2: -# - department2 -# - department3 -# -# Affiliations are hierarchical in nature. In the above example, -# department1 (used as businessunit1.department1) is the child of businessunit1. -# team1 (used as businessunit1.department1.team1) is the child of department1. -# department2 (used as businessunit2.department2) and department3 (businessunit2.department3) -# are children of businessunit2. -# Note: Affiliations are case sensitive except for the non-leaf affiliations -# (like businessunit1, department1, businessunit2) that are specified in the configuration file, -# which are always stored in lower case. -############################################################################# -affiliations: - org1: - - department1 - - department2 - org2: - - department1 - -############################################################################# -# Signing section -# -# The "default" subsection is used to sign enrollment certificates; -# the default expiration ("expiry" field) is "8760h", which is 1 year in hours. -# -# The "ca" profile subsection is used to sign intermediate CA certificates; -# the default expiration ("expiry" field) is "43800h" which is 5 years in hours. -# Note that "isca" is true, meaning that it issues a CA certificate. -# A maxpathlen of 0 means that the intermediate CA cannot issue other -# intermediate CA certificates, though it can still issue end entity certificates. -# (See RFC 5280, section 4.2.1.9) -# -# The "tls" profile subsection is used to sign TLS certificate requests; -# the default expiration ("expiry" field) is "8760h", which is 1 year in hours. -############################################################################# -signing: - default: - usage: - - digital signature - expiry: 8760h - profiles: - ca: - usage: - - cert sign - - crl sign - expiry: 43800h - caconstraint: - isca: true - maxpathlen: 0 - tls: - usage: - - signing - - key encipherment - - server auth - - client auth - - key agreement - expiry: 8760h - -########################################################################### -# Certificate Signing Request (CSR) section. -# This controls the creation of the root CA certificate. -# The expiration for the root CA certificate is configured with the -# "ca.expiry" field below, whose default value is "131400h" which is -# 15 years in hours. -# The pathlength field is used to limit CA certificate hierarchy as described -# in section 4.2.1.9 of RFC 5280. -# Examples: -# 1) No pathlength value means no limit is requested. -# 2) pathlength == 1 means a limit of 1 is requested which is the default for -# a root CA. This means the root CA can issue intermediate CA certificates, -# but these intermediate CAs may not in turn issue other CA certificates -# though they can still issue end entity certificates. -# 3) pathlength == 0 means a limit of 0 is requested; -# this is the default for an intermediate CA, which means it can not issue -# CA certificates though it can still issue end entity certificates. -########################################################################### -csr: - cn: ca.org3.example.com - names: - - C: US - ST: "North Carolina" - L: "Raleigh" - O: org3.example.com - OU: - hosts: - - localhost - - org3.example.com - ca: - expiry: 131400h - pathlength: 1 - -############################################################################# -# BCCSP (BlockChain Crypto Service Provider) section is used to select which -# crypto library implementation to use -############################################################################# -bccsp: - default: SW - sw: - hash: SHA2 - security: 256 - filekeystore: - # The directory used for the software file-based keystore - keystore: msp/keystore - -############################################################################# -# Multi CA section -# -# Each Fabric CA server contains one CA by default. This section is used -# to configure multiple CAs in a single server. -# -# 1) --cacount <number-of-CAs> -# Automatically generate <number-of-CAs> non-default CAs. The names of these -# additional CAs are "ca1", "ca2", ... "caN", where "N" is <number-of-CAs> -# This is particularly useful in a development environment to quickly set up -# multiple CAs. Note that, this config option is not applicable to intermediate CA server -# i.e., Fabric CA server that is started with intermediate.parentserver.url config -# option (-u command line option) -# -# 2) --cafiles <CA-config-files> -# For each CA config file in the list, generate a separate signing CA. Each CA -# config file in this list MAY contain all of the same elements as are found in -# the server config file except port, debug, and tls sections. -# -# Examples: -# fabric-ca-server start -b admin:adminpw --cacount 2 -# -# fabric-ca-server start -b admin:adminpw --cafiles ca/ca1/fabric-ca-server-config.yaml -# --cafiles ca/ca2/fabric-ca-server-config.yaml -# -############################################################################# - -cacount: - -cafiles: - -############################################################################# -# Intermediate CA section -# -# The relationship between servers and CAs is as follows: -# 1) A single server process may contain or function as one or more CAs. -# This is configured by the "Multi CA section" above. -# 2) Each CA is either a root CA or an intermediate CA. -# 3) Each intermediate CA has a parent CA which is either a root CA or another intermediate CA. -# -# This section pertains to configuration of #2 and #3. -# If the "intermediate.parentserver.url" property is set, -# then this is an intermediate CA with the specified parent -# CA. -# -# parentserver section -# url - The URL of the parent server -# caname - Name of the CA to enroll within the server -# -# enrollment section used to enroll intermediate CA with parent CA -# profile - Name of the signing profile to use in issuing the certificate -# label - Label to use in HSM operations -# -# tls section for secure socket connection -# certfiles - PEM-encoded list of trusted root certificate files -# client: -# certfile - PEM-encoded certificate file for when client authentication -# is enabled on server -# keyfile - PEM-encoded key file for when client authentication -# is enabled on server -############################################################################# -intermediate: - parentserver: - url: - caname: - - enrollment: - hosts: - profile: - label: - - tls: - certfiles: - client: - certfile: - keyfile: diff --git a/fabric/network/addOrg3/fabric-ca/registerEnroll.sh b/fabric/network/addOrg3/fabric-ca/registerEnroll.sh @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -function createOrg3 { - infoln "Enrolling the CA admin" - mkdir -p ../organizations/peerOrganizations/org3.example.com/ - - export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/ - - set -x - fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - echo 'NodeOUs: - Enable: true - ClientOUIdentifier: - Certificate: cacerts/localhost-11054-ca-org3.pem - OrganizationalUnitIdentifier: client - PeerOUIdentifier: - Certificate: cacerts/localhost-11054-ca-org3.pem - OrganizationalUnitIdentifier: peer - AdminOUIdentifier: - Certificate: cacerts/localhost-11054-ca-org3.pem - OrganizationalUnitIdentifier: admin - OrdererOUIdentifier: - Certificate: cacerts/localhost-11054-ca-org3.pem - OrganizationalUnitIdentifier: orderer' > "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml" - - infoln "Registering peer0" - set -x - fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Registering user" - set -x - fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Registering the org admin" - set -x - fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Generating the peer0 msp" - set -x - fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp" --csr.hosts peer0.org3.example.com --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml" - - infoln "Generating the peer0-tls certificates" - set -x - fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls" --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt" - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/signcerts/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.crt" - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/keystore/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.key" - - mkdir "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/tlscacerts" - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/tlscacerts/ca.crt" - - mkdir "${PWD}/../organizations/peerOrganizations/org3.example.com/tlsca" - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem" - - mkdir "${PWD}/../organizations/peerOrganizations/org3.example.com/ca" - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/cacerts/"* "${PWD}/../organizations/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem" - - infoln "Generating the user msp" - set -x - fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M "${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp" --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp/config.yaml" - - infoln "Generating the org admin msp" - set -x - fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M "${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp" --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml" -} diff --git a/fabric/network/addOrg3/org3-crypto.yaml b/fabric/network/addOrg3/org3-crypto.yaml @@ -1,21 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# --------------------------------------------------------------------------- -# "PeerOrgs" - Definition of organizations managing peer nodes -# --------------------------------------------------------------------------- -PeerOrgs: - # --------------------------------------------------------------------------- - # Org3 - # --------------------------------------------------------------------------- - - Name: Org3 - Domain: org3.example.com - EnableNodeOUs: true - Template: - Count: 1 - SANS: - - localhost - Users: - Count: 1 diff --git a/fabric/network/addOrg4/addOrg4.sh b/fabric/network/addOrg4/addOrg4.sh @@ -1,263 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script extends the Hyperledger Fabric test network by adding -# adding a fourth organization to the network -# - -# prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries -# this may be commented out to resolve installed version of tools if desired -export PATH=${PWD}/../../bin:${PWD}:$PATH -export FABRIC_CFG_PATH=${PWD} -export VERBOSE=false - -. ../scripts/utils.sh - -# Print the usage message -function printHelp () { - echo "Usage: " - echo " addOrg4.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]" - echo " addOrg4.sh -h|--help (print this message)" - echo " <mode> - one of 'up', 'down', or 'generate'" - echo " - 'up' - add org4 to the sample network. You need to bring up the test network and create a channel first." - echo " - 'down' - bring down the test network and org4 nodes" - echo " - 'generate' - generate required certificates and org definition" - echo " -c <channel name> - test network channel name (defaults to \"mychannel\")" - echo " -ca <use CA> - Use a CA to generate the crypto material" - echo " -t <timeout> - CLI timeout duration in seconds (defaults to 10)" - echo " -d <delay> - delay duration in seconds (defaults to 3)" - echo " -s <dbtype> - the database backend to use: goleveldb (default) or couchdb" - echo " -verbose - verbose mode" - echo - echo "Typically, one would first generate the required certificates and " - echo "genesis block, then bring up the network. e.g.:" - echo - echo " addOrg4.sh generate" - echo " addOrg4.sh up" - echo " addOrg4.sh up -c mychannel -s couchdb" - echo " addOrg4.sh down" - echo - echo "Taking all defaults:" - echo " addOrg4.sh up" - echo " addOrg4.sh down" -} - -# We use the cryptogen tool to generate the cryptographic material -# (x509 certs) for the new org. After we run the tool, the certs will -# be put in the organizations folder with org1 and org2 - -# Create Organziation crypto material using cryptogen or CAs -function generateOrg4() { - # Create crypto material using cryptogen - if [ "$CRYPTO" == "cryptogen" ]; then - which cryptogen - if [ "$?" -ne 0 ]; then - fatalln "cryptogen tool not found. exiting" - fi - infoln "Generating certificates using cryptogen tool" - - infoln "Creating Org4 Identities" - - set -x - cryptogen generate --config=org4-crypto.yaml --output="../organizations" - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - fatalln "Failed to generate certificates..." - fi - - fi - - # Create crypto material using Fabric CA - if [ "$CRYPTO" == "Certificate Authorities" ]; then - fabric-ca-client version > /dev/null 2>&1 - if [[ $? -ne 0 ]]; then - echo "ERROR! fabric-ca-client binary not found.." - echo - echo "Follow the instructions in the Fabric docs to install the Fabric Binaries:" - echo "https://hyperledger-fabric.readthedocs.io/en/latest/install.html" - exit 1 - fi - - infoln "Generating certificates using Fabric CA" - docker-compose -f $COMPOSE_FILE_CA_ORG4 up -d 2>&1 - - . fabric-ca/registerEnroll.sh - - sleep 10 - - infoln "Creating Org4 Identities" - createOrg4 - - fi - - infoln "Generating CCP files for Org4" - ./ccp-generate.sh -} - -# Generate channel configuration transaction -function generateOrg4Definition() { - which configtxgen - if [ "$?" -ne 0 ]; then - fatalln "configtxgen tool not found. exiting" - fi - infoln "Generating Org4 organization definition" - export FABRIC_CFG_PATH=$PWD - set -x - configtxgen -printOrg Org4MSP > ../organizations/peerOrganizations/org4.example.com/org4.json - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - fatalln "Failed to generate Org4 organization definition..." - fi -} - -function Org4Up () { - # start org4 nodes - if [ "${DATABASE}" == "couchdb" ]; then - docker-compose -f $COMPOSE_FILE_ORG4 -f $COMPOSE_FILE_COUCH_ORG4 up -d 2>&1 - else - docker-compose -f $COMPOSE_FILE_ORG4 up -d 2>&1 - fi - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to start Org4 network" - fi -} - -# Generate the needed certificates, the genesis block and start the network. -function addOrg4 () { - # If the test network is not up, abort - if [ ! -d ../organizations/ordererOrganizations ]; then - fatalln "ERROR: Please, run ./network.sh up createChannel first." - fi - - # generate artifacts if they don't exist - if [ ! -d "../organizations/peerOrganizations/org4.example.com" ]; then - generateOrg4 - generateOrg4Definition - fi - - infoln "Bringing up Org4 peer" - Org4Up - - # Use the CLI container to create the configuration transaction needed to add - # Org4 to the network - infoln "Generating and submitting config tx to add Org4" - docker exec cli ./scripts/org4-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to create config tx" - fi - - infoln "Joining Org4 peers to network" - docker exec cli ./scripts/org4-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE - if [ $? -ne 0 ]; then - fatalln "ERROR !!!! Unable to join Org4 peers to network" - fi -} - -# Tear down running network -function networkDown () { - cd .. - ./network.sh down -} - -# Using crpto vs CA. default is cryptogen -CRYPTO="cryptogen" -# timeout duration - the duration the CLI should wait for a response from -# another container before giving up -CLI_TIMEOUT=10 -#default for delay -CLI_DELAY=3 -# channel name defaults to "mychannel" -CHANNEL_NAME="mychannel" -# use this as the docker compose couch file -COMPOSE_FILE_COUCH_ORG4=docker/docker-compose-couch-org4.yaml -# use this as the default docker-compose yaml definition -COMPOSE_FILE_ORG4=docker/docker-compose-org4.yaml -# certificate authorities compose file -COMPOSE_FILE_CA_ORG4=docker/docker-compose-ca-org4.yaml -# database -DATABASE="leveldb" - -# Parse commandline args - -## Parse mode -if [[ $# -lt 1 ]] ; then - printHelp - exit 0 -else - MODE=$1 - shift -fi - -# parse flags - -while [[ $# -ge 1 ]] ; do - key="$1" - case $key in - -h ) - printHelp - exit 0 - ;; - -c ) - CHANNEL_NAME="$2" - shift - ;; - -ca ) - CRYPTO="Certificate Authorities" - ;; - -t ) - CLI_TIMEOUT="$2" - shift - ;; - -d ) - CLI_DELAY="$2" - shift - ;; - -s ) - DATABASE="$2" - shift - ;; - -verbose ) - VERBOSE=true - shift - ;; - * ) - errorln "Unknown flag: $key" - printHelp - exit 1 - ;; - esac - shift -done - - -# Determine whether starting, stopping, restarting or generating for announce -if [ "$MODE" == "up" ]; then - infoln "Adding org4 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" - echo -elif [ "$MODE" == "down" ]; then - EXPMODE="Stopping network" -elif [ "$MODE" == "generate" ]; then - EXPMODE="Generating certs and organization definition for Org4" -else - printHelp - exit 1 -fi - -#Create the network using docker compose -if [ "${MODE}" == "up" ]; then - addOrg4 -elif [ "${MODE}" == "down" ]; then ## Clear the network - networkDown -elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts - generateOrg4 - generateOrg4Definition -else - printHelp - exit 1 -fi diff --git a/fabric/network/addOrg4/ccp-generate.sh b/fabric/network/addOrg4/ccp-generate.sh @@ -1,36 +0,0 @@ -#!/usr/bin/env bash - -function one_line_pem { - echo "`awk 'NF {sub(/\\n/, ""); printf "%s\\\\\\\n",$0;}' $1`" -} - -function json_ccp { - local PP=$(one_line_pem $4) - local CP=$(one_line_pem $5) - sed -e "s/\${ORG}/$1/" \ - -e "s/\${P0PORT}/$2/" \ - -e "s/\${CAPORT}/$3/" \ - -e "s#\${PEERPEM}#$PP#" \ - -e "s#\${CAPEM}#$CP#" \ - ccp-template.json -} - -function yaml_ccp { - local PP=$(one_line_pem $4) - local CP=$(one_line_pem $5) - sed -e "s/\${ORG}/$1/" \ - -e "s/\${P0PORT}/$2/" \ - -e "s/\${CAPORT}/$3/" \ - -e "s#\${PEERPEM}#$PP#" \ - -e "s#\${CAPEM}#$CP#" \ - ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g' -} - -ORG=4 -P0PORT=13051 -CAPORT=13054 -PEERPEM=../organizations/peerOrganizations/org4.example.com/tlsca/tlsca.org4.example.com-cert.pem -CAPEM=../organizations/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem - -echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ../organizations/peerOrganizations/org4.example.com/connection-org4.json -echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ../organizations/peerOrganizations/org4.example.com/connection-org4.yaml diff --git a/fabric/network/addOrg4/ccp-template.json b/fabric/network/addOrg4/ccp-template.json @@ -1,49 +0,0 @@ -{ - "name": "test-network-org${ORG}", - "version": "1.0.0", - "client": { - "organization": "Org${ORG}", - "connection": { - "timeout": { - "peer": { - "endorser": "300" - } - } - } - }, - "organizations": { - "Org${ORG}": { - "mspid": "Org${ORG}MSP", - "peers": [ - "peer0.org${ORG}.example.com" - ], - "certificateAuthorities": [ - "ca.org${ORG}.example.com" - ] - } - }, - "peers": { - "peer0.org${ORG}.example.com": { - "url": "grpcs://localhost:${P0PORT}", - "tlsCACerts": { - "pem": "${PEERPEM}" - }, - "grpcOptions": { - "ssl-target-name-override": "peer0.org${ORG}.example.com", - "hostnameOverride": "peer0.org${ORG}.example.com" - } - } - }, - "certificateAuthorities": { - "ca.org${ORG}.example.com": { - "url": "https://localhost:${CAPORT}", - "caName": "ca-org${ORG}", - "tlsCACerts": { - "pem": "${CAPEM}" - }, - "httpOptions": { - "verify": false - } - } - } -} diff --git a/fabric/network/addOrg4/ccp-template.yaml b/fabric/network/addOrg4/ccp-template.yaml @@ -1,34 +0,0 @@ ---- -name: test-network-org${ORG} -version: 1.0.0 -client: - organization: Org${ORG} - connection: - timeout: - peer: - endorser: '300' -organizations: - Org${ORG}: - mspid: Org${ORG}MSP - peers: - - peer0.org${ORG}.example.com - certificateAuthorities: - - ca.org${ORG}.example.com -peers: - peer0.org${ORG}.example.com: - url: grpcs://localhost:${P0PORT} - tlsCACerts: - pem: | - ${PEERPEM} - grpcOptions: - ssl-target-name-override: peer0.org${ORG}.example.com - hostnameOverride: peer0.org${ORG}.example.com -certificateAuthorities: - ca.org${ORG}.example.com: - url: https://localhost:${CAPORT} - caName: ca-org${ORG} - tlsCACerts: - pem: | - ${CAPEM} - httpOptions: - verify: false diff --git a/fabric/network/addOrg4/configtx.yaml b/fabric/network/addOrg4/configtx.yaml @@ -1,38 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - ---- -################################################################################ -# -# Section: Organizations -# -# - This section defines the different organizational identities which will -# be referenced later in the configuration. -# -################################################################################ -Organizations: - - &Org4 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org4MSP - - # ID to load the MSP definition as - ID: Org4MSP - - MSPDir: ../organizations/peerOrganizations/org4.example.com/msp - - Policies: - Readers: - Type: Signature - Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org4MSP.admin', 'Org4MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org4MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org4MSP.peer')" diff --git a/fabric/network/addOrg4/docker/docker-compose-ca-org4.yaml b/fabric/network/addOrg4/docker/docker-compose-ca-org4.yaml @@ -1,27 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -networks: - test: - name: fabric_test - -services: - ca_org4: - image: hyperledger/fabric-ca:latest - labels: - service: hyperledger-fabric - environment: - - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server - - FABRIC_CA_SERVER_CA_NAME=ca-org4 - - FABRIC_CA_SERVER_TLS_ENABLED=true - - FABRIC_CA_SERVER_PORT=13054 - ports: - - "13054:13054" - command: sh -c 'fabric-ca-server start -b admin:adminpw -d' - volumes: - - ../fabric-ca/org4:/etc/hyperledger/fabric-ca-server - container_name: ca_org4 diff --git a/fabric/network/addOrg4/docker/docker-compose-couch-org4.yaml b/fabric/network/addOrg4/docker/docker-compose-couch-org4.yaml @@ -1,42 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -networks: - test: - name: fabric_test - -services: - couchdb5: - container_name: couchdb5 - image: couchdb:3.1.1 - labels: - service: hyperledger-fabric - # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password - # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. - environment: - - COUCHDB_USER=admin - - COUCHDB_PASSWORD=adminpw - # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, - # for example map it to utilize Fauxton User Interface in dev environments. - ports: - - "11984:5984" - networks: - - test - - peer0.org4.example.com: - environment: - - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb5:5984 - # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD - # provide the credentials for ledger to connect to CouchDB. The username and password must - # match the username and password set for the associated CouchDB. - - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin - - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw - depends_on: - - couchdb5 - networks: - - test diff --git a/fabric/network/addOrg4/docker/docker-compose-org4.yaml b/fabric/network/addOrg4/docker/docker-compose-org4.yaml @@ -1,52 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2' - -volumes: - peer0.org4.example.com: - -networks: - test: - name: fabric_test - -services: - - peer0.org4.example.com: - container_name: peer0.org4.example.com - image: hyperledger/fabric-peer:latest - labels: - service: hyperledger-fabric - environment: - #Generic peer variables - - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_test - - FABRIC_LOGGING_SPEC=INFO - #- FABRIC_LOGGING_SPEC=DEBUG - - CORE_PEER_TLS_ENABLED=true - - CORE_PEER_PROFILE_ENABLED=true - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - # Peer specific variabes - - CORE_PEER_ID=peer0.org4.example.com - - CORE_PEER_ADDRESS=peer0.org4.example.com:13051 - - CORE_PEER_LISTENADDRESS=0.0.0.0:13051 - - CORE_PEER_CHAINCODEADDRESS=peer0.org4.example.com:13052 - - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:13052 - - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org4.example.com:13051 - - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org4.example.com:13051 - - CORE_PEER_LOCALMSPID=Org4MSP - volumes: - - /var/run/docker.sock:/host/var/run/docker.sock - - ../../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp:/etc/hyperledger/fabric/msp - - ../../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls:/etc/hyperledger/fabric/tls - - peer0.org4.example.com:/var/hyperledger/production - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: peer node start - ports: - - 13051:13051 - networks: - - test diff --git a/fabric/network/addOrg4/fabric-ca/org4/fabric-ca-server-config.yaml b/fabric/network/addOrg4/fabric-ca/org4/fabric-ca-server-config.yaml @@ -1,406 +0,0 @@ -############################################################################# -# This is a configuration file for the fabric-ca-server command. -# -# COMMAND LINE ARGUMENTS AND ENVIRONMENT VARIABLES -# ------------------------------------------------ -# Each configuration element can be overridden via command line -# arguments or environment variables. The precedence for determining -# the value of each element is as follows: -# 1) command line argument -# Examples: -# a) --port 443 -# To set the listening port -# b) --ca.keyfile ../mykey.pem -# To set the "keyfile" element in the "ca" section below; -# note the '.' separator character. -# 2) environment variable -# Examples: -# a) FABRIC_CA_SERVER_PORT=443 -# To set the listening port -# b) FABRIC_CA_SERVER_CA_KEYFILE="../mykey.pem" -# To set the "keyfile" element in the "ca" section below; -# note the '_' separator character. -# 3) configuration file -# 4) default value (if there is one) -# All default values are shown beside each element below. -# -# FILE NAME ELEMENTS -# ------------------ -# The value of all fields whose name ends with "file" or "files" are -# name or names of other files. -# For example, see "tls.certfile" and "tls.clientauth.certfiles". -# The value of each of these fields can be a simple filename, a -# relative path, or an absolute path. If the value is not an -# absolute path, it is interpretted as being relative to the location -# of this configuration file. -# -############################################################################# - -# Version of config file -version: 1.2.0 - -# Server's listening port (default: 7054) -port: 13054 - -# Enables debug logging (default: false) -debug: false - -# Size limit of an acceptable CRL in bytes (default: 512000) -crlsizelimit: 512000 - -############################################################################# -# TLS section for the server's listening port -# -# The following types are supported for client authentication: NoClientCert, -# RequestClientCert, RequireAnyClientCert, VerifyClientCertIfGiven, -# and RequireAndVerifyClientCert. -# -# Certfiles is a list of root certificate authorities that the server uses -# when verifying client certificates. -############################################################################# -tls: - # Enable TLS (default: false) - enabled: true - # TLS for the server's listening port - certfile: - keyfile: - clientauth: - type: noclientcert - certfiles: - -############################################################################# -# The CA section contains information related to the Certificate Authority -# including the name of the CA, which should be unique for all members -# of a blockchain network. It also includes the key and certificate files -# used when issuing enrollment certificates (ECerts) and transaction -# certificates (TCerts). -# The chainfile (if it exists) contains the certificate chain which -# should be trusted for this CA, where the 1st in the chain is always the -# root CA certificate. -############################################################################# -ca: - # Name of this CA - name: Org4CA - # Key file (is only used to import a private key into BCCSP) - keyfile: - # Certificate file (default: ca-cert.pem) - certfile: - # Chain file - chainfile: - -############################################################################# -# The gencrl REST endpoint is used to generate a CRL that contains revoked -# certificates. This section contains configuration options that are used -# during gencrl request processing. -############################################################################# -crl: - # Specifies expiration for the generated CRL. The number of hours - # specified by this property is added to the UTC time, the resulting time - # is used to set the 'Next Update' date of the CRL. - expiry: 24h - -############################################################################# -# The registry section controls how the fabric-ca-server does two things: -# 1) authenticates enrollment requests which contain a username and password -# (also known as an enrollment ID and secret). -# 2) once authenticated, retrieves the identity's attribute names and -# values which the fabric-ca-server optionally puts into TCerts -# which it issues for transacting on the Hyperledger Fabric blockchain. -# These attributes are useful for making access control decisions in -# chaincode. -# There are two main configuration options: -# 1) The fabric-ca-server is the registry. -# This is true if "ldap.enabled" in the ldap section below is false. -# 2) An LDAP server is the registry, in which case the fabric-ca-server -# calls the LDAP server to perform these tasks. -# This is true if "ldap.enabled" in the ldap section below is true, -# which means this "registry" section is ignored. -############################################################################# -registry: - # Maximum number of times a password/secret can be reused for enrollment - # (default: -1, which means there is no limit) - maxenrollments: -1 - - # Contains identity information which is used when LDAP is disabled - identities: - - name: admin - pass: adminpw - type: client - affiliation: "" - attrs: - hf.Registrar.Roles: "*" - hf.Registrar.DelegateRoles: "*" - hf.Revoker: true - hf.IntermediateCA: true - hf.GenCRL: true - hf.Registrar.Attributes: "*" - hf.AffiliationMgr: true - -############################################################################# -# Database section -# Supported types are: "sqlite3", "postgres", and "mysql". -# The datasource value depends on the type. -# If the type is "sqlite3", the datasource value is a file name to use -# as the database store. Since "sqlite3" is an embedded database, it -# may not be used if you want to run the fabric-ca-server in a cluster. -# To run the fabric-ca-server in a cluster, you must choose "postgres" -# or "mysql". -############################################################################# -db: - type: sqlite3 - datasource: fabric-ca-server.db - tls: - enabled: false - certfiles: - client: - certfile: - keyfile: - -############################################################################# -# LDAP section -# If LDAP is enabled, the fabric-ca-server calls LDAP to: -# 1) authenticate enrollment ID and secret (i.e. username and password) -# for enrollment requests; -# 2) To retrieve identity attributes -############################################################################# -ldap: - # Enables or disables the LDAP client (default: false) - # If this is set to true, the "registry" section is ignored. - enabled: false - # The URL of the LDAP server - url: ldap://<adminDN>:<adminPassword>@<host>:<port>/<base> - # TLS configuration for the client connection to the LDAP server - tls: - certfiles: - client: - certfile: - keyfile: - # Attribute related configuration for mapping from LDAP entries to Fabric CA attributes - attribute: - # 'names' is an array of strings containing the LDAP attribute names which are - # requested from the LDAP server for an LDAP identity's entry - names: ['uid','member'] - # The 'converters' section is used to convert an LDAP entry to the value of - # a fabric CA attribute. - # For example, the following converts an LDAP 'uid' attribute - # whose value begins with 'revoker' to a fabric CA attribute - # named "hf.Revoker" with a value of "true" (because the boolean expression - # evaluates to true). - # converters: - # - name: hf.Revoker - # value: attr("uid") =~ "revoker*" - converters: - - name: - value: - # The 'maps' section contains named maps which may be referenced by the 'map' - # function in the 'converters' section to map LDAP responses to arbitrary values. - # For example, assume a user has an LDAP attribute named 'member' which has multiple - # values which are each a distinguished name (i.e. a DN). For simplicity, assume the - # values of the 'member' attribute are 'dn1', 'dn2', and 'dn3'. - # Further assume the following configuration. - # converters: - # - name: hf.Registrar.Roles - # value: map(attr("member"),"groups") - # maps: - # groups: - # - name: dn1 - # value: peer - # - name: dn2 - # value: client - # The value of the user's 'hf.Registrar.Roles' attribute is then computed to be - # "peer,client,dn3". This is because the value of 'attr("member")' is - # "dn1,dn2,dn3", and the call to 'map' with a 2nd argument of - # "group" replaces "dn1" with "peer" and "dn2" with "client". - maps: - groups: - - name: - value: - -############################################################################# -# Affiliations section. Fabric CA server can be bootstrapped with the -# affiliations specified in this section. Affiliations are specified as maps. -# For example: -# businessunit1: -# department1: -# - team1 -# businessunit2: -# - department2 -# - department3 -# -# Affiliations are hierarchical in nature. In the above example, -# department1 (used as businessunit1.department1) is the child of businessunit1. -# team1 (used as businessunit1.department1.team1) is the child of department1. -# department2 (used as businessunit2.department2) and department3 (businessunit2.department3) -# are children of businessunit2. -# Note: Affiliations are case sensitive except for the non-leaf affiliations -# (like businessunit1, department1, businessunit2) that are specified in the configuration file, -# which are always stored in lower case. -############################################################################# -affiliations: - org1: - - department1 - - department2 - org2: - - department1 - -############################################################################# -# Signing section -# -# The "default" subsection is used to sign enrollment certificates; -# the default expiration ("expiry" field) is "8760h", which is 1 year in hours. -# -# The "ca" profile subsection is used to sign intermediate CA certificates; -# the default expiration ("expiry" field) is "43800h" which is 5 years in hours. -# Note that "isca" is true, meaning that it issues a CA certificate. -# A maxpathlen of 0 means that the intermediate CA cannot issue other -# intermediate CA certificates, though it can still issue end entity certificates. -# (See RFC 5280, section 4.2.1.9) -# -# The "tls" profile subsection is used to sign TLS certificate requests; -# the default expiration ("expiry" field) is "8760h", which is 1 year in hours. -############################################################################# -signing: - default: - usage: - - digital signature - expiry: 8760h - profiles: - ca: - usage: - - cert sign - - crl sign - expiry: 43800h - caconstraint: - isca: true - maxpathlen: 0 - tls: - usage: - - signing - - key encipherment - - server auth - - client auth - - key agreement - expiry: 8760h - -########################################################################### -# Certificate Signing Request (CSR) section. -# This controls the creation of the root CA certificate. -# The expiration for the root CA certificate is configured with the -# "ca.expiry" field below, whose default value is "131400h" which is -# 15 years in hours. -# The pathlength field is used to limit CA certificate hierarchy as described -# in section 4.2.1.9 of RFC 5280. -# Examples: -# 1) No pathlength value means no limit is requested. -# 2) pathlength == 1 means a limit of 1 is requested which is the default for -# a root CA. This means the root CA can issue intermediate CA certificates, -# but these intermediate CAs may not in turn issue other CA certificates -# though they can still issue end entity certificates. -# 3) pathlength == 0 means a limit of 0 is requested; -# this is the default for an intermediate CA, which means it can not issue -# CA certificates though it can still issue end entity certificates. -########################################################################### -csr: - cn: ca.org4.example.com - names: - - C: US - ST: "North Carolina" - L: "Raleigh" - O: org4.example.com - OU: - hosts: - - localhost - - org4.example.com - ca: - expiry: 131400h - pathlength: 1 - -############################################################################# -# BCCSP (BlockChain Crypto Service Provider) section is used to select which -# crypto library implementation to use -############################################################################# -bccsp: - default: SW - sw: - hash: SHA2 - security: 256 - filekeystore: - # The directory used for the software file-based keystore - keystore: msp/keystore - -############################################################################# -# Multi CA section -# -# Each Fabric CA server contains one CA by default. This section is used -# to configure multiple CAs in a single server. -# -# 1) --cacount <number-of-CAs> -# Automatically generate <number-of-CAs> non-default CAs. The names of these -# additional CAs are "ca1", "ca2", ... "caN", where "N" is <number-of-CAs> -# This is particularly useful in a development environment to quickly set up -# multiple CAs. Note that, this config option is not applicable to intermediate CA server -# i.e., Fabric CA server that is started with intermediate.parentserver.url config -# option (-u command line option) -# -# 2) --cafiles <CA-config-files> -# For each CA config file in the list, generate a separate signing CA. Each CA -# config file in this list MAY contain all of the same elements as are found in -# the server config file except port, debug, and tls sections. -# -# Examples: -# fabric-ca-server start -b admin:adminpw --cacount 2 -# -# fabric-ca-server start -b admin:adminpw --cafiles ca/ca1/fabric-ca-server-config.yaml -# --cafiles ca/ca2/fabric-ca-server-config.yaml -# -############################################################################# - -cacount: - -cafiles: - -############################################################################# -# Intermediate CA section -# -# The relationship between servers and CAs is as follows: -# 1) A single server process may contain or function as one or more CAs. -# This is configured by the "Multi CA section" above. -# 2) Each CA is either a root CA or an intermediate CA. -# 3) Each intermediate CA has a parent CA which is either a root CA or another intermediate CA. -# -# This section pertains to configuration of #2 and #3. -# If the "intermediate.parentserver.url" property is set, -# then this is an intermediate CA with the specified parent -# CA. -# -# parentserver section -# url - The URL of the parent server -# caname - Name of the CA to enroll within the server -# -# enrollment section used to enroll intermediate CA with parent CA -# profile - Name of the signing profile to use in issuing the certificate -# label - Label to use in HSM operations -# -# tls section for secure socket connection -# certfiles - PEM-encoded list of trusted root certificate files -# client: -# certfile - PEM-encoded certificate file for when client authentication -# is enabled on server -# keyfile - PEM-encoded key file for when client authentication -# is enabled on server -############################################################################# -intermediate: - parentserver: - url: - caname: - - enrollment: - hosts: - profile: - label: - - tls: - certfiles: - client: - certfile: - keyfile: diff --git a/fabric/network/addOrg4/fabric-ca/registerEnroll.sh b/fabric/network/addOrg4/fabric-ca/registerEnroll.sh @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# - -function createOrg4 { - infoln "Enrolling the CA admin" - mkdir -p ../organizations/peerOrganizations/org4.example.com/ - - export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org4.example.com/ - - set -x - fabric-ca-client enroll -u https://admin:adminpw@localhost:13054 --caname ca-org4 --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - echo 'NodeOUs: - Enable: true - ClientOUIdentifier: - Certificate: cacerts/localhost-13054-ca-org4.pem - OrganizationalUnitIdentifier: client - PeerOUIdentifier: - Certificate: cacerts/localhost-13054-ca-org4.pem - OrganizationalUnitIdentifier: peer - AdminOUIdentifier: - Certificate: cacerts/localhost-13054-ca-org4.pem - OrganizationalUnitIdentifier: admin - OrdererOUIdentifier: - Certificate: cacerts/localhost-13054-ca-org4.pem - OrganizationalUnitIdentifier: orderer' > "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/config.yaml" - - infoln "Registering peer0" - set -x - fabric-ca-client register --caname ca-org4 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Registering user" - set -x - fabric-ca-client register --caname ca-org4 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Registering the org admin" - set -x - fabric-ca-client register --caname ca-org4 --id.name org4admin --id.secret org4adminpw --id.type admin --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - infoln "Generating the peer0 msp" - set -x - fabric-ca-client enroll -u https://peer0:peer0pw@localhost:13054 --caname ca-org4 -M "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp" --csr.hosts peer0.org4.example.com --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/config.yaml" - - infoln "Generating the peer0-tls certificates" - set -x - fabric-ca-client enroll -u https://peer0:peer0pw@localhost:13054 --caname ca-org4 -M "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls" --enrollment.profile tls --csr.hosts peer0.org4.example.com --csr.hosts localhost --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/ca.crt" - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/signcerts/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/server.crt" - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/keystore/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/server.key" - - mkdir "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/tlscacerts" - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/tlscacerts/ca.crt" - - mkdir "${PWD}/../organizations/peerOrganizations/org4.example.com/tlsca" - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/tlsca/tlsca.org4.example.com-cert.pem" - - mkdir "${PWD}/../organizations/peerOrganizations/org4.example.com/ca" - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/cacerts/"* "${PWD}/../organizations/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem" - - infoln "Generating the user msp" - set -x - fabric-ca-client enroll -u https://user1:user1pw@localhost:13054 --caname ca-org4 -M "${PWD}/../organizations/peerOrganizations/org4.example.com/users/User1@org4.example.com/msp" --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org4.example.com/users/User1@org4.example.com/msp/config.yaml" - - infoln "Generating the org admin msp" - set -x - fabric-ca-client enroll -u https://org4admin:org4adminpw@localhost:13054 --caname ca-org4 -M "${PWD}/../organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp" --tls.certfiles "${PWD}/fabric-ca/org4/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/../organizations/peerOrganizations/org4.example.com/msp/config.yaml" "${PWD}/../organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/config.yaml" -} diff --git a/fabric/network/addOrg4/org4-crypto.yaml b/fabric/network/addOrg4/org4-crypto.yaml @@ -1,21 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# --------------------------------------------------------------------------- -# "PeerOrgs" - Definition of organizations managing peer nodes -# --------------------------------------------------------------------------- -PeerOrgs: - # --------------------------------------------------------------------------- - # Org4 - # --------------------------------------------------------------------------- - - Name: Org4 - Domain: org4.example.com - EnableNodeOUs: true - Template: - Count: 1 - SANS: - - localhost - Users: - Count: 1 diff --git a/fabric/network/configtx/configtx.yaml b/fabric/network/configtx/configtx.yaml @@ -1,318 +1,181 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - ---- -################################################################################ -# -# Section: Organizations -# -# - This section defines the different organizational identities which will -# be referenced later in the configuration. -# -################################################################################ Organizations: + - &OrdererOrg + Name: OrdererOrg + ID: OrdererMSP + MSPDir: ../organizations/ordererOrganizations/example.com/msp + Policies: + Readers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Writers: + Type: Signature + Rule: "OR('OrdererMSP.member')" + Admins: + Type: Signature + Rule: "OR('OrdererMSP.admin')" + OrdererEndpoints: + - orderer.example.com:7050 + + - &Org1 + Name: Org1MSP + ID: Org1MSP + MSPDir: ../organizations/peerOrganizations/org1.example.com/msp + Policies: + Readers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org1MSP.admin', 'Org1MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org1MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org1MSP.peer')" + + - &Org2 + Name: Org2MSP + ID: Org2MSP + MSPDir: ../organizations/peerOrganizations/org2.example.com/msp + Policies: + Readers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org2MSP.admin', 'Org2MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org2MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org2MSP.peer')" + + - &Org3 + Name: Org3MSP + ID: Org3MSP + MSPDir: ../organizations/peerOrganizations/org3.example.com/msp + Policies: + Readers: + Type: Signature + Rule: "OR('Org3MSP.admin', 'Org3MSP.peer', 'Org3MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org3MSP.admin', 'Org3MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org3MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org3MSP.peer')" + + - &Org4 + Name: Org4MSP + ID: Org4MSP + MSPDir: ../organizations/peerOrganizations/org4.example.com/msp + Policies: + Readers: + Type: Signature + Rule: "OR('Org4MSP.admin', 'Org4MSP.peer', 'Org4MSP.client')" + Writers: + Type: Signature + Rule: "OR('Org4MSP.admin', 'Org4MSP.client')" + Admins: + Type: Signature + Rule: "OR('Org4MSP.admin')" + Endorsement: + Type: Signature + Rule: "OR('Org4MSP.peer')" - # SampleOrg defines an MSP using the sampleconfig. It should never be used - # in production but may be used as a template for other definitions - - &OrdererOrg - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: OrdererOrg - - # ID to load the MSP definition as - ID: OrdererMSP - - # MSPDir is the filesystem path which contains the MSP configuration - MSPDir: ../organizations/ordererOrganizations/example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/<Application|Orderer>/<OrgName>/<PolicyName> - Policies: - Readers: - Type: Signature - Rule: "OR('OrdererMSP.member')" - Writers: - Type: Signature - Rule: "OR('OrdererMSP.member')" - Admins: - Type: Signature - Rule: "OR('OrdererMSP.admin')" - - OrdererEndpoints: - - orderer.example.com:7050 - - - &Org1 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org1MSP - - # ID to load the MSP definition as - ID: Org1MSP - - MSPDir: ../organizations/peerOrganizations/org1.example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/<Application|Orderer>/<OrgName>/<PolicyName> - Policies: - Readers: - Type: Signature - Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org1MSP.admin', 'Org1MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org1MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org1MSP.peer')" - - - &Org2 - # DefaultOrg defines the organization which is used in the sampleconfig - # of the fabric.git development environment - Name: Org2MSP - - # ID to load the MSP definition as - ID: Org2MSP - - MSPDir: ../organizations/peerOrganizations/org2.example.com/msp - - # Policies defines the set of policies at this level of the config tree - # For organization policies, their canonical path is usually - # /Channel/<Application|Orderer>/<OrgName>/<PolicyName> - Policies: - Readers: - Type: Signature - Rule: "OR('Org2MSP.admin', 'Org2MSP.peer', 'Org2MSP.client')" - Writers: - Type: Signature - Rule: "OR('Org2MSP.admin', 'Org2MSP.client')" - Admins: - Type: Signature - Rule: "OR('Org2MSP.admin')" - Endorsement: - Type: Signature - Rule: "OR('Org2MSP.peer')" - -################################################################################ -# -# SECTION: Capabilities -# -# - This section defines the capabilities of fabric network. This is a new -# concept as of v1.1.0 and should not be utilized in mixed networks with -# v1.0.x peers and orderers. Capabilities define features which must be -# present in a fabric binary for that binary to safely participate in the -# fabric network. For instance, if a new MSP type is added, newer binaries -# might recognize and validate the signatures from this type, while older -# binaries without this support would be unable to validate those -# transactions. This could lead to different versions of the fabric binaries -# having different world states. Instead, defining a capability for a channel -# informs those binaries without this capability that they must cease -# processing transactions until they have been upgraded. For v1.0.x if any -# capabilities are defined (including a map with all capabilities turned off) -# then the v1.0.x peer will deliberately crash. -# -################################################################################ Capabilities: - # Channel capabilities apply to both the orderers and the peers and must be - # supported by both. - # Set the value of the capability to true to require it. - Channel: &ChannelCapabilities - # V2_0 capability ensures that orderers and peers behave according - # to v2.0 channel capabilities. Orderers and peers from - # prior releases would behave in an incompatible way, and are therefore - # not able to participate in channels at v2.0 capability. - # Prior to enabling V2.0 channel capabilities, ensure that all - # orderers and peers on a channel are at v2.0.0 or later. - V2_0: true - - # Orderer capabilities apply only to the orderers, and may be safely - # used with prior release peers. - # Set the value of the capability to true to require it. - Orderer: &OrdererCapabilities - # V2_0 orderer capability ensures that orderers behave according - # to v2.0 orderer capabilities. Orderers from - # prior releases would behave in an incompatible way, and are therefore - # not able to participate in channels at v2.0 orderer capability. - # Prior to enabling V2.0 orderer capabilities, ensure that all - # orderers on channel are at v2.0.0 or later. - V2_0: true + Channel: &ChannelCapabilities + V2_0: true + Orderer: &OrdererCapabilities + V2_0: true + Application: &ApplicationCapabilities + V2_0: true - # Application capabilities apply only to the peer network, and may be safely - # used with prior release orderers. - # Set the value of the capability to true to require it. - Application: &ApplicationCapabilities - # V2_0 application capability ensures that peers behave according - # to v2.0 application capabilities. Peers from - # prior releases would behave in an incompatible way, and are therefore - # not able to participate in channels at v2.0 application capability. - # Prior to enabling V2.0 application capabilities, ensure that all - # peers on channel are at v2.0.0 or later. - V2_0: true - -################################################################################ -# -# SECTION: Application -# -# - This section defines the values to encode into a config transaction or -# genesis block for application related parameters -# -################################################################################ Application: &ApplicationDefaults + Organizations: + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + LifecycleEndorsement: + Type: ImplicitMeta + Rule: "MAJORITY Endorsement" + Endorsement: + Type: ImplicitMeta + Rule: "MAJORITY Endorsement" + Capabilities: + <<: *ApplicationCapabilities - # Organizations is the list of orgs which are defined as participants on - # the application side of the network - Organizations: - - # Policies defines the set of policies at this level of the config tree - # For Application policies, their canonical path is - # /Channel/Application/<PolicyName> - Policies: - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - LifecycleEndorsement: - Type: ImplicitMeta - Rule: "MAJORITY Endorsement" - Endorsement: - Type: ImplicitMeta - Rule: "MAJORITY Endorsement" - - Capabilities: - <<: *ApplicationCapabilities -################################################################################ -# -# SECTION: Orderer -# -# - This section defines the values to encode into a config transaction or -# genesis block for orderer related parameters -# -################################################################################ Orderer: &OrdererDefaults + OrdererType: etcdraft + Addresses: + - orderer.example.com:7050 + EtcdRaft: + Consenters: + - Host: orderer.example.com + Port: 7050 + ClientTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt + ServerTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt + BatchTimeout: 2s + BatchSize: + MaxMessageCount: 10 + AbsoluteMaxBytes: 99 MB + PreferredMaxBytes: 512 KB + Organizations: + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + BlockValidation: + Type: ImplicitMeta + Rule: "ANY Writers" - # Orderer Type: The orderer implementation to start - OrdererType: etcdraft - - # Addresses used to be the list of orderer addresses that clients and peers - # could connect to. However, this does not allow clients to associate orderer - # addresses and orderer organizations which can be useful for things such - # as TLS validation. The preferred way to specify orderer addresses is now - # to include the OrdererEndpoints item in your org definition - Addresses: - - orderer.example.com:7050 - - EtcdRaft: - Consenters: - - Host: orderer.example.com - Port: 7050 - ClientTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt - ServerTLSCert: ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt - - # Batch Timeout: The amount of time to wait before creating a batch - BatchTimeout: 2s - - # Batch Size: Controls the number of messages batched into a block - BatchSize: - - # Max Message Count: The maximum number of messages to permit in a batch - MaxMessageCount: 10 - - # Absolute Max Bytes: The absolute maximum number of bytes allowed for - # the serialized messages in a batch. - AbsoluteMaxBytes: 99 MB - - # Preferred Max Bytes: The preferred maximum number of bytes allowed for - # the serialized messages in a batch. A message larger than the preferred - # max bytes will result in a batch larger than preferred max bytes. - PreferredMaxBytes: 512 KB - - # Organizations is the list of orgs which are defined as participants on - # the orderer side of the network - Organizations: - - # Policies defines the set of policies at this level of the config tree - # For Orderer policies, their canonical path is - # /Channel/Orderer/<PolicyName> - Policies: - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - # BlockValidation specifies what signatures must be included in the block - # from the orderer for the peer to validate it. - BlockValidation: - Type: ImplicitMeta - Rule: "ANY Writers" - -################################################################################ -# -# CHANNEL -# -# This section defines the values to encode into a config transaction or -# genesis block for channel related parameters. -# -################################################################################ Channel: &ChannelDefaults - # Policies defines the set of policies at this level of the config tree - # For Channel policies, their canonical path is - # /Channel/<PolicyName> - Policies: - # Who may invoke the 'Deliver' API - Readers: - Type: ImplicitMeta - Rule: "ANY Readers" - # Who may invoke the 'Broadcast' API - Writers: - Type: ImplicitMeta - Rule: "ANY Writers" - # By default, who may modify elements at this config level - Admins: - Type: ImplicitMeta - Rule: "MAJORITY Admins" - - # Capabilities describes the channel level capabilities, see the - # dedicated Capabilities section elsewhere in this file for a full - # description - Capabilities: - <<: *ChannelCapabilities + Policies: + Readers: + Type: ImplicitMeta + Rule: "ANY Readers" + Writers: + Type: ImplicitMeta + Rule: "ANY Writers" + Admins: + Type: ImplicitMeta + Rule: "MAJORITY Admins" + Capabilities: + <<: *ChannelCapabilities -################################################################################ -# -# Profile -# -# - Different configuration profiles may be encoded here to be specified -# as parameters to the configtxgen tool -# -################################################################################ Profiles: - - TwoOrgsApplicationGenesis: - <<: *ChannelDefaults - Orderer: - <<: *OrdererDefaults - Organizations: - - *OrdererOrg - Capabilities: - <<: *OrdererCapabilities - Application: - <<: *ApplicationDefaults - Organizations: - - *Org1 - - *Org2 - Capabilities: - <<: *ApplicationCapabilities -\ No newline at end of file + FourOrgsApplicationGenesis: + <<: *ChannelDefaults + Orderer: + <<: *OrdererDefaults + Organizations: + - *OrdererOrg + Capabilities: + <<: *OrdererCapabilities + Application: + <<: *ApplicationDefaults + Organizations: + - *Org1 + - *Org2 + - *Org3 + - *Org4 + Capabilities: + <<: *ApplicationCapabilities diff --git a/fabric/network/docker/docker-compose-ca.yaml b/fabric/network/docker/docker-compose-ca.yaml @@ -1,16 +1,8 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2.4' - networks: - test: - name: fabric_test + matiru: + name: matiru-network services: - ca_org1: image: hyperledger/fabric-ca:latest labels: @@ -27,7 +19,7 @@ services: - ../organizations/fabric-ca/org1:/etc/hyperledger/fabric-ca-server container_name: ca_org1 networks: - - test + - matiru ca_org2: image: hyperledger/fabric-ca:latest @@ -45,7 +37,43 @@ services: - ../organizations/fabric-ca/org2:/etc/hyperledger/fabric-ca-server container_name: ca_org2 networks: - - test + - matiru + + ca_org3: + image: hyperledger/fabric-ca:latest + labels: + service: hyperledger-fabric + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org3 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_PORT=11054 + ports: + - "11054:11054" + command: sh -c 'fabric-ca-server start -b admin:adminpw -d' + volumes: + - ../organizations/fabric-ca/org3:/etc/hyperledger/fabric-ca-server + container_name: ca_org3 + networks: + - matiru + + ca_org4: + image: hyperledger/fabric-ca:latest + labels: + service: hyperledger-fabric + environment: + - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server + - FABRIC_CA_SERVER_CA_NAME=ca-org4 + - FABRIC_CA_SERVER_TLS_ENABLED=true + - FABRIC_CA_SERVER_PORT=13054 + ports: + - "13054:13054" + command: sh -c 'fabric-ca-server start -b admin:adminpw -d' + volumes: + - ../organizations/fabric-ca/org4:/etc/hyperledger/fabric-ca-server + container_name: ca_org4 + networks: + - matiru ca_orderer: image: hyperledger/fabric-ca:latest @@ -63,4 +91,4 @@ services: - ../organizations/fabric-ca/ordererOrg:/etc/hyperledger/fabric-ca-server container_name: ca_orderer networks: - - test + - matiru diff --git a/fabric/network/docker/docker-compose-couch.yaml b/fabric/network/docker/docker-compose-couch.yaml @@ -1,13 +1,6 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: '2.4' - networks: - test: - name: fabric_test + matiru: + name: matiru-network services: couchdb0: @@ -15,25 +8,18 @@ services: image: couchdb:3.1.1 labels: service: hyperledger-fabric - # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password - # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: - COUCHDB_USER=admin - COUCHDB_PASSWORD=adminpw - # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, - # for example map it to utilize Fauxton User Interface in dev environments. ports: - "5984:5984" networks: - - test + - matiru peer0.org1.example.com: environment: - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984 - # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD - # provide the credentials for ledger to connect to CouchDB. The username and password must - # match the username and password set for the associated CouchDB. - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw depends_on: @@ -44,26 +30,63 @@ services: image: couchdb:3.1.1 labels: service: hyperledger-fabric - # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password - # for CouchDB. This will prevent CouchDB from operating in an "Admin Party" mode. environment: - COUCHDB_USER=admin - COUCHDB_PASSWORD=adminpw - # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service, - # for example map it to utilize Fauxton User Interface in dev environments. ports: - "7984:5984" networks: - - test + - matiru peer0.org2.example.com: environment: - CORE_LEDGER_STATE_STATEDATABASE=CouchDB - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984 - # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD - # provide the credentials for ledger to connect to CouchDB. The username and password must - # match the username and password set for the associated CouchDB. - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw depends_on: - couchdb1 + + couchdb2: + container_name: couchdb2 + image: couchdb:3.1.1 + labels: + service: hyperledger-fabric + environment: + - COUCHDB_USER=admin + - COUCHDB_PASSWORD=adminpw + ports: + - "9984:5984" + networks: + - matiru + + peer0.org3.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984 + - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin + - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw + depends_on: + - couchdb2 + + couchdb3: + container_name: couchdb3 + image: couchdb:3.1.1 + labels: + service: hyperledger-fabric + environment: + - COUCHDB_USER=admin + - COUCHDB_PASSWORD=adminpw + ports: + - "11984:5984" + networks: + - matiru + + peer0.org4.example.com: + environment: + - CORE_LEDGER_STATE_STATEDATABASE=CouchDB + - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984 + - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin + - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw + depends_on: + - couchdb3 diff --git a/fabric/network/docker/docker-compose-network.yaml b/fabric/network/docker/docker-compose-network.yaml @@ -0,0 +1,213 @@ +volumes: + orderer.example.com: + peer0.org1.example.com: + peer0.org2.example.com: + peer0.org3.example.com: + peer0.org4.example.com: + +networks: + matiru: + name: matiru-network + +services: + orderer.example.com: + container_name: orderer.example.com + image: hyperledger/fabric-orderer:latest + labels: + service: hyperledger-fabric + environment: + - FABRIC_LOGGING_SPEC=INFO + - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 + - ORDERER_GENERAL_LISTENPORT=7050 + - ORDERER_GENERAL_LOCALMSPID=OrdererMSP + - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp + - ORDERER_GENERAL_TLS_ENABLED=true + - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 + - ORDERER_KAFKA_VERBOSE=true + - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_GENERAL_BOOTSTRAPMETHOD=none + - ORDERER_CHANNELPARTICIPATION_ENABLED=true + - ORDERER_ADMIN_TLS_ENABLED=true + - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt + - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key + - ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] + - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053 + working_dir: /opt/gopath/src/github.com/hyperledger/fabric + command: orderer + volumes: + - ../system-genesis-block/genesis.block:/var/hyperledger/orderer/orderer.genesis.block + - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp + - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls + - orderer.example.com:/var/hyperledger/production/orderer + ports: + - 7050:7050 + - 7053:7053 + networks: + - matiru + + peer0.org1.example.com: + container_name: peer0.org1.example.com + image: hyperledger/fabric-peer:latest + labels: + service: hyperledger-fabric + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=matiru-network + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt + - CORE_PEER_ID=peer0.org1.example.com + - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:7051 + - CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 + - CORE_PEER_LOCALMSPID=Org1MSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp + - ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls + - peer0.org1.example.com:/var/hyperledger/production + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: peer node start + ports: + - 7051:7051 + networks: + - matiru + + peer0.org2.example.com: + container_name: peer0.org2.example.com + image: hyperledger/fabric-peer:latest + labels: + service: hyperledger-fabric + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=matiru-network + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt + - CORE_PEER_ID=peer0.org2.example.com + - CORE_PEER_ADDRESS=peer0.org2.example.com:9051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:9051 + - CORE_PEER_CHAINCODEADDRESS=peer0.org2.example.com:9052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:9052 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:9051 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:9051 + - CORE_PEER_LOCALMSPID=Org2MSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - ../organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp + - ../organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls + - peer0.org2.example.com:/var/hyperledger/production + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: peer node start + ports: + - 9051:9051 + networks: + - matiru + + peer0.org3.example.com: + container_name: peer0.org3.example.com + image: hyperledger/fabric-peer:latest + labels: + service: hyperledger-fabric + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=matiru-network + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt + - CORE_PEER_ID=peer0.org3.example.com + - CORE_PEER_ADDRESS=peer0.org3.example.com:11051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:11051 + - CORE_PEER_CHAINCODEADDRESS=peer0.org3.example.com:11052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:11052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org3.example.com:11051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org3.example.com:11051 + - CORE_PEER_LOCALMSPID=Org3MSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp:/etc/hyperledger/fabric/msp + - ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls:/etc/hyperledger/fabric/tls + - peer0.org3.example.com:/var/hyperledger/production + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: peer node start + ports: + - 11051:11051 + networks: + - matiru + + peer0.org4.example.com: + container_name: peer0.org4.example.com + image: hyperledger/fabric-peer:latest + labels: + service: hyperledger-fabric + environment: + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=matiru-network + - FABRIC_LOGGING_SPEC=INFO + - CORE_PEER_TLS_ENABLED=true + - CORE_PEER_PROFILE_ENABLED=true + - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt + - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key + - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt + - CORE_PEER_ID=peer0.org4.example.com + - CORE_PEER_ADDRESS=peer0.org4.example.com:13051 + - CORE_PEER_LISTENADDRESS=0.0.0.0:13051 + - CORE_PEER_CHAINCODEADDRESS=peer0.org4.example.com:13052 + - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:13052 + - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org4.example.com:13051 + - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org4.example.com:13051 + - CORE_PEER_LOCALMSPID=Org4MSP + volumes: + - /var/run/docker.sock:/host/var/run/docker.sock + - ../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp:/etc/hyperledger/fabric/msp + - ../organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls:/etc/hyperledger/fabric/tls + - peer0.org4.example.com:/var/hyperledger/production + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: peer node start + ports: + - 13051:13051 + networks: + - matiru + + cli: + container_name: cli + image: hyperledger/fabric-tools:latest + labels: + service: hyperledger-fabric + tty: true + stdin_open: true + environment: + - GOPATH=/opt/gopath + - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock + - FABRIC_LOGGING_SPEC=INFO + working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer + command: /usr/bin/env bash + volumes: + - /var/run/:/host/var/run/ + - ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations + - ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ + depends_on: + - peer0.org1.example.com + - peer0.org2.example.com + - peer0.org3.example.com + - peer0.org4.example.com + networks: + - matiru diff --git a/fabric/network/docker/docker-compose-test-net.yaml b/fabric/network/docker/docker-compose-test-net.yaml @@ -1,156 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -version: "2.4" - -volumes: - orderer.example.com: - peer0.org1.example.com: - peer0.org2.example.com: - -networks: - test: - name: fabric_test - -services: - orderer.example.com: - container_name: orderer.example.com - image: hyperledger/fabric-orderer:latest - labels: - service: hyperledger-fabric - environment: - - FABRIC_LOGGING_SPEC=INFO - - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - - ORDERER_GENERAL_LISTENPORT=7050 - - ORDERER_GENERAL_LOCALMSPID=OrdererMSP - - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp - # enabled TLS - - ORDERER_GENERAL_TLS_ENABLED=true - - ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key - - ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt - - ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] - - ORDERER_KAFKA_TOPIC_REPLICATIONFACTOR=1 - - ORDERER_KAFKA_VERBOSE=true - - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt - - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key - - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] - - ORDERER_GENERAL_BOOTSTRAPMETHOD=none - - ORDERER_CHANNELPARTICIPATION_ENABLED=true - - ORDERER_ADMIN_TLS_ENABLED=true - - ORDERER_ADMIN_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt - - ORDERER_ADMIN_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key - - ORDERER_ADMIN_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] - - ORDERER_ADMIN_TLS_CLIENTROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] - - ORDERER_ADMIN_LISTENADDRESS=0.0.0.0:7053 - working_dir: /opt/gopath/src/github.com/hyperledger/fabric - command: orderer - volumes: - - ../system-genesis-block/genesis.block:/var/hyperledger/orderer/orderer.genesis.block - - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp - - ../organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls - - orderer.example.com:/var/hyperledger/production/orderer - ports: - - 7050:7050 - - 7053:7053 - networks: - - test - - peer0.org1.example.com: - container_name: peer0.org1.example.com - image: hyperledger/fabric-peer:latest - labels: - service: hyperledger-fabric - environment: - #Generic peer variables - - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_test - - FABRIC_LOGGING_SPEC=INFO - #- FABRIC_LOGGING_SPEC=DEBUG - - CORE_PEER_TLS_ENABLED=true - - CORE_PEER_PROFILE_ENABLED=true - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - # Peer specific variabes - - CORE_PEER_ID=peer0.org1.example.com - - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 - - CORE_PEER_LISTENADDRESS=0.0.0.0:7051 - - CORE_PEER_CHAINCODEADDRESS=peer0.org1.example.com:7052 - - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052 - - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051 - - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 - - CORE_PEER_LOCALMSPID=Org1MSP - volumes: - - /var/run/docker.sock:/host/var/run/docker.sock - - ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp - - ../organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls - - peer0.org1.example.com:/var/hyperledger/production - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: peer node start - ports: - - 7051:7051 - networks: - - test - - peer0.org2.example.com: - container_name: peer0.org2.example.com - image: hyperledger/fabric-peer:latest - labels: - service: hyperledger-fabric - environment: - #Generic peer variables - - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=fabric_test - - FABRIC_LOGGING_SPEC=INFO - #- FABRIC_LOGGING_SPEC=DEBUG - - CORE_PEER_TLS_ENABLED=true - - CORE_PEER_PROFILE_ENABLED=true - - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt - - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key - - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt - # Peer specific variabes - - CORE_PEER_ID=peer0.org2.example.com - - CORE_PEER_ADDRESS=peer0.org2.example.com:9051 - - CORE_PEER_LISTENADDRESS=0.0.0.0:9051 - - CORE_PEER_CHAINCODEADDRESS=peer0.org2.example.com:9052 - - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:9052 - - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:9051 - - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:9051 - - CORE_PEER_LOCALMSPID=Org2MSP - volumes: - - /var/run/docker.sock:/host/var/run/docker.sock - - ../organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp - - ../organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls - - peer0.org2.example.com:/var/hyperledger/production - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: peer node start - ports: - - 9051:9051 - networks: - - test - - cli: - container_name: cli - image: hyperledger/fabric-tools:latest - labels: - service: hyperledger-fabric - tty: true - stdin_open: true - environment: - - GOPATH=/opt/gopath - - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock - - FABRIC_LOGGING_SPEC=INFO - #- FABRIC_LOGGING_SPEC=DEBUG - working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer - command: /usr/bin/env bash - volumes: - - /var/run/:/host/var/run/ - - ../organizations:/opt/gopath/src/github.com/hyperledger/fabric/peer/organizations - - ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ - depends_on: - - peer0.org1.example.com - - peer0.org2.example.com - networks: - - test diff --git a/fabric/network/network.sh b/fabric/network/network.sh @@ -1,133 +1,35 @@ #!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# -# This script brings up a Hyperledger Fabric network for testing smart contracts -# and applications. The test network consists of two organizations with one -# peer each, and a single node Raft ordering service. Users can also use this -# script to create a channel deploy a chaincode on the channel -# -# prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries -# this may be commented out to resolve installed version of tools if desired export PATH=${PWD}/../bin:$PATH export FABRIC_CFG_PATH=${PWD}/configtx export VERBOSE=false . scripts/utils.sh -# Obtain CONTAINER_IDS and remove them -# This function is called when you bring a network down function clearContainers() { infoln "Removing remaining containers" docker rm -f $(docker ps -aq --filter label=service=hyperledger-fabric) 2>/dev/null || true docker rm -f $(docker ps -aq --filter name='dev-peer*') 2>/dev/null || true } -# Delete any images that were generated as a part of this setup -# specifically the following images are often left behind: -# This function is called when you bring the network down function removeUnwantedImages() { infoln "Removing generated chaincode docker images" docker image rm -f $(docker images -aq --filter reference='dev-peer*') 2>/dev/null || true } -# Versions of fabric known not to work with the test network -NONWORKING_VERSIONS="^1\.0\. ^1\.1\. ^1\.2\. ^1\.3\. ^1\.4\." - -# Do some basic sanity checking to make sure that the appropriate versions of fabric -# binaries/images are available. In the future, additional checking for the presence -# of go or other items could be added. function checkPrereqs() { - ## Check if your have cloned the peer binaries and configuration files. peer version > /dev/null 2>&1 - if [[ $? -ne 0 || ! -d "../config" ]]; then errorln "Peer binary and configuration files not found.." - errorln - errorln "Follow the instructions in the Fabric docs to install the Fabric Binaries:" - errorln "https://hyperledger-fabric.readthedocs.io/en/latest/install.html" exit 1 fi - # use the fabric tools container to see if the samples and binaries match your - # docker images - LOCAL_VERSION=$(peer version | sed -ne 's/ Version: //p') - DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:latest peer version | sed -ne 's/ Version: //p' | head -1) - - infoln "LOCAL_VERSION=$LOCAL_VERSION" - infoln "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION" - - if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ]; then - warnln "Local fabric binaries and docker images are out of sync. This may cause problems." - fi - - for UNSUPPORTED_VERSION in $NONWORKING_VERSIONS; do - infoln "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION - if [ $? -eq 0 ]; then - fatalln "Local Fabric binary version of $LOCAL_VERSION does not match the versions supported by the test network." - fi - - infoln "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION - if [ $? -eq 0 ]; then - fatalln "Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match the versions supported by the test network." - fi - done - - ## Check for fabric-ca - if [ "$CRYPTO" == "Certificate Authorities" ]; then - - fabric-ca-client version > /dev/null 2>&1 - if [[ $? -ne 0 ]]; then - errorln "fabric-ca-client binary not found.." - errorln - errorln "Follow the instructions in the Fabric docs to install the Fabric Binaries:" - errorln "https://hyperledger-fabric.readthedocs.io/en/latest/install.html" - exit 1 - fi - CA_LOCAL_VERSION=$(fabric-ca-client version | sed -ne 's/ Version: //p') - CA_DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-ca:latest fabric-ca-client version | sed -ne 's/ Version: //p' | head -1) - infoln "CA_LOCAL_VERSION=$CA_LOCAL_VERSION" - infoln "CA_DOCKER_IMAGE_VERSION=$CA_DOCKER_IMAGE_VERSION" - - if [ "$CA_LOCAL_VERSION" != "$CA_DOCKER_IMAGE_VERSION" ]; then - warnln "Local fabric-ca binaries and docker images are out of sync. This may cause problems." - fi - fi } -# Before you can bring up a network, each organization needs to generate the crypto -# material that will define that organization on the network. Because Hyperledger -# Fabric is a permissioned blockchain, each node and user on the network needs to -# use certificates and keys to sign and verify its actions. In addition, each user -# needs to belong to an organization that is recognized as a member of the network. -# You can use the Cryptogen tool or Fabric CAs to generate the organization crypto -# material. - -# By default, the sample network uses cryptogen. Cryptogen is a tool that is -# meant for development and testing that can quickly create the certificates and keys -# that can be consumed by a Fabric network. The cryptogen tool consumes a series -# of configuration files for each organization in the "organizations/cryptogen" -# directory. Cryptogen uses the files to generate the crypto material for each -# org in the "organizations" directory. - -# You can also use Fabric CAs to generate the crypto material. CAs sign the certificates -# and keys that they generate to create a valid root of trust for each organization. -# The script uses Docker Compose to bring up three CAs, one for each peer organization -# and the ordering organization. The configuration file for creating the Fabric CA -# servers are in the "organizations/fabric-ca" directory. Within the same directory, -# the "registerEnroll.sh" script uses the Fabric CA client to create the identities, -# certificates, and MSP folders that are needed to create the test network in the -# "organizations/ordererOrganizations" directory. - -# Create Organization crypto material using cryptogen or CAs function createOrgs() { if [ -d "organizations/peerOrganizations" ]; then rm -Rf organizations/peerOrganizations && rm -Rf organizations/ordererOrganizations fi - # Create crypto material using cryptogen if [ "$CRYPTO" == "cryptogen" ]; then which cryptogen if [ "$?" -ne 0 ]; then @@ -135,20 +37,9 @@ function createOrgs() { fi infoln "Generating certificates using cryptogen tool" - infoln "Creating Org1 Identities" - + infoln "Creating Peer Org Identities" set -x - cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations" - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - fatalln "Failed to generate certificates..." - fi - - infoln "Creating Org2 Identities" - - set -x - cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations" + cryptogen generate --config=./organizations/cryptogen/crypto-config-orgs.yaml --output="organizations" res=$? { set +x; } 2>/dev/null if [ $res -ne 0 ]; then @@ -156,7 +47,6 @@ function createOrgs() { fi infoln "Creating Orderer Org Identities" - set -x cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations" res=$? @@ -167,76 +57,45 @@ function createOrgs() { fi - # Create crypto material using Fabric CA if [ "$CRYPTO" == "Certificate Authorities" ]; then infoln "Generating certificates using Fabric CA" docker-compose -f $COMPOSE_FILE_CA up -d 2>&1 - . organizations/fabric-ca/registerEnroll.sh + infoln "Waiting for Fabric CAs to start" + while : + do + if [ ! -f "organizations/fabric-ca/ordererOrg/tls-cert.pem" ]; then + sleep 1 + else + break + fi + done - while : - do - if [ ! -f "organizations/fabric-ca/org1/tls-cert.pem" ]; then - sleep 1 - else - break - fi - done + . organizations/fabric-ca/registerEnroll.sh infoln "Creating Org1 Identities" - createOrg1 - infoln "Creating Org2 Identities" - createOrg2 - + infoln "Creating Org3 Identities" + createOrg3 + infoln "Creating Org4 Identities" + createOrg4 infoln "Creating Orderer Org Identities" - createOrderer - fi - infoln "Generating CCP files for Org1 and Org2" + infoln "Generating CCP files for all Orgs" ./organizations/ccp-generate.sh } -# Once you create the organization crypto material, you need to create the -# genesis block of the application channel. - -# The configtxgen tool is used to create the genesis block. Configtxgen consumes a -# "configtx.yaml" file that contains the definitions for the sample network. The -# genesis block is defined using the "TwoOrgsApplicationGenesis" profile at the bottom -# of the file. This profile defines an application channel consisting of our two Peer Orgs. -# The peer and ordering organizations are defined in the "Profiles" section at the -# top of the file. As part of each organization profile, the file points to the -# location of the MSP directory for each member. This MSP is used to create the channel -# MSP that defines the root of trust for each organization. In essence, the channel -# MSP allows the nodes and users to be recognized as network members. -# -# If you receive the following warning, it can be safely ignored: -# -# [bccsp] GetDefault -> WARN 001 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP. -# -# You can ignore the logs regarding intermediate certs, we are not using them in -# this crypto implementation. - -# After we create the org crypto material and the application channel genesis block, -# we can now bring up the peers and ordering service. By default, the base -# file for creating the network is "docker-compose-test-net.yaml" in the ``docker`` -# folder. This file defines the environment variables and file mounts that -# point the crypto material and genesis block that were created in earlier. - -# Bring up the peer and orderer nodes using docker compose. function networkUp() { checkPrereqs - # generate artifacts if they don't exist if [ ! -d "organizations/peerOrganizations" ]; then createOrgs fi COMPOSE_FILES="-f ${COMPOSE_FILE_BASE}" - if [ "${DATABASE}" == "couchdb" ]; then COMPOSE_FILES="${COMPOSE_FILES} -f ${COMPOSE_FILE_COUCH}" fi @@ -249,107 +108,53 @@ function networkUp() { fi } -# call the script to create the channel, join the peers of org1 and org2, -# and then update the anchor peers for each organization function createChannel() { - # Bring up the network if it is not already up. - if [ ! -d "organizations/peerOrganizations" ]; then infoln "Bringing up network" networkUp fi - - # now run the script that creates a channel. This script uses configtxgen once - # to create the channel creation transaction and the anchor peer updates. scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE } - -## Call the script to deploy a chaincode to the channel function deployCC() { scripts/deployCC.sh $CHANNEL_NAME $CC_NAME $CC_SRC_PATH $CC_SRC_LANGUAGE $CC_VERSION $CC_SEQUENCE $CC_INIT_FCN $CC_END_POLICY $CC_COLL_CONFIG $CLI_DELAY $MAX_RETRY $VERBOSE - if [ $? -ne 0 ]; then fatalln "Deploying chaincode failed" fi } - -# Tear down running network function networkDown() { - # stop org3 containers also in addition to org1 and org2, in case we were running sample to add org3 docker-compose -f $COMPOSE_FILE_BASE -f $COMPOSE_FILE_COUCH -f $COMPOSE_FILE_CA down --volumes --remove-orphans - docker-compose -f $COMPOSE_FILE_COUCH_ORG3 -f $COMPOSE_FILE_ORG3 down --volumes --remove-orphans - docker-compose -f $COMPOSE_FILE_COUCH_ORG4 -f $COMPOSE_FILE_ORG4 down --volumes --remove-orphans - - # Don't remove the generated artifacts -- note, the ledgers are always removed if [ "$MODE" != "restart" ]; then - # Bring down the network, deleting the volumes - #Cleanup the chaincode containers clearContainers - #Cleanup images removeUnwantedImages - # remove orderer block and other channel configuration transactions and certs docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf system-genesis-block/*.block organizations/peerOrganizations organizations/ordererOrganizations' - ## remove fabric ca artifacts docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf organizations/fabric-ca/org1/msp organizations/fabric-ca/org1/tls-cert.pem organizations/fabric-ca/org1/ca-cert.pem organizations/fabric-ca/org1/IssuerPublicKey organizations/fabric-ca/org1/IssuerRevocationPublicKey organizations/fabric-ca/org1/fabric-ca-server.db' docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf organizations/fabric-ca/org2/msp organizations/fabric-ca/org2/tls-cert.pem organizations/fabric-ca/org2/ca-cert.pem organizations/fabric-ca/org2/IssuerPublicKey organizations/fabric-ca/org2/IssuerRevocationPublicKey organizations/fabric-ca/org2/fabric-ca-server.db' + docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf organizations/fabric-ca/org3/msp organizations/fabric-ca/org3/tls-cert.pem organizations/fabric-ca/org3/ca-cert.pem organizations/fabric-ca/org3/IssuerPublicKey organizations/fabric-ca/org3/IssuerRevocationPublicKey organizations/fabric-ca/org3/fabric-ca-server.db' + docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf organizations/fabric-ca/org4/msp organizations/fabric-ca/org4/tls-cert.pem organizations/fabric-ca/org4/ca-cert.pem organizations/fabric-ca/org4/IssuerPublicKey organizations/fabric-ca/org4/IssuerRevocationPublicKey organizations/fabric-ca/org4/fabric-ca-server.db' docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf organizations/fabric-ca/ordererOrg/msp organizations/fabric-ca/ordererOrg/tls-cert.pem organizations/fabric-ca/ordererOrg/ca-cert.pem organizations/fabric-ca/ordererOrg/IssuerPublicKey organizations/fabric-ca/ordererOrg/IssuerRevocationPublicKey organizations/fabric-ca/ordererOrg/fabric-ca-server.db' - docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db' - docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf addOrg4/fabric-ca/org4/msp addOrg4/fabric-ca/org4/tls-cert.pem addOrg4/fabric-ca/org4/ca-cert.pem addOrg4/fabric-ca/org4/IssuerPublicKey addOrg4/fabric-ca/org4/IssuerRevocationPublicKey addOrg4/fabric-ca/org4/fabric-ca-server.db' - - # remove channel and script artifacts docker run --rm -v "$(pwd):/data" busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz' fi } -# Using crpto vs CA. default is cryptogen CRYPTO="cryptogen" -# timeout duration - the duration the CLI should wait for a response from -# another container before giving up MAX_RETRY=8 -# default for delay between commands CLI_DELAY=3 -# channel name defaults to "mychannel" CHANNEL_NAME="mychannel" -# chaincode name defaults to "NA" CC_NAME="NA" -# chaincode path defaults to "NA" CC_SRC_PATH="NA" -# endorsement policy defaults to "NA". This would allow chaincodes to use the majority default policy. CC_END_POLICY="NA" -# collection configuration defaults to "NA" CC_COLL_CONFIG="NA" -# chaincode init function defaults to "NA" CC_INIT_FCN="NA" -# use this as the default docker-compose yaml definition -COMPOSE_FILE_BASE=docker/docker-compose-test-net.yaml -# docker-compose.yaml file if you are using couchdb +COMPOSE_FILE_BASE=docker/docker-compose-network.yaml COMPOSE_FILE_COUCH=docker/docker-compose-couch.yaml -# certificate authorities compose file COMPOSE_FILE_CA=docker/docker-compose-ca.yaml -# use this as the docker compose couch file for org3 -COMPOSE_FILE_COUCH_ORG3=addOrg3/docker/docker-compose-couch-org3.yaml -# use this as the default docker-compose yaml definition for org3 -COMPOSE_FILE_ORG3=addOrg3/docker/docker-compose-org3.yaml -# use this as the docker compose couch file for org4 -COMPOSE_FILE_COUCH_ORG4=addOrg4/docker/docker-compose-couch-org4.yaml -# use this as the default docker-compose yaml definition for org4 -COMPOSE_FILE_ORG4=addOrg4/docker/docker-compose-org4.yaml - -# -# chaincode language defaults to "NA" CC_SRC_LANGUAGE="NA" -# Chaincode version CC_VERSION="1.0" -# Chaincode definition sequence CC_SEQUENCE=1 -# default database DATABASE="leveldb" -# Parse commandline args - -## Parse mode if [[ $# -lt 1 ]] ; then printHelp exit 0 @@ -358,7 +163,6 @@ else shift fi -# parse a createChannel subcommand if used if [[ $# -ge 1 ]] ; then key="$1" if [[ "$key" == "createChannel" ]]; then @@ -367,8 +171,6 @@ if [[ $# -ge 1 ]] ; then fi fi -# parse flags - while [[ $# -ge 1 ]] ; do key="$1" case $key in @@ -440,19 +242,17 @@ while [[ $# -ge 1 ]] ; do shift done -# Are we generating crypto material with this command? if [ ! -d "organizations/peerOrganizations" ]; then CRYPTO_MODE="with crypto from '${CRYPTO}'" else CRYPTO_MODE="" fi -# Determine mode of operation and printing out what we asked for if [ "$MODE" == "up" ]; then infoln "Starting nodes with CLI timeout of '${MAX_RETRY}' tries and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}' ${CRYPTO_MODE}" elif [ "$MODE" == "createChannel" ]; then infoln "Creating channel '${CHANNEL_NAME}'." - infoln "If network is not up, starting nodes with CLI timeout of '${MAX_RETRY}' tries and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE} ${CRYPTO_MODE}" + infoln "If network is not up, starting nodes with CLI timeout of '${MAX_RETRY}' tries and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}' ${CRYPTO_MODE}" elif [ "$MODE" == "down" ]; then infoln "Stopping network" elif [ "$MODE" == "restart" ]; then diff --git a/fabric/network/organizations/ccp-generate.sh b/fabric/network/organizations/ccp-generate.sh @@ -43,3 +43,21 @@ CAPEM=organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-ce echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.json echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.yaml + +ORG=3 +P0PORT=11051 +CAPORT=11054 +PEERPEM=organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem +CAPEM=organizations/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem + +echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org3.example.com/connection-org3.json +echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org3.example.com/connection-org3.yaml + +ORG=4 +P0PORT=13051 +CAPORT=13054 +PEERPEM=organizations/peerOrganizations/org4.example.com/tlsca/tlsca.org4.example.com-cert.pem +CAPEM=organizations/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem + +echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org4.example.com/connection-org4.json +echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > organizations/peerOrganizations/org4.example.com/connection-org4.yaml diff --git a/fabric/network/organizations/ccp-template.json b/fabric/network/organizations/ccp-template.json @@ -1,49 +1,45 @@ { - "name": "test-network-org${ORG}", - "version": "1.0.0", - "client": { - "organization": "Org${ORG}", - "connection": { - "timeout": { - "peer": { - "endorser": "300" - } - } - } - }, - "organizations": { - "Org${ORG}": { - "mspid": "Org${ORG}MSP", - "peers": [ - "peer0.org${ORG}.example.com" - ], - "certificateAuthorities": [ - "ca.org${ORG}.example.com" - ] - } - }, - "peers": { - "peer0.org${ORG}.example.com": { - "url": "grpcs://localhost:${P0PORT}", - "tlsCACerts": { - "pem": "${PEERPEM}" - }, - "grpcOptions": { - "ssl-target-name-override": "peer0.org${ORG}.example.com", - "hostnameOverride": "peer0.org${ORG}.example.com" - } - } - }, - "certificateAuthorities": { - "ca.org${ORG}.example.com": { - "url": "https://localhost:${CAPORT}", - "caName": "ca-org${ORG}", - "tlsCACerts": { - "pem": ["${CAPEM}"] - }, - "httpOptions": { - "verify": false - } + "name": "matiru-network-org${ORG}", + "version": "1.0.0", + "client": { + "organization": "Org${ORG}", + "connection": { + "timeout": { + "peer": { + "endorser": "300" } + } + } + }, + "organizations": { + "Org${ORG}": { + "mspid": "Org${ORG}MSP", + "peers": ["peer0.org${ORG}.example.com"], + "certificateAuthorities": ["ca.org${ORG}.example.com"] + } + }, + "peers": { + "peer0.org${ORG}.example.com": { + "url": "grpcs://localhost:${P0PORT}", + "tlsCACerts": { + "pem": "${PEERPEM}" + }, + "grpcOptions": { + "ssl-target-name-override": "peer0.org${ORG}.example.com", + "hostnameOverride": "peer0.org${ORG}.example.com" + } + } + }, + "certificateAuthorities": { + "ca.org${ORG}.example.com": { + "url": "https://localhost:${CAPORT}", + "caName": "ca-org${ORG}", + "tlsCACerts": { + "pem": ["${CAPEM}"] + }, + "httpOptions": { + "verify": false + } } + } } diff --git a/fabric/network/organizations/ccp-template.yaml b/fabric/network/organizations/ccp-template.yaml @@ -1,25 +1,25 @@ --- -name: test-network-org${ORG} +name: matiru-network-org${ORG} version: 1.0.0 client: organization: Org${ORG} connection: timeout: peer: - endorser: '300' + endorser: "300" organizations: Org${ORG}: mspid: Org${ORG}MSP peers: - - peer0.org${ORG}.example.com + - peer0.org${ORG}.example.com certificateAuthorities: - - ca.org${ORG}.example.com + - ca.org${ORG}.example.com peers: peer0.org${ORG}.example.com: url: grpcs://localhost:${P0PORT} tlsCACerts: pem: | - ${PEERPEM} + ${PEERPEM} grpcOptions: ssl-target-name-override: peer0.org${ORG}.example.com hostnameOverride: peer0.org${ORG}.example.com @@ -28,7 +28,7 @@ certificateAuthorities: url: https://localhost:${CAPORT} caName: ca-org${ORG} tlsCACerts: - pem: + pem: - | ${CAPEM} httpOptions: diff --git a/fabric/network/organizations/cryptogen/crypto-config-orderer.yaml b/fabric/network/organizations/cryptogen/crypto-config-orderer.yaml @@ -1,21 +1,7 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# --------------------------------------------------------------------------- -# "OrdererOrgs" - Definition of organizations managing orderer nodes -# --------------------------------------------------------------------------- OrdererOrgs: - # --------------------------------------------------------------------------- - # Orderer - # --------------------------------------------------------------------------- - Name: Orderer Domain: example.com EnableNodeOUs: true - # --------------------------------------------------------------------------- - # "Specs" - See PeerOrgs for complete description - # --------------------------------------------------------------------------- Specs: - Hostname: orderer SANS: diff --git a/fabric/network/organizations/cryptogen/crypto-config-org1.yaml b/fabric/network/organizations/cryptogen/crypto-config-org1.yaml @@ -1,61 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - - -# --------------------------------------------------------------------------- -# "PeerOrgs" - Definition of organizations managing peer nodes -# --------------------------------------------------------------------------- -PeerOrgs: - # --------------------------------------------------------------------------- - # Org1 - # --------------------------------------------------------------------------- - - Name: Org1 - Domain: org1.example.com - EnableNodeOUs: true - # --------------------------------------------------------------------------- - # "Specs" - # --------------------------------------------------------------------------- - # Uncomment this section to enable the explicit definition of hosts in your - # configuration. Most users will want to use Template, below - # - # Specs is an array of Spec entries. Each Spec entry consists of two fields: - # - Hostname: (Required) The desired hostname, sans the domain. - # - CommonName: (Optional) Specifies the template or explicit override for - # the CN. By default, this is the template: - # - # "{{.Hostname}}.{{.Domain}}" - # - # which obtains its values from the Spec.Hostname and - # Org.Domain, respectively. - # --------------------------------------------------------------------------- - # - Hostname: foo # implicitly "foo.org1.example.com" - # CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above - # - Hostname: bar - # - Hostname: baz - # --------------------------------------------------------------------------- - # "Template" - # --------------------------------------------------------------------------- - # Allows for the definition of 1 or more hosts that are created sequentially - # from a template. By default, this looks like "peer%d" from 0 to Count-1. - # You may override the number of nodes (Count), the starting index (Start) - # or the template used to construct the name (Hostname). - # - # Note: Template and Specs are not mutually exclusive. You may define both - # sections and the aggregate nodes will be created for you. Take care with - # name collisions - # --------------------------------------------------------------------------- - Template: - Count: 1 - SANS: - - localhost - # Start: 5 - # Hostname: {{.Prefix}}{{.Index}} # default - # --------------------------------------------------------------------------- - # "Users" - # --------------------------------------------------------------------------- - # Count: The number of user accounts _in addition_ to Admin - # --------------------------------------------------------------------------- - Users: - Count: 1 diff --git a/fabric/network/organizations/cryptogen/crypto-config-org2.yaml b/fabric/network/organizations/cryptogen/crypto-config-org2.yaml @@ -1,61 +0,0 @@ -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# --------------------------------------------------------------------------- -# "PeerOrgs" - Definition of organizations managing peer nodes -# --------------------------------------------------------------------------- -PeerOrgs: - # --------------------------------------------------------------------------- - # Org2 - # --------------------------------------------------------------------------- - - Name: Org2 - Domain: org2.example.com - EnableNodeOUs: true - # --------------------------------------------------------------------------- - # "Specs" - # --------------------------------------------------------------------------- - # Uncomment this section to enable the explicit definition of hosts in your - # configuration. Most users will want to use Template, below - # - # Specs is an array of Spec entries. Each Spec entry consists of two fields: - # - Hostname: (Required) The desired hostname, sans the domain. - # - CommonName: (Optional) Specifies the template or explicit override for - # the CN. By default, this is the template: - # - # "{{.Hostname}}.{{.Domain}}" - # - # which obtains its values from the Spec.Hostname and - # Org.Domain, respectively. - # --------------------------------------------------------------------------- - # Specs: - # - Hostname: foo # implicitly "foo.org1.example.com" - # CommonName: foo27.org5.example.com # overrides Hostname-based FQDN set above - # - Hostname: bar - # - Hostname: baz - # --------------------------------------------------------------------------- - # "Template" - # --------------------------------------------------------------------------- - # Allows for the definition of 1 or more hosts that are created sequentially - # from a template. By default, this looks like "peer%d" from 0 to Count-1. - # You may override the number of nodes (Count), the starting index (Start) - # or the template used to construct the name (Hostname). - # - # Note: Template and Specs are not mutually exclusive. You may define both - # sections and the aggregate nodes will be created for you. Take care with - # name collisions - # --------------------------------------------------------------------------- - Template: - Count: 1 - SANS: - - localhost - # Start: 5 - # Hostname: {{.Prefix}}{{.Index}} # default - # --------------------------------------------------------------------------- - # "Users" - # --------------------------------------------------------------------------- - # Count: The number of user accounts _in addition_ to Admin - # --------------------------------------------------------------------------- - Users: - Count: 1 diff --git a/fabric/network/organizations/cryptogen/crypto-config-orgs.yaml b/fabric/network/organizations/cryptogen/crypto-config-orgs.yaml @@ -0,0 +1,37 @@ +PeerOrgs: + - Name: Org1 + Domain: org1.example.com + EnableNodeOUs: true + Template: + Count: 1 + SANS: + - localhost + Users: + Count: 1 + - Name: Org2 + Domain: org2.example.com + EnableNodeOUs: true + Template: + Count: 1 + SANS: + - localhost + Users: + Count: 1 + - Name: Org3 + Domain: org3.example.com + EnableNodeOUs: true + Template: + Count: 1 + SANS: + - localhost + Users: + Count: 1 + - Name: Org4 + Domain: org4.example.com + EnableNodeOUs: true + Template: + Count: 1 + SANS: + - localhost + Users: + Count: 1 diff --git a/fabric/network/organizations/fabric-ca/registerEnroll.sh b/fabric/network/organizations/fabric-ca/registerEnroll.sh @@ -3,7 +3,6 @@ function createOrg1() { infoln "Enrolling the CA admin" mkdir -p organizations/peerOrganizations/org1.example.com/ - export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/ set -x @@ -30,16 +29,11 @@ function createOrg1() { fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" { set +x; } 2>/dev/null - infoln "Registering user" - set -x - fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" - { set +x; } 2>/dev/null - infoln "Registering the org admin" set -x fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" { set +x; } 2>/dev/null - + infoln "Generating the peer0 msp" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp" --csr.hosts peer0.org1.example.com --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" @@ -64,14 +58,7 @@ function createOrg1() { mkdir -p "${PWD}/organizations/peerOrganizations/org1.example.com/ca" cp "${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/"* "${PWD}/organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem" - - infoln "Generating the user msp" - set -x - fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M "${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" - { set +x; } 2>/dev/null - - cp "${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/config.yaml" - + infoln "Generating the org admin msp" set -x fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M "${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org1/tls-cert.pem" @@ -83,7 +70,6 @@ function createOrg1() { function createOrg2() { infoln "Enrolling the CA admin" mkdir -p organizations/peerOrganizations/org2.example.com/ - export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/ set -x @@ -110,11 +96,6 @@ function createOrg2() { fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" { set +x; } 2>/dev/null - infoln "Registering user" - set -x - fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" - { set +x; } 2>/dev/null - infoln "Registering the org admin" set -x fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" @@ -145,25 +126,151 @@ function createOrg2() { mkdir -p "${PWD}/organizations/peerOrganizations/org2.example.com/ca" cp "${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/"* "${PWD}/organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem" - infoln "Generating the user msp" + infoln "Generating the org admin msp" + set -x + fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M "${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" + { set +x; } 2>/dev/null + + cp "${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml" +} + +function createOrg3() { + infoln "Enrolling the CA admin" + mkdir -p organizations/peerOrganizations/org3.example.com/ + export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org3.example.com/ + + set -x + fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" + { set +x; } 2>/dev/null + + echo 'NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/localhost-11054-ca-org3.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/localhost-11054-ca-org3.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/localhost-11054-ca-org3.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/localhost-11054-ca-org3.pem + OrganizationalUnitIdentifier: orderer' > "${PWD}/organizations/peerOrganizations/org3.example.com/msp/config.yaml" + + infoln "Registering peer0" + set -x + fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" + { set +x; } 2>/dev/null + + infoln "Registering the org admin" + set -x + fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" + { set +x; } 2>/dev/null + + infoln "Generating the peer0 msp" + set -x + fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp" --csr.hosts peer0.org3.example.com --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" + { set +x; } 2>/dev/null + + cp "${PWD}/organizations/peerOrganizations/org3.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml" + + infoln "Generating the peer0-tls certificates" set -x - fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M "${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" + fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls" --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" { set +x; } 2>/dev/null - cp "${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp/config.yaml" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/signcerts/"* "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.crt" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/keystore/"* "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/server.key" + + mkdir -p "${PWD}/organizations/peerOrganizations/org3.example.com/msp/tlscacerts" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org3.example.com/msp/tlscacerts/ca.crt" + + mkdir -p "${PWD}/organizations/peerOrganizations/org3.example.com/tlsca" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org3.example.com/tlsca/tlsca.org3.example.com-cert.pem" + + mkdir -p "${PWD}/organizations/peerOrganizations/org3.example.com/ca" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/cacerts/"* "${PWD}/organizations/peerOrganizations/org3.example.com/ca/ca.org3.example.com-cert.pem" infoln "Generating the org admin msp" set -x - fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M "${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org2/tls-cert.pem" + fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M "${PWD}/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org3/tls-cert.pem" { set +x; } 2>/dev/null - cp "${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml" + cp "${PWD}/organizations/peerOrganizations/org3.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml" +} + +function createOrg4() { + infoln "Enrolling the CA admin" + mkdir -p organizations/peerOrganizations/org4.example.com/ + export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org4.example.com/ + + set -x + fabric-ca-client enroll -u https://admin:adminpw@localhost:13054 --caname ca-org4 --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + echo 'NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/localhost-13054-ca-org4.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/localhost-13054-ca-org4.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/localhost-13054-ca-org4.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/localhost-13054-ca-org4.pem + OrganizationalUnitIdentifier: orderer' > "${PWD}/organizations/peerOrganizations/org4.example.com/msp/config.yaml" + + infoln "Registering peer0" + set -x + fabric-ca-client register --caname ca-org4 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + infoln "Registering the org admin" + set -x + fabric-ca-client register --caname ca-org4 --id.name org4admin --id.secret org4adminpw --id.type admin --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + infoln "Generating the peer0 msp" + set -x + fabric-ca-client enroll -u https://peer0:peer0pw@localhost:13054 --caname ca-org4 -M "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp" --csr.hosts peer0.org4.example.com --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + cp "${PWD}/organizations/peerOrganizations/org4.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/config.yaml" + + infoln "Generating the peer0-tls certificates" + set -x + fabric-ca-client enroll -u https://peer0:peer0pw@localhost:13054 --caname ca-org4 -M "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls" --enrollment.profile tls --csr.hosts peer0.org4.example.com --csr.hosts localhost --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/ca.crt" + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/signcerts/"* "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/server.crt" + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/keystore/"* "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/server.key" + + mkdir -p "${PWD}/organizations/peerOrganizations/org4.example.com/msp/tlscacerts" + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org4.example.com/msp/tlscacerts/ca.crt" + + mkdir -p "${PWD}/organizations/peerOrganizations/org4.example.com/tlsca" + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/tlscacerts/"* "${PWD}/organizations/peerOrganizations/org4.example.com/tlsca/tlsca.org4.example.com-cert.pem" + + mkdir -p "${PWD}/organizations/peerOrganizations/org4.example.com/ca" + cp "${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/msp/cacerts/"* "${PWD}/organizations/peerOrganizations/org4.example.com/ca/ca.org4.example.com-cert.pem" + + infoln "Generating the org admin msp" + set -x + fabric-ca-client enroll -u https://org4admin:org4adminpw@localhost:13054 --caname ca-org4 -M "${PWD}/organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp" --tls.certfiles "${PWD}/organizations/fabric-ca/org4/tls-cert.pem" + { set +x; } 2>/dev/null + + cp "${PWD}/organizations/peerOrganizations/org4.example.com/msp/config.yaml" "${PWD}/organizations/peerOrganizations/org4.example.com/users/Admin@org4.example.com/msp/config.yaml" } function createOrderer() { infoln "Enrolling the CA admin" mkdir -p organizations/ordererOrganizations/example.com - export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com set -x @@ -201,7 +308,7 @@ function createOrderer() { { set +x; } 2>/dev/null cp "${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml" "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml" - + infoln "Generating the orderer-tls certificates" set -x fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls" --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles "${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem" diff --git a/fabric/network/scripts/configUpdate.sh b/fabric/network/scripts/configUpdate.sh @@ -1,16 +1,8 @@ #!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -# import utils . scripts/envVar.sh -# fetchChannelConfig <org> <channel_id> <output_json> # Writes the current channel config for a given channel to a JSON file -# NOTE: this must be run in a CLI container since it requires configtxlator fetchChannelConfig() { ORG=$1 CHANNEL=$2 @@ -29,10 +21,7 @@ fetchChannelConfig() { { set +x; } 2>/dev/null } -# createConfigUpdate <channel_id> <original_config.json> <modified_config.json> <output.pb> -# Takes an original and modified config, and produces the config update tx -# which transitions between the two -# NOTE: this must be run in a CLI container since it requires configtxlator +# Takes an original and modified config, and produces the config update tx which transitions between the two createConfigUpdate() { CHANNEL=$1 ORIGINAL=$2 @@ -49,7 +38,6 @@ createConfigUpdate() { { set +x; } 2>/dev/null } -# signConfigtxAsPeerOrg <org> <configtx.pb> # Set the peerOrg admin of an org and sign the config update signConfigtxAsPeerOrg() { ORG=$1 diff --git a/fabric/network/scripts/createChannel.sh b/fabric/network/scripts/createChannel.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -# imports . scripts/envVar.sh . scripts/utils.sh @@ -23,7 +22,7 @@ createChannelGenesisBlock() { fatalln "configtxgen tool not found." fi set -x - configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/${CHANNEL_NAME}.block -channelID $CHANNEL_NAME + configtxgen -profile FourOrgsApplicationGenesis -outputBlock ./channel-artifacts/${CHANNEL_NAME}.block -channelID $CHANNEL_NAME res=$? { set +x; } 2>/dev/null verifyResult $res "Failed to generate channel configuration transaction..." @@ -31,7 +30,6 @@ createChannelGenesisBlock() { createChannel() { setGlobals 1 - # Poll in case the raft leader is not set yet local rc=1 local COUNTER=1 while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do @@ -47,14 +45,12 @@ createChannel() { verifyResult $res "Channel creation failed" } -# joinChannel ORG joinChannel() { FABRIC_CFG_PATH=$PWD/../config/ ORG=$1 setGlobals $ORG local rc=1 local COUNTER=1 - ## Sometimes Join takes time, hence retry while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do sleep $DELAY set -x @@ -75,28 +71,32 @@ setAnchorPeer() { FABRIC_CFG_PATH=${PWD}/configtx -## Create channel genesis block infoln "Generating channel genesis block '${CHANNEL_NAME}.block'" createChannelGenesisBlock FABRIC_CFG_PATH=$PWD/../config/ BLOCKFILE="./channel-artifacts/${CHANNEL_NAME}.block" -## Create channel infoln "Creating channel ${CHANNEL_NAME}" createChannel successln "Channel '$CHANNEL_NAME' created" -## Join all the peers to the channel infoln "Joining org1 peer to the channel..." joinChannel 1 infoln "Joining org2 peer to the channel..." joinChannel 2 +infoln "Joining org3 peer to the channel..." +joinChannel 3 +infoln "Joining org4 peer to the channel..." +joinChannel 4 -## Set the anchor peers for each org in the channel infoln "Setting anchor peer for org1..." setAnchorPeer 1 infoln "Setting anchor peer for org2..." setAnchorPeer 2 +infoln "Setting anchor peer for org3..." +setAnchorPeer 3 +infoln "Setting anchor peer for org4..." +setAnchorPeer 4 successln "Channel '$CHANNEL_NAME' joined" diff --git a/fabric/network/scripts/deployCC.sh b/fabric/network/scripts/deployCC.sh @@ -31,65 +31,48 @@ println "- VERBOSE: ${C_GREEN}${VERBOSE}${C_RESET}" FABRIC_CFG_PATH=$PWD/../config/ -#User has not provided a name if [ -z "$CC_NAME" ] || [ "$CC_NAME" = "NA" ]; then - fatalln "No chaincode name was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -# User has not provided a path + fatalln "No chaincode name was provided." elif [ -z "$CC_SRC_PATH" ] || [ "$CC_SRC_PATH" = "NA" ]; then - fatalln "No chaincode path was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -# User has not provided a language + fatalln "No chaincode path was provided." elif [ -z "$CC_SRC_LANGUAGE" ] || [ "$CC_SRC_LANGUAGE" = "NA" ]; then - fatalln "No chaincode language was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -## Make sure that the path to the chaincode exists + fatalln "No chaincode language was provided." elif [ ! -d "$CC_SRC_PATH" ]; then - fatalln "Path to chaincode does not exist. Please provide different path." + fatalln "Path to chaincode does not exist." fi CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]) -# do some language specific preparation to the chaincode before packaging if [ "$CC_SRC_LANGUAGE" = "go" ]; then CC_RUNTIME_LANGUAGE=golang - infoln "Vendoring Go dependencies at $CC_SRC_PATH" pushd $CC_SRC_PATH GO111MODULE=on go mod vendor popd successln "Finished vendoring Go dependencies" - elif [ "$CC_SRC_LANGUAGE" = "java" ]; then CC_RUNTIME_LANGUAGE=java - infoln "Compiling Java code..." pushd $CC_SRC_PATH ./gradlew installDist popd successln "Finished compiling Java code" CC_SRC_PATH=$CC_SRC_PATH/build/install/$CC_NAME - elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then CC_RUNTIME_LANGUAGE=node - elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then CC_RUNTIME_LANGUAGE=node - infoln "Compiling TypeScript code into JavaScript..." pushd $CC_SRC_PATH npm install npm run build popd successln "Finished compiling TypeScript code into JavaScript" - else - fatalln "The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script. Supported chaincode languages are: go, java, javascript, and typescript" - exit 1 + fatalln "The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script." fi INIT_REQUIRED="--init-required" -# check if the init fcn should be called if [ "$CC_INIT_FCN" = "NA" ]; then INIT_REQUIRED="" fi @@ -106,7 +89,6 @@ else CC_COLL_CONFIG="--collections-config $CC_COLL_CONFIG" fi -# import utils . scripts/envVar.sh packageChaincode() { @@ -119,7 +101,6 @@ packageChaincode() { successln "Chaincode is packaged" } -# installChaincode PEER ORG installChaincode() { ORG=$1 setGlobals $ORG @@ -132,7 +113,6 @@ installChaincode() { successln "Chaincode is installed on peer0.org${ORG}" } -# queryInstalled PEER ORG queryInstalled() { ORG=$1 setGlobals $ORG @@ -146,7 +126,6 @@ queryInstalled() { successln "Query installed successful on peer0.org${ORG} on channel" } -# approveForMyOrg VERSION PEER ORG approveForMyOrg() { ORG=$1 setGlobals $ORG @@ -159,7 +138,6 @@ approveForMyOrg() { successln "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME'" } -# checkCommitReadiness VERSION PEER ORG checkCommitReadiness() { ORG=$1 shift 1 @@ -167,8 +145,6 @@ checkCommitReadiness() { infoln "Checking the commit readiness of the chaincode definition on peer0.org${ORG} on channel '$CHANNEL_NAME'..." local rc=1 local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do sleep $DELAY infoln "Attempting to check the commit readiness of the chaincode definition on peer0.org${ORG}, Retry after $DELAY seconds." @@ -190,15 +166,10 @@ checkCommitReadiness() { fi } -# commitChaincodeDefinition VERSION PEER ORG (PEER ORG)... commitChaincodeDefinition() { parsePeerConnectionParameters $@ res=$? verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters " - - # while 'peer chaincode' command can get the orderer endpoint from the - # peer (if join was successful), let's supply it directly as we know - # it using the "-o" option set -x peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" --channelID $CHANNEL_NAME --name ${CC_NAME} "${PEER_CONN_PARMS[@]}" --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt res=$? @@ -208,7 +179,6 @@ commitChaincodeDefinition() { successln "Chaincode definition committed on channel '$CHANNEL_NAME'" } -# queryCommitted ORG queryCommitted() { ORG=$1 setGlobals $ORG @@ -216,8 +186,6 @@ queryCommitted() { infoln "Querying chaincode definition on peer0.org${ORG} on channel '$CHANNEL_NAME'..." local rc=1 local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do sleep $DELAY infoln "Attempting to Query committed status on peer0.org${ORG}, Retry after $DELAY seconds." @@ -241,10 +209,6 @@ chaincodeInvokeInit() { parsePeerConnectionParameters $@ res=$? verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters " - - # while 'peer chaincode' command can get the orderer endpoint from the - # peer (if join was successful), let's supply it directly as we know - # it using the "-o" option set -x fcn_call='{"function":"'${CC_INIT_FCN}'","Args":[]}' infoln "invoke fcn call:${fcn_call}" @@ -256,96 +220,36 @@ chaincodeInvokeInit() { successln "Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME'" } -chaincodeQuery() { - ORG=$1 - setGlobals $ORG - infoln "Querying on peer0.org${ORG} on channel '$CHANNEL_NAME'..." - local rc=1 - local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do - sleep $DELAY - infoln "Attempting to Query peer0.org${ORG}, Retry after $DELAY seconds." - set -x - peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllCars"]}' >&log.txt - res=$? - { set +x; } 2>/dev/null - let rc=$res - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - if test $rc -eq 0; then - successln "Query successful on peer0.org${ORG} on channel '$CHANNEL_NAME'" - else - fatalln "After $MAX_RETRY attempts, Query result on peer0.org${ORG} is INVALID!" - fi -} - -## package the chaincode packageChaincode -## Install chaincode on peer0.org1 and peer0.org2 infoln "Installing chaincode on peer0.org1..." installChaincode 1 infoln "Installing chaincode on peer0.org2..." installChaincode 2 infoln "Installing chaincode on peer0.org3..." installChaincode 3 -infoln "Installing chaincode on peer0.org2..." +infoln "Installing chaincode on peer0.org4..." installChaincode 4 -## query whether the chaincode is installed queryInstalled 1 - -## approve the definition for org1 approveForMyOrg 1 - -## check whether the chaincode definition is ready to be committed -## expect org1 to have approved and org2 not to checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": false" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": false" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org2MSP\": false" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 4 "\"Org1MSP\": true" "\"Org2MSP\": false" "\"Org3MSP\": false" "\"Org4MSP\": false" -## now approve also for org2 approveForMyOrg 2 - -## check whether the chaincode definition is ready to be committed -## expect them both to have approved checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": false" "\"Org4MSP\": false" -checkCommitReadiness 4 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": false" "\"Org4MSP\": false" approveForMyOrg 3 - -## check whether the chaincode definition is ready to be committed -## expect them both to have approved checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": false" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": false" -checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": false" -checkCommitReadiness 4 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": false" approveForMyOrg 4 - -## check whether the chaincode definition is ready to be committed -## expect them both to have approved checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": true" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": true" -checkCommitReadiness 3 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": true" -checkCommitReadiness 4 "\"Org1MSP\": true" "\"Org2MSP\": true" "\"Org3MSP\": true" "\"Org4MSP\": true" -## now that we know for sure all orgs have approved, commit the definition -commitChaincodeDefinition 1 2 3 4 -## query on both orgs to see that the definition committed successfully +commitChaincodeDefinition 1 2 3 4 queryCommitted 1 queryCommitted 2 queryCommitted 3 queryCommitted 4 -## Invoke the chaincode - this does require that the chaincode have the 'initLedger' -## method defined if [ "$CC_INIT_FCN" = "NA" ]; then infoln "Chaincode initialization is not required" else diff --git a/fabric/network/scripts/deployCC_2org.sh b/fabric/network/scripts/deployCC_2org.sh @@ -1,328 +0,0 @@ -#!/usr/bin/env bash - -source scripts/utils.sh - -CHANNEL_NAME=${1:-"mychannel"} -CC_NAME=${2} -CC_SRC_PATH=${3} -CC_SRC_LANGUAGE=${4} -CC_VERSION=${5:-"1.0"} -CC_SEQUENCE=${6:-"1"} -CC_INIT_FCN=${7:-"NA"} -CC_END_POLICY=${8:-"NA"} -CC_COLL_CONFIG=${9:-"NA"} -DELAY=${10:-"3"} -MAX_RETRY=${11:-"5"} -VERBOSE=${12:-"false"} - -println "executing with the following" -println "- CHANNEL_NAME: ${C_GREEN}${CHANNEL_NAME}${C_RESET}" -println "- CC_NAME: ${C_GREEN}${CC_NAME}${C_RESET}" -println "- CC_SRC_PATH: ${C_GREEN}${CC_SRC_PATH}${C_RESET}" -println "- CC_SRC_LANGUAGE: ${C_GREEN}${CC_SRC_LANGUAGE}${C_RESET}" -println "- CC_VERSION: ${C_GREEN}${CC_VERSION}${C_RESET}" -println "- CC_SEQUENCE: ${C_GREEN}${CC_SEQUENCE}${C_RESET}" -println "- CC_END_POLICY: ${C_GREEN}${CC_END_POLICY}${C_RESET}" -println "- CC_COLL_CONFIG: ${C_GREEN}${CC_COLL_CONFIG}${C_RESET}" -println "- CC_INIT_FCN: ${C_GREEN}${CC_INIT_FCN}${C_RESET}" -println "- DELAY: ${C_GREEN}${DELAY}${C_RESET}" -println "- MAX_RETRY: ${C_GREEN}${MAX_RETRY}${C_RESET}" -println "- VERBOSE: ${C_GREEN}${VERBOSE}${C_RESET}" - -FABRIC_CFG_PATH=$PWD/../config/ - -#User has not provided a name -if [ -z "$CC_NAME" ] || [ "$CC_NAME" = "NA" ]; then - fatalln "No chaincode name was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -# User has not provided a path -elif [ -z "$CC_SRC_PATH" ] || [ "$CC_SRC_PATH" = "NA" ]; then - fatalln "No chaincode path was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -# User has not provided a language -elif [ -z "$CC_SRC_LANGUAGE" ] || [ "$CC_SRC_LANGUAGE" = "NA" ]; then - fatalln "No chaincode language was provided. Valid call example: ./network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go" - -## Make sure that the path to the chaincode exists -elif [ ! -d "$CC_SRC_PATH" ]; then - fatalln "Path to chaincode does not exist. Please provide different path." -fi - -CC_SRC_LANGUAGE=$(echo "$CC_SRC_LANGUAGE" | tr [:upper:] [:lower:]) - -# do some language specific preparation to the chaincode before packaging -if [ "$CC_SRC_LANGUAGE" = "go" ]; then - CC_RUNTIME_LANGUAGE=golang - - infoln "Vendoring Go dependencies at $CC_SRC_PATH" - pushd $CC_SRC_PATH - GO111MODULE=on go mod vendor - popd - successln "Finished vendoring Go dependencies" - -elif [ "$CC_SRC_LANGUAGE" = "java" ]; then - CC_RUNTIME_LANGUAGE=java - - infoln "Compiling Java code..." - pushd $CC_SRC_PATH - ./gradlew installDist - popd - successln "Finished compiling Java code" - CC_SRC_PATH=$CC_SRC_PATH/build/install/$CC_NAME - -elif [ "$CC_SRC_LANGUAGE" = "javascript" ]; then - CC_RUNTIME_LANGUAGE=node - -elif [ "$CC_SRC_LANGUAGE" = "typescript" ]; then - CC_RUNTIME_LANGUAGE=node - - infoln "Compiling TypeScript code into JavaScript..." - pushd $CC_SRC_PATH - npm install - npm run build - popd - successln "Finished compiling TypeScript code into JavaScript" - -else - fatalln "The chaincode language ${CC_SRC_LANGUAGE} is not supported by this script. Supported chaincode languages are: go, java, javascript, and typescript" - exit 1 -fi - -INIT_REQUIRED="--init-required" -# check if the init fcn should be called -if [ "$CC_INIT_FCN" = "NA" ]; then - INIT_REQUIRED="" -fi - -if [ "$CC_END_POLICY" = "NA" ]; then - CC_END_POLICY="" -else - CC_END_POLICY="--signature-policy $CC_END_POLICY" -fi - -if [ "$CC_COLL_CONFIG" = "NA" ]; then - CC_COLL_CONFIG="" -else - CC_COLL_CONFIG="--collections-config $CC_COLL_CONFIG" -fi - -# import utils -. scripts/envVar.sh - -packageChaincode() { - set -x - peer lifecycle chaincode package ${CC_NAME}.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label ${CC_NAME}_${CC_VERSION} >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - verifyResult $res "Chaincode packaging has failed" - successln "Chaincode is packaged" -} - -# installChaincode PEER ORG -installChaincode() { - ORG=$1 - setGlobals $ORG - set -x - peer lifecycle chaincode install ${CC_NAME}.tar.gz >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - verifyResult $res "Chaincode installation on peer0.org${ORG} has failed" - successln "Chaincode is installed on peer0.org${ORG}" -} - -# queryInstalled PEER ORG -queryInstalled() { - ORG=$1 - setGlobals $ORG - set -x - peer lifecycle chaincode queryinstalled >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - PACKAGE_ID=$(sed -n "/${CC_NAME}_${CC_VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt) - verifyResult $res "Query installed on peer0.org${ORG} has failed" - successln "Query installed successful on peer0.org${ORG} on channel" -} - -# approveForMyOrg VERSION PEER ORG -approveForMyOrg() { - ORG=$1 - setGlobals $ORG - set -x - peer lifecycle chaincode approveformyorg -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --package-id ${PACKAGE_ID} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - verifyResult $res "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME' failed" - successln "Chaincode definition approved on peer0.org${ORG} on channel '$CHANNEL_NAME'" -} - -# checkCommitReadiness VERSION PEER ORG -checkCommitReadiness() { - ORG=$1 - shift 1 - setGlobals $ORG - infoln "Checking the commit readiness of the chaincode definition on peer0.org${ORG} on channel '$CHANNEL_NAME'..." - local rc=1 - local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do - sleep $DELAY - infoln "Attempting to check the commit readiness of the chaincode definition on peer0.org${ORG}, Retry after $DELAY seconds." - set -x - peer lifecycle chaincode checkcommitreadiness --channelID $CHANNEL_NAME --name ${CC_NAME} --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} --output json >&log.txt - res=$? - { set +x; } 2>/dev/null - let rc=0 - for var in "$@"; do - grep "$var" log.txt &>/dev/null || let rc=1 - done - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - if test $rc -eq 0; then - infoln "Checking the commit readiness of the chaincode definition successful on peer0.org${ORG} on channel '$CHANNEL_NAME'" - else - fatalln "After $MAX_RETRY attempts, Check commit readiness result on peer0.org${ORG} is INVALID!" - fi -} - -# commitChaincodeDefinition VERSION PEER ORG (PEER ORG)... -commitChaincodeDefinition() { - parsePeerConnectionParameters $@ - res=$? - verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters " - - # while 'peer chaincode' command can get the orderer endpoint from the - # peer (if join was successful), let's supply it directly as we know - # it using the "-o" option - set -x - peer lifecycle chaincode commit -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" --channelID $CHANNEL_NAME --name ${CC_NAME} "${PEER_CONN_PARMS[@]}" --version ${CC_VERSION} --sequence ${CC_SEQUENCE} ${INIT_REQUIRED} ${CC_END_POLICY} ${CC_COLL_CONFIG} >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - verifyResult $res "Chaincode definition commit failed on peer0.org${ORG} on channel '$CHANNEL_NAME' failed" - successln "Chaincode definition committed on channel '$CHANNEL_NAME'" -} - -# queryCommitted ORG -queryCommitted() { - ORG=$1 - setGlobals $ORG - EXPECTED_RESULT="Version: ${CC_VERSION}, Sequence: ${CC_SEQUENCE}, Endorsement Plugin: escc, Validation Plugin: vscc" - infoln "Querying chaincode definition on peer0.org${ORG} on channel '$CHANNEL_NAME'..." - local rc=1 - local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do - sleep $DELAY - infoln "Attempting to Query committed status on peer0.org${ORG}, Retry after $DELAY seconds." - set -x - peer lifecycle chaincode querycommitted --channelID $CHANNEL_NAME --name ${CC_NAME} >&log.txt - res=$? - { set +x; } 2>/dev/null - test $res -eq 0 && VALUE=$(cat log.txt | grep -o '^Version: '$CC_VERSION', Sequence: [0-9]*, Endorsement Plugin: escc, Validation Plugin: vscc') - test "$VALUE" = "$EXPECTED_RESULT" && let rc=0 - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - if test $rc -eq 0; then - successln "Query chaincode definition successful on peer0.org${ORG} on channel '$CHANNEL_NAME'" - else - fatalln "After $MAX_RETRY attempts, Query chaincode definition result on peer0.org${ORG} is INVALID!" - fi -} - -chaincodeInvokeInit() { - parsePeerConnectionParameters $@ - res=$? - verifyResult $res "Invoke transaction failed on channel '$CHANNEL_NAME' due to uneven number of peer and org parameters " - - # while 'peer chaincode' command can get the orderer endpoint from the - # peer (if join was successful), let's supply it directly as we know - # it using the "-o" option - set -x - fcn_call='{"function":"'${CC_INIT_FCN}'","Args":[]}' - infoln "invoke fcn call:${fcn_call}" - peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" -C $CHANNEL_NAME -n ${CC_NAME} "${PEER_CONN_PARMS[@]}" --isInit -c ${fcn_call} >&log.txt - res=$? - { set +x; } 2>/dev/null - cat log.txt - verifyResult $res "Invoke execution on $PEERS failed " - successln "Invoke transaction successful on $PEERS on channel '$CHANNEL_NAME'" -} - -chaincodeQuery() { - ORG=$1 - setGlobals $ORG - infoln "Querying on peer0.org${ORG} on channel '$CHANNEL_NAME'..." - local rc=1 - local COUNTER=1 - # continue to poll - # we either get a successful response, or reach MAX RETRY - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ]; do - sleep $DELAY - infoln "Attempting to Query peer0.org${ORG}, Retry after $DELAY seconds." - set -x - peer chaincode query -C $CHANNEL_NAME -n ${CC_NAME} -c '{"Args":["queryAllCars"]}' >&log.txt - res=$? - { set +x; } 2>/dev/null - let rc=$res - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - if test $rc -eq 0; then - successln "Query successful on peer0.org${ORG} on channel '$CHANNEL_NAME'" - else - fatalln "After $MAX_RETRY attempts, Query result on peer0.org${ORG} is INVALID!" - fi -} - -## package the chaincode -packageChaincode - -## Install chaincode on peer0.org1 and peer0.org2 -infoln "Installing chaincode on peer0.org1..." -installChaincode 1 -infoln "Installing chaincode on peer0.org2..." -installChaincode 2 - -## query whether the chaincode is installed -queryInstalled 1 - -## approve the definition for org1 -approveForMyOrg 1 - -## check whether the chaincode definition is ready to be committed -## expect org1 to have approved and org2 not to -checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": false" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": false" - -## now approve also for org2 -approveForMyOrg 2 - -## check whether the chaincode definition is ready to be committed -## expect them both to have approved -checkCommitReadiness 1 "\"Org1MSP\": true" "\"Org2MSP\": true" -checkCommitReadiness 2 "\"Org1MSP\": true" "\"Org2MSP\": true" - -## now that we know for sure both orgs have approved, commit the definition -commitChaincodeDefinition 1 2 - -## query on both orgs to see that the definition committed successfully -queryCommitted 1 -queryCommitted 2 - -## Invoke the chaincode - this does require that the chaincode have the 'initLedger' -## method defined -if [ "$CC_INIT_FCN" = "NA" ]; then - infoln "Chaincode initialization is not required" -else - chaincodeInvokeInit 1 2 -fi - -exit 0 diff --git a/fabric/network/scripts/envVar.sh b/fabric/network/scripts/envVar.sh @@ -1,13 +1,5 @@ #!/usr/bin/env bash -# -# Copyright IBM Corp All Rights Reserved -# -# SPDX-License-Identifier: Apache-2.0 -# -# This is a collection of bash functions used by different scripts - -# imports . scripts/utils.sh export CORE_PEER_TLS_ENABLED=true @@ -16,11 +8,9 @@ export PEER0_ORG1_CA=${PWD}/organizations/peerOrganizations/org1.example.com/pee export PEER0_ORG2_CA=${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt export PEER0_ORG3_CA=${PWD}/organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt export PEER0_ORG4_CA=${PWD}/organizations/peerOrganizations/org4.example.com/peers/peer0.org4.example.com/tls/ca.crt - export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key -# Set environment variables for the peer org setGlobals() { local USING_ORG="" if [ -z "$OVERRIDE_ORG" ]; then @@ -39,7 +29,6 @@ setGlobals() { export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp export CORE_PEER_ADDRESS=localhost:9051 - elif [ $USING_ORG -eq 3 ]; then export CORE_PEER_LOCALMSPID="Org3MSP" export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG3_CA @@ -59,10 +48,8 @@ setGlobals() { fi } -# Set environment variables for use in the CLI container setGlobalsCLI() { setGlobals $1 - local USING_ORG="" if [ -z "$OVERRIDE_ORG" ]; then USING_ORG=$1 @@ -82,28 +69,21 @@ setGlobalsCLI() { fi } -# parsePeerConnectionParameters $@ -# Helper function that sets the peer connection parameters for a chaincode -# operation parsePeerConnectionParameters() { PEER_CONN_PARMS=() PEERS="" while [ "$#" -gt 0 ]; do setGlobals $1 PEER="peer0.org$1" - ## Set peer addresses - if [ -z "$PEERS" ] - then - PEERS="$PEER" + if [ -z "$PEERS" ]; then + PEERS="$PEER" else - PEERS="$PEERS $PEER" + PEERS="$PEERS $PEER" fi PEER_CONN_PARMS=("${PEER_CONN_PARMS[@]}" --peerAddresses $CORE_PEER_ADDRESS) - ## Set path to TLS certificate CA=PEER0_ORG$1_CA TLSINFO=(--tlsRootCertFiles "${!CA}") PEER_CONN_PARMS=("${PEER_CONN_PARMS[@]}" "${TLSINFO[@]}") - # shift by one to get to the next organization shift done } diff --git a/fabric/network/scripts/org3-scripts/joinChannel.sh b/fabric/network/scripts/org3-scripts/joinChannel.sh @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script is designed to be run in the cli container as the -# second step of the EYFN tutorial. It joins the org3 peers to the -# channel previously setup in the BYFN tutorial and install the -# chaincode as version 2.0 on peer0.org3. -# - -CHANNEL_NAME="$1" -DELAY="$2" -TIMEOUT="$3" -VERBOSE="$4" -: ${CHANNEL_NAME:="mychannel"} -: ${DELAY:="3"} -: ${TIMEOUT:="10"} -: ${VERBOSE:="false"} -COUNTER=1 -MAX_RETRY=5 - -# import environment variables -. scripts/envVar.sh - -# joinChannel ORG -joinChannel() { - ORG=$1 - local rc=1 - local COUNTER=1 - ## Sometimes Join takes time, hence retry - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do - sleep $DELAY - set -x - peer channel join -b $BLOCKFILE >&log.txt - res=$? - { set +x; } 2>/dev/null - let rc=$res - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' " -} - -setAnchorPeer() { - ORG=$1 - scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME -} - -setGlobalsCLI 3 -BLOCKFILE="${CHANNEL_NAME}.block" - -echo "Fetching channel config block from orderer..." -set -x -peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt -res=$? -{ set +x; } 2>/dev/null -cat log.txt -verifyResult $res "Fetching config block from orderer has failed" - -infoln "Joining org3 peer to the channel..." -joinChannel 3 - -infoln "Setting anchor peer for org3..." -setAnchorPeer 3 - -successln "Channel '$CHANNEL_NAME' joined" -successln "Org3 peer successfully added to network" diff --git a/fabric/network/scripts/org3-scripts/updateChannelConfig.sh b/fabric/network/scripts/org3-scripts/updateChannelConfig.sh @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script is designed to be run in the cli container as the -# first step of the EYFN tutorial. It creates and submits a -# configuration transaction to add org3 to the test network -# - -CHANNEL_NAME="$1" -DELAY="$2" -TIMEOUT="$3" -VERBOSE="$4" -: ${CHANNEL_NAME:="mychannel"} -: ${DELAY:="3"} -: ${TIMEOUT:="10"} -: ${VERBOSE:="false"} -COUNTER=1 -MAX_RETRY=5 - - -# imports -. scripts/envVar.sh -. scripts/configUpdate.sh -. scripts/utils.sh - -infoln "Creating config transaction to add org3 to network" - -# Fetch the config for the channel, writing it to config.json -fetchChannelConfig 1 ${CHANNEL_NAME} config.json - -# Modify the configuration to append the new org -set -x -jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[1]}}}}}' config.json ./organizations/peerOrganizations/org3.example.com/org3.json > modified_config.json -{ set +x; } 2>/dev/null - -# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb -createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb - -infoln "Signing config transaction" -signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb - -infoln "Submitting transaction from a different peer (peer0.org2) which also signs it" -setGlobals 2 -set -x -peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" -{ set +x; } 2>/dev/null - -successln "Config transaction to add org3 to network submitted" diff --git a/fabric/network/scripts/org4-scripts/joinChannel.sh b/fabric/network/scripts/org4-scripts/joinChannel.sh @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script is designed to be run in the cli container as the -# second step of the EYFN tutorial. It joins the org4 peers to the -# channel previously setup in the BYFN tutorial and install the -# chaincode as version 2.0 on peer0.org4. -# - -CHANNEL_NAME="$1" -DELAY="$2" -TIMEOUT="$3" -VERBOSE="$4" -: ${CHANNEL_NAME:="mychannel"} -: ${DELAY:="3"} -: ${TIMEOUT:="10"} -: ${VERBOSE:="false"} -COUNTER=1 -MAX_RETRY=5 - -# import environment variables -. scripts/envVar.sh - -# joinChannel ORG -joinChannel() { - ORG=$1 - local rc=1 - local COUNTER=1 - ## Sometimes Join takes time, hence retry - while [ $rc -ne 0 -a $COUNTER -lt $MAX_RETRY ] ; do - sleep $DELAY - set -x - peer channel join -b $BLOCKFILE >&log.txt - res=$? - { set +x; } 2>/dev/null - let rc=$res - COUNTER=$(expr $COUNTER + 1) - done - cat log.txt - verifyResult $res "After $MAX_RETRY attempts, peer0.org${ORG} has failed to join channel '$CHANNEL_NAME' " -} - -setAnchorPeer() { - ORG=$1 - scripts/setAnchorPeer.sh $ORG $CHANNEL_NAME -} - -setGlobalsCLI 4 -BLOCKFILE="${CHANNEL_NAME}.block" - -echo "Fetching channel config block from orderer..." -set -x -peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME --tls --cafile "$ORDERER_CA" >&log.txt -res=$? -{ set +x; } 2>/dev/null -cat log.txt -verifyResult $res "Fetching config block from orderer has failed" - -infoln "Joining org4 peer to the channel..." -joinChannel 4 - -infoln "Setting anchor peer for org4..." -setAnchorPeer 4 - -successln "Channel '$CHANNEL_NAME' joined" -successln "Org4 peer successfully added to network" diff --git a/fabric/network/scripts/org4-scripts/updateChannelConfig.sh b/fabric/network/scripts/org4-scripts/updateChannelConfig.sh @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# - -# This script is designed to be run in the cli container as the -# first step of the EYFN tutorial. It creates and submits a -# configuration transaction to add org4 to the test network -# - -CHANNEL_NAME="$1" -DELAY="$2" -TIMEOUT="$3" -VERBOSE="$4" -: ${CHANNEL_NAME:="mychannel"} -: ${DELAY:="3"} -: ${TIMEOUT:="10"} -: ${VERBOSE:="false"} -COUNTER=1 -MAX_RETRY=5 - - -# imports -. scripts/envVar.sh -. scripts/configUpdate.sh -. scripts/utils.sh - -infoln "Creating config transaction to add org4 to network" - -# Fetch the config for the channel, writing it to config.json -fetchChannelConfig 1 ${CHANNEL_NAME} config.json - -# Modify the configuration to append the new org -set -x -jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org4MSP":.[1]}}}}}' config.json ./organizations/peerOrganizations/org4.example.com/org4.json > modified_config.json -{ set +x; } 2>/dev/null - -# Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org4_update_in_envelope.pb -createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org4_update_in_envelope.pb - -infoln "Signing config transaction" -signConfigtxAsPeerOrg 1 org4_update_in_envelope.pb -signConfigtxAsPeerOrg 3 org4_update_in_envelope.pb - -infoln "Submitting transaction from a different peer (peer0.org2) which also signs it" -setGlobals 2 -set -x -peer channel update -f org4_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "$ORDERER_CA" -{ set +x; } 2>/dev/null - -successln "Config transaction to add org4 to network submitted" diff --git a/fabric/network/scripts/setAnchorPeer.sh b/fabric/network/scripts/setAnchorPeer.sh @@ -1,16 +1,8 @@ #!/usr/bin/env bash -# -# Copyright IBM Corp. All Rights Reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -# import utils . scripts/envVar.sh . scripts/configUpdate.sh - -# NOTE: this must be run in a CLI container since it requires jq and configtxlator createAnchorPeerUpdate() { infoln "Fetching channel config for channel $CHANNEL_NAME" fetchChannelConfig $ORG $CHANNEL_NAME ${CORE_PEER_LOCALMSPID}config.json @@ -34,13 +26,9 @@ createAnchorPeerUpdate() { fi set -x - # Modify the configuration to append the anchor peer jq '.channel_group.groups.Application.groups.'${CORE_PEER_LOCALMSPID}'.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "'$HOST'","port": '$PORT'}]},"version": "0"}}' ${CORE_PEER_LOCALMSPID}config.json > ${CORE_PEER_LOCALMSPID}modified_config.json { set +x; } 2>/dev/null - # Compute a config update, based on the differences between - # {orgmsp}config.json and {orgmsp}modified_config.json, write - # it as a transaction to {orgmsp}anchors.tx createConfigUpdate ${CHANNEL_NAME} ${CORE_PEER_LOCALMSPID}config.json ${CORE_PEER_LOCALMSPID}modified_config.json ${CORE_PEER_LOCALMSPID}anchors.tx } @@ -58,4 +46,4 @@ setGlobalsCLI $ORG createAnchorPeerUpdate -updateAnchorPeer +updateAnchorPeer diff --git a/fabric/network/scripts/utils.sh b/fabric/network/scripts/utils.sh @@ -6,69 +6,38 @@ C_GREEN='\033[0;32m' C_BLUE='\033[0;34m' C_YELLOW='\033[1;33m' -# Print the usage message function printHelp() { USAGE="$1" if [ "$USAGE" == "up" ]; then println "Usage: " println " network.sh \033[0;32mup\033[0m [Flags]" - println println " Flags:" - println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material" + println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material" println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")" println " -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb" - println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)" - println " -d <delay> - CLI delays for a certain number of seconds (defaults to 3)" println " -verbose - Verbose mode" - println println " -h - Print this message" - println - println " Possible Mode and flag combinations" - println " \033[0;32mup\033[0m -ca -r -d -s -verbose" - println " \033[0;32mup createChannel\033[0m -ca -c -r -d -s -verbose" - println - println " Examples:" - println " network.sh up createChannel -ca -c mychannel -s couchdb " elif [ "$USAGE" == "createChannel" ]; then println "Usage: " println " network.sh \033[0;32mcreateChannel\033[0m [Flags]" - println println " Flags:" println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")" - println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)" - println " -d <delay> - CLI delays for a certain number of seconds (defaults to 3)" println " -verbose - Verbose mode" - println println " -h - Print this message" - println - println " Possible Mode and flag combinations" - println " \033[0;32mcreateChannel\033[0m -c -r -d -verbose" - println - println " Examples:" - println " network.sh createChannel -c channelName" elif [ "$USAGE" == "deployCC" ]; then println "Usage: " println " network.sh \033[0;32mdeployCC\033[0m [Flags]" - println println " Flags:" println " -c <channel name> - Name of channel to deploy chaincode to" println " -ccn <name> - Chaincode name." - println " -ccl <language> - Programming language of chaincode to deploy: go, java, javascript, typescript" - println " -ccv <version> - Chaincode version. 1.0 (default), v2, version3.x, etc" - println " -ccs <sequence> - Chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc" + println " -ccl <language> - Programming language of chaincode: go, java, javascript, typescript" + println " -ccv <version> - Chaincode version. 1.0 (default)" + println " -ccs <sequence> - Chaincode definition sequence. 1 (default)" println " -ccp <path> - File path to the chaincode." - println " -ccep <policy> - (Optional) Chaincode endorsement policy using signature policy syntax. The default policy requires an endorsement from Org1 and Org2" + println " -ccep <policy> - (Optional) Chaincode endorsement policy." println " -cccg <collection-config> - (Optional) File path to private data collections configuration file" - println " -cci <fcn name> - (Optional) Name of chaincode initialization function. When a function is provided, the execution of init will be requested and the function will be invoked." - println + println " -cci <fcn name> - (Optional) Name of chaincode initialization function." println " -h - Print this message" - println - println " Possible Mode and flag combinations" - println " \033[0;32mdeployCC\033[0m -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose" - println - println " Examples:" - println " network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ ./ -ccl javascript" - println " network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript" else println "Usage: " println " network.sh <Mode> [Flags]" @@ -76,71 +45,36 @@ function printHelp() { println " \033[0;32mup\033[0m - Bring up Fabric orderer and peer nodes. No channel is created" println " \033[0;32mup createChannel\033[0m - Bring up fabric network with one channel" println " \033[0;32mcreateChannel\033[0m - Create and join a channel after the network is created" - println " \033[0;32mdeployCC\033[0m - Deploy a chaincode to a channel (defaults to asset-transfer-basic)" + println " \033[0;32mdeployCC\033[0m - Deploy a chaincode to a channel" println " \033[0;32mdown\033[0m - Bring down the network" - println println " Flags:" - println " Used with \033[0;32mnetwork.sh up\033[0m, \033[0;32mnetwork.sh createChannel\033[0m:" - println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material" - println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")" - println " -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb" - println " -r <max retry> - CLI times out after certain number of attempts (defaults to 5)" - println " -d <delay> - CLI delays for a certain number of seconds (defaults to 3)" - println " -verbose - Verbose mode" - println - println " Used with \033[0;32mnetwork.sh deployCC\033[0m" - println " -c <channel name> - Name of channel to deploy chaincode to" - println " -ccn <name> - Chaincode name." - println " -ccl <language> - Programming language of the chaincode to deploy: go, java, javascript, typescript" - println " -ccv <version> - Chaincode version. 1.0 (default), v2, version3.x, etc" - println " -ccs <sequence> - Chaincode definition sequence. Must be an integer, 1 (default), 2, 3, etc" - println " -ccp <path> - File path to the chaincode." - println " -ccep <policy> - (Optional) Chaincode endorsement policy using signature policy syntax. The default policy requires an endorsement from Org1 and Org2" - println " -cccg <collection-config> - (Optional) File path to private data collections configuration file" - println " -cci <fcn name> - (Optional) Name of chaincode initialization function. When a function is provided, the execution of init will be requested and the function will be invoked." - println - println " -h - Print this message" - println - println " Possible Mode and flag combinations" - println " \033[0;32mup\033[0m -ca -r -d -s -verbose" - println " \033[0;32mup createChannel\033[0m -ca -c -r -d -s -verbose" - println " \033[0;32mcreateChannel\033[0m -c -r -d -verbose" - println " \033[0;32mdeployCC\033[0m -ccn -ccl -ccv -ccs -ccp -cci -r -d -verbose" - println - println " Examples:" - println " network.sh up createChannel -ca -c mychannel -s couchdb" - println " network.sh createChannel -c channelName" - println " network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-javascript/ -ccl javascript" - println " network.sh deployCC -ccn mychaincode -ccp ./user/mychaincode -ccv 1 -ccl javascript" + println " -ca: Use Certificate Authorities" + println " -c <channel name>: channel name (defaults to \"mychannel\")" + println " -s <dbtype>: Peer state database (defaults to goleveldb)" + println " -verbose: Verbose mode" fi } -# println echos string function println() { echo -e "$1" } -# errorln echos i red color function errorln() { println "${C_RED}${1}${C_RESET}" } -# successln echos in green color function successln() { println "${C_GREEN}${1}${C_RESET}" } -# infoln echos in blue color function infoln() { println "${C_BLUE}${1}${C_RESET}" } -# warnln echos in yellow color function warnln() { println "${C_YELLOW}${1}${C_RESET}" } -# fatalln echos in red color and exits with fail status function fatalln() { errorln "$1" exit 1