Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade configtx to HLF2.5.9 #640

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions src/api-engine/api/lib/configtxgen/configtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,9 @@ def __init__(self, network, filepath=CELLO_HOME, orderer=None, raft_option=None,
self.filepath = filepath
self.network = network
self.template = load_configtx(template_path)
# 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

def create(self, name, consensus, orderers, peers, orderer_cfg=None, application=None, option=None):
"""create the configtx.yaml
param:
consensus:consensus
orderers:the list of orderer
Expand Down Expand Up @@ -101,24 +91,24 @@ def create(self, consensus, orderers, peers, orderer_cfg=None, application=None,
Application=ApplicationCapabilities
)
Application = deepcopy(ApplicationDefaults)
Application["Capabilities"] = Capabilities["Application"]
Orderer = deepcopy(OrdererDefaults)
Orderer["Addresses"] = deepcopy(OrdererAddress)
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="ANY Writers")
)
Orderer["EtcdRaft"]["Consenters"] = deepcopy(Consenters)
Channel = deepcopy(ChannelDefaults)
Application["Capabilities"] = Capabilities["Application"]
Channel["Capabilities"] = Capabilities["Channel"]
Orderer["Capabilities"] = Capabilities["Orderer"]
Orderer["OrdererType"] = consensus
Orderer["EtcdRaft"]["Consenters"] = deepcopy(Consenters)

Profiles = {}
Profiles["TwoOrgsOrdererGenesis"] = deepcopy(Channel)
Profiles["TwoOrgsOrdererGenesis"]["Orderer"] = deepcopy(Orderer)
Profiles["TwoOrgsOrdererGenesis"]["Orderer"]["Organizations"] = OrdererOrganizations
Profiles["TwoOrgsOrdererGenesis"]["Orderer"]["Capabilities"] = Capabilities["Orderer"]
Profiles["TwoOrgsOrdererGenesis"]["Consortiums"] = {'SampleConsortium': {'Organizations': deepcopy(PeerOrganizations)}}
Profiles[name] = deepcopy(Channel)
Profiles[name]["Orderer"] = deepcopy(Orderer)
Profiles[name]["Application"] = deepcopy(Application)
Profiles[name]["Capabilities"] = Capabilities["Channel"]
Profiles[name]["Orderer"]["Capabilities"] = Capabilities["Orderer"]
Profiles[name]["Application"]["Capabilities"] = Capabilities["Application"]
Profiles[name]["Orderer"]["Organizations"] = OrdererOrganizations
Profiles[name]["Application"]["Organizations"] = PeerOrganizations

configtx = dict(
Organizations=Organizations,
Expand All @@ -145,8 +135,8 @@ def createChannel(self, name, organizations):
configtx = yaml.load(f, Loader=yaml.FullLoader)
Profiles = configtx["Profiles"]
Channel = configtx["Channel"]
Orderer = configtx["Orderer"]
Application = configtx["Application"]
Capabilities = configtx["Capabilities"]["Application"]
PeerOrganizations = []
for org in configtx["Organizations"]:
for item in organizations:
Expand All @@ -155,10 +145,8 @@ def createChannel(self, name, organizations):
if PeerOrganizations == []:
raise Exception("can't find organnization")
Profiles[name] = deepcopy(Channel)
Profiles[name]["Consortium"] = "SampleConsortium"
Profiles[name]["Application"] = deepcopy(Application)
Profiles[name]["Application"]["Organizations"] = deepcopy(PeerOrganizations)
Profiles[name]["Application"]["Capabilities"] = deepcopy(Capabilities)
Profiles[name]["Orderer"] = Orderer
Profiles[name]["Application"] = Application

with open('{}/{}/{}'.format(self.filepath, self.network, "configtx.yaml"), 'w', encoding='utf-8') as f:
yaml.safe_dump(configtx, f, sort_keys=False)
Expand Down
2 changes: 1 addition & 1 deletion src/api-engine/api/routes/channel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,5 @@ def join_peers(envs, block_path):
# Join the peers to the channel.
peer_channel_cli = PeerChannel(**envs)
peer_channel_cli.join(
block_file=block_path
block_path=block_path
)
Loading