Skip to content

Commit

Permalink
Merge pull request #3 from hyperledger/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
XuHugo authored Jan 23, 2021
2 parents b50383b + 1fe2244 commit 1fcac4f
Show file tree
Hide file tree
Showing 5 changed files with 260 additions and 76 deletions.
2 changes: 1 addition & 1 deletion build_image/dockerhub/v0.9.0/user-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"rimraf": "^2.6.2",
"shelljs": "^0.7.8",
"sleep-promise": "^2.0.0",
"socket.io": "^2.0.4",
"socket.io": "^2.4.0",
"swig": "^1.4.2",
"uuid4": "^1.0.0",
"winston": "^2.3.1"
Expand Down
124 changes: 49 additions & 75 deletions build_image/dockerhub/v0.9.0/user-dashboard/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,6 @@ async-each@^1.0.0, async-each@^1.0.1:
resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==

async-limiter@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==

async-listener@^0.6.0:
version "0.6.10"
resolved "https://registry.yarnpkg.com/async-listener/-/async-listener-0.6.10.tgz#a7c97abe570ba602d782273c0de60a51e3e17cbc"
Expand Down Expand Up @@ -1105,13 +1100,6 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

better-assert@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522"
integrity sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=
dependencies:
callsite "1.0.0"

binary-extensions@^1.0.0:
version "1.13.1"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65"
Expand Down Expand Up @@ -1314,7 +1302,7 @@ caller-path@^0.1.0:
dependencies:
callsites "^0.2.0"

callsite@1.0.0, callsite@^1.0.0:
callsite@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA=
Expand Down Expand Up @@ -1574,7 +1562,7 @@ component-emitter@1.2.1:
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=

component-emitter@^1.2.1:
component-emitter@^1.2.1, component-emitter@~1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
Expand Down Expand Up @@ -1683,6 +1671,11 @@ cookie@0.4.0:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==

cookie@~0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.1.tgz#afd713fe26ebd21ba95ceb61f9a8116e50a537d1"
integrity sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==

copy-descriptor@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
Expand Down Expand Up @@ -1952,20 +1945,20 @@ end-of-stream@^1.0.0:
dependencies:
once "^1.4.0"

engine.io-client@~3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.4.0.tgz#82a642b42862a9b3f7a188f41776b2deab643700"
integrity sha512-a4J5QO2k99CM2a0b12IznnyQndoEvtA4UAldhGzKqnHf42I3Qs2W5SPnDvatZRcMaNZs4IevVicBPayxYt6FwA==
engine.io-client@~3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.5.0.tgz#fc1b4d9616288ce4f2daf06dcf612413dec941c7"
integrity sha512-12wPRfMrugVw/DNyJk34GQ5vIVArEcVMXWugQGGuw2XxUSztFNmJggZmv8IZlLyEdnpO1QB9LkcjeWewO2vxtA==
dependencies:
component-emitter "1.2.1"
component-emitter "~1.3.0"
component-inherit "0.0.3"
debug "~4.1.0"
debug "~3.1.0"
engine.io-parser "~2.2.0"
has-cors "1.1.0"
indexof "0.0.1"
parseqs "0.0.5"
parseuri "0.0.5"
ws "~6.1.0"
parseqs "0.0.6"
parseuri "0.0.6"
ws "~7.4.2"
xmlhttprequest-ssl "~1.5.4"
yeast "0.1.2"

Expand All @@ -1980,17 +1973,17 @@ engine.io-parser@~2.2.0:
blob "0.0.5"
has-binary2 "~1.0.2"

engine.io@~3.4.0:
version "3.4.0"
resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.4.0.tgz#3a962cc4535928c252759a00f98519cb46c53ff3"
integrity sha512-XCyYVWzcHnK5cMz7G4VTu2W7zJS7SM1QkcelghyIk/FmobWBtXE7fwhBusEKvCSqc3bMh8fNFMlUkCKTFRxH2w==
engine.io@~3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.5.0.tgz#9d6b985c8a39b1fe87cd91eb014de0552259821b"
integrity sha512-21HlvPUKaitDGE4GXNtQ7PLP0Sz4aWLddMPw2VTyFz1FVZqu/kZsJUO8WNpKuE/OCL7nkfRaOui2ZCJloGznGA==
dependencies:
accepts "~1.3.4"
base64id "2.0.0"
cookie "0.3.1"
cookie "~0.4.1"
debug "~4.1.0"
engine.io-parser "~2.2.0"
ws "^7.1.2"
ws "~7.4.2"

errs@^0.3.2:
version "0.3.2"
Expand Down Expand Up @@ -4192,11 +4185,6 @@ object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=

object-component@0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291"
integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=

object-copy@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c"
Expand Down Expand Up @@ -4336,19 +4324,15 @@ parse-glob@^3.0.4:
is-extglob "^1.0.0"
is-glob "^2.0.0"

parseqs@0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d"
integrity sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=
dependencies:
better-assert "~1.0.0"
parseqs@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.6.tgz#8e4bb5a19d1cdc844a08ac974d34e273afa670d5"
integrity sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w==

parseuri@0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a"
integrity sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=
dependencies:
better-assert "~1.0.0"
parseuri@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.6.tgz#e1496e829e3ac2ff47f39a4dd044b32823c4a25a"
integrity sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow==

parseurl@~1.3.3:
version "1.3.3"
Expand Down Expand Up @@ -5275,23 +5259,20 @@ socket.io-adapter@~1.1.0:
resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.2.tgz#ab3f0d6f66b8fc7fca3959ab5991f82221789be9"
integrity sha512-WzZRUj1kUjrTIrUKpZLEzFZ1OLj5FwLlAFQs9kuZJzJi5DKdU7FsWc36SNmA8iDOtwBQyT8FkrriRM8vXLYz8g==

socket.io-client@2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.3.0.tgz#14d5ba2e00b9bcd145ae443ab96b3f86cbcc1bb4"
integrity sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==
socket.io-client@2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.4.0.tgz#aafb5d594a3c55a34355562fc8aea22ed9119a35"
integrity sha512-M6xhnKQHuuZd4Ba9vltCLT9oa+YvTsP8j9NcEiLElfIg8KeYPyhWOes6x4t+LTAC8enQbE/995AdTem2uNyKKQ==
dependencies:
backo2 "1.0.2"
base64-arraybuffer "0.1.5"
component-bind "1.0.0"
component-emitter "1.2.1"
debug "~4.1.0"
engine.io-client "~3.4.0"
component-emitter "~1.3.0"
debug "~3.1.0"
engine.io-client "~3.5.0"
has-binary2 "~1.0.2"
has-cors "1.1.0"
indexof "0.0.1"
object-component "0.0.3"
parseqs "0.0.5"
parseuri "0.0.5"
parseqs "0.0.6"
parseuri "0.0.6"
socket.io-parser "~3.3.0"
to-array "0.1.4"

Expand All @@ -5313,16 +5294,16 @@ socket.io-parser@~3.4.0:
debug "~4.1.0"
isarray "2.0.1"

socket.io@^2.0.4:
version "2.3.0"
resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.3.0.tgz#cd762ed6a4faeca59bc1f3e243c0969311eb73fb"
integrity sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg==
socket.io@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.4.0.tgz#01030a2727bd8eb2e85ea96d69f03692ee53d47e"
integrity sha512-9UPJ1UTvKayuQfVv2IQ3k7tCQC/fboDyIK62i99dAQIyHKaBsNdTpwHLgKJ6guRWxRtC9H+138UwpaGuQO9uWQ==
dependencies:
debug "~4.1.0"
engine.io "~3.4.0"
engine.io "~3.5.0"
has-binary2 "~1.0.2"
socket.io-adapter "~1.1.0"
socket.io-client "2.3.0"
socket.io-client "2.4.0"
socket.io-parser "~3.4.0"

source-map-resolve@^0.5.0:
Expand Down Expand Up @@ -6048,17 +6029,10 @@ write@^0.2.1:
dependencies:
mkdirp "^0.5.1"

ws@^7.1.2:
version "7.2.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.1.tgz#03ed52423cd744084b2cf42ed197c8b65a936b8e"
integrity sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A==

ws@~6.1.0:
version "6.1.4"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.1.4.tgz#5b5c8800afab925e94ccb29d153c8d02c1776ef9"
integrity sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==
dependencies:
async-limiter "~1.0.0"
ws@~7.4.2:
version "7.4.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.2.tgz#782100048e54eb36fe9843363ab1c68672b261dd"
integrity sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA==

xdg-basedir@^3.0.0:
version "3.0.0"
Expand Down
5 changes: 5 additions & 0 deletions src/api-engine/api/lib/configtxgen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# SPDX-License-Identifier: Apache-2.0
#
from .configtx import ConfigTX
from .configtxgen import ConfigTxGen
140 changes: 140 additions & 0 deletions src/api-engine/api/lib/configtxgen/configtx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#
# SPDX-License-Identifier: Apache-2.0
#
import yaml
import os
from api.config import CELLO_HOME


class ConfigTX:
"""Class represents crypto-config yaml."""

def __init__(self, network, filepath=CELLO_HOME, orderer=None, raft_option=None):
"""init ConfigTX
param:
network: network's name
orderer: configuration of output block
raft_option: configuration of raft
filepath: cello's working directory
return:
"""
self.filepath = filepath
self.network = network
self.orderer = {'BatchTimeout': '2s',
'OrdererType': "etcdraft",
'BatchSize': {'AbsoluteMaxBytes': '98 MB',
'MaxMessageCount': 2000,
'PreferredMaxBytes': '10 MB'}} if not orderer else orderer
self.raft_option = {'TickInterval': "600ms",
'ElectionTick': 10,
'HeartbeatTick': 1,
'MaxInflightBlocks': 5,
'SnapshotIntervalSize': "20 MB"} if not raft_option else raft_option

def create(self, consensus, orderers, peers, orderer_cfg=None, application=None, option=None):
"""create the cryptotx.yaml
param:
consensus:consensus
orderers:the list of orderer
peers: the list of peer
orderer_cfg: the config of orderer
application: application
option: option
return:
"""
OrdererOrganizations = []
OrdererAddress = []
for orderer in orderers:
OrdererOrganizations.append(dict(Name=orderer["name"].split(".")[0].capitalize() + "Orderer",
ID='{}MSP'.format(orderer["name"].split(".")[0].capitalize()+"Orderer"),
MSPDir='{}/{}/crypto-config/ordererOrganizations/{}/msp'.format(self.filepath,orderer["name"],orderer['name'].split(".", 1)[1]),
Policies=dict(Readers=dict(Type="Signature",Rule="OR('{}MSP.member')".format(orderer["name"].split(".")[0].capitalize()+"Orderer")),
Writers=dict(Type="Signature",Rule="OR('{}MSP.member')".format(orderer["name"].split(".")[0].capitalize()+"Orderer")),
Admins=dict(Type="Signature",Rule="OR('{}MSP.admin')".format(orderer["name"].split(".")[0].capitalize()+"Orderer")))
))
for host in orderer['hosts']:
OrdererAddress.append('{}.{}:{}'.format(host['name'], orderer['name'].split(".", 1)[1], host["port"]))

PeerOrganizations = []

for peer in peers:
PeerOrganizations.append(dict(Name=peer["name"].split(".")[0].capitalize(),
ID='{}MSP'.format(peer["name"].split(".")[0].capitalize()),
MSPDir='{}/{}/crypto-config/peerOrganizations/{}/msp'.format(self.filepath,peer['name'],peer['name']),
#AnchorPeers=[{'Port': peer["hosts"][0]["port"], 'Host': '{}.{}'.format(peer["hosts"][0]["name"],peer["name"])}],
Policies=dict(Readers=dict(Type="Signature",Rule="OR('{}MSP.peer', '{}MSP.admin','{}MSP.client')".format(peer["name"].split(".")[0].capitalize(),peer["name"].split(".")[0].capitalize(),peer["name"].split(".")[0].capitalize())),
Writers=dict(Type="Signature",Rule="OR('{}MSP.admin','{}MSP.client')".format(peer["name"].split(".")[0].capitalize(),peer["name"].split(".")[0].capitalize())),
Admins=dict(Type="Signature",Rule="OR('{}MSP.admin')".format(peer["name"].split(".")[0].capitalize())))
))
Organizations = OrdererOrganizations + PeerOrganizations

Orderer = {'BatchTimeout': orderer_cfg['BatchTimeout'] if orderer_cfg else self.orderer['BatchTimeout'],
'Organizations': None,
'Addresses': OrdererAddress,
'OrdererType': consensus if consensus else self.orderer['OrdererType'],
'BatchSize': orderer_cfg['BatchSize'] if orderer_cfg else self.orderer['BatchSize']
}

channel = {"Policies": dict(Readers=dict(Type="ImplicitMeta", Rule="ANY Readers"),
Writers=dict(Type="ImplicitMeta", Rule="ANY Writers"),
Admins=dict(Type="ImplicitMeta", Rule="MAJORITY Admins"))
}


if consensus=='etcdraft':
Consenters = []
for orderer in orderers:
for host in orderer['hosts']:
Consenters.append(dict(Host='{}.{}'.format(host['name'], orderer['name'].split(".", 1)[1]),
Port=host['port'],
ClientTLSCert='{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt'
.format(self.filepath, orderer['name'], orderer['name'].split(".", 1)[1],host['name'], orderer['name'].split(".", 1)[1]),
ServerTLSCert='{}/{}/crypto-config/ordererOrganizations/{}/orderers/{}.{}/tls/server.crt'
.format(self.filepath, orderer['name'], orderer['name'].split(".", 1)[1], host['name'], orderer['name'].split(".", 1)[1])))
Option = option if option else self.raft_option
Orderer['EtcdRaft'] = dict(Consenters=Consenters,Options=Option)
Orderer["Policies"] = dict(Readers=dict(Type="ImplicitMeta", Rule="ANY Readers"),
Writers=dict(Type="ImplicitMeta", Rule="ANY Writers"),
Admins=dict(Type="ImplicitMeta", Rule="MAJORITY Admins"),
BlockValidation=dict(Type="ImplicitMeta",Rule="MAJORITY Writers"))
#Profiles['TwoOrgsOrdererGenesis']['Orderer']['EtcdRaft'] = dict(Consenters=Consenters, Options=Option)

Application = application if application else {'Organizations': None,
"Policies": dict(Readers=dict(Type="ImplicitMeta", Rule="ANY Readers"),
Writers=dict(Type="ImplicitMeta", Rule="ANY Writers"),
Admins=dict(Type="ImplicitMeta", Rule="MAJORITY Admins"))
}
Profiles = {'TwoOrgsOrdererGenesis': {
# 'Orderer': {'BatchTimeout': orderer_cfg['BatchTimeout'] if orderer_cfg else self.orderer['BatchTimeout'],
# 'Organizations': OrdererOrganizations,
# 'Addresses': OrdererAddress,
# 'OrdererType': consensus if consensus else self.orderer['OrdererType'],
# 'BatchSize': orderer_cfg['BatchSize'] if orderer_cfg else self.orderer['BatchSize']
# },
"Orderer": Orderer,
'Consortiums': {'SampleConsortium': {'Organizations': PeerOrganizations}},
"Policies": dict(Readers=dict(Type="ImplicitMeta", Rule="ANY Readers"),
Writers=dict(Type="ImplicitMeta", Rule="ANY Writers"),
Admins=dict(Type="ImplicitMeta", Rule="MAJORITY Admins"))
}}

configtx = dict(Application=Application, Orderer=Orderer, Profiles=Profiles, Organizations=Organizations, Channel=channel)
os.system('mkdir -p {}/{}'.format(self.filepath, self.network))

with open('{}/{}/configtx.yaml'.format(self.filepath, self.network), 'w', encoding='utf-8') as f:
yaml.dump(configtx, f)

def update(self):
"""update the cryptotx.yaml
param:
return:
"""
pass


if __name__ == "__main__":
orderers=[{"name":"org1.cello.com","hosts":[{"name": "orderer1", "port":8051}]}]
#peers = [{"name": "org1.cello.com", "hosts": [{"name": "foo", "port": 7051},{"name": "car", "port": 7052}]},
# {"name": "org2.cello.com", "hosts": [{"name": "zoo", "port": 7053}]}]
peers = [{"name": "org1.cello.com", "hosts": [{"name": "foo", "port": 7051}, {"name": "car", "port": 7052}]}]
ConfigTX("test3").create(consensus="etcdraft", orderers=orderers, peers=peers)
Loading

0 comments on commit 1fcac4f

Please sign in to comment.