Skip to content

Commit

Permalink
Merge pull request #473 from Sanket-0510/consortium_update
Browse files Browse the repository at this point in the history
dropped consortium according to the version
  • Loading branch information
dzikowski authored Aug 14, 2024
2 parents f34e20e + 3d22207 commit 740a894
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
6 changes: 6 additions & 0 deletions e2e/__snapshots__/extendConfig.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode.json 1`] = `
"application": "V2_5",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "docker",
Expand Down Expand Up @@ -1386,6 +1387,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode-k8s.json 1`] =
"application": "V2_0",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "kubernetes",
Expand Down Expand Up @@ -2171,6 +2173,7 @@ exports[`extend config samples/fablo-config-hlf2-1org-1chaincode-raft-explorer.j
"application": "V2_0",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "docker",
Expand Down Expand Up @@ -3521,6 +3524,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-private-data.
"application": "V2_0",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "docker",
Expand Down Expand Up @@ -5744,6 +5748,7 @@ exports[`extend config samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml 1`]
"application": "V2_0",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "docker",
Expand Down Expand Up @@ -8230,6 +8235,7 @@ exports[`extend config samples/fablo-config-hlf2-3orgs-1chaincode-raft-explorer.
"application": "V2_0",
"channel": "V2_0",
"isV2": true,
"isV3": false,
"orderer": "V2_0",
},
"engine": "docker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ Profiles:
- *Orderer2
- *Org1
- *Org2
# Profile used to create Genesis block for group group2 #
Group2Genesis:
<<: *ChannelDefaults
Expand Down Expand Up @@ -301,7 +300,6 @@ Profiles:
Organizations:
- *Org1
- *Org2
# Profile used to create channeltx for my-channel2 #
MyChannel2:
<<: *ChannelDefaults
Expand All @@ -322,7 +320,6 @@ Profiles:
Organizations:
- *Org1
- *Org2
# Profile used to create channeltx for my-channel3 #
MyChannel3:
<<: *ChannelDefaults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ Profiles:
<<: *ApplicationDefaults
Organizations:
- *Org1
# Profile used to create channeltx for my-channel2 #
MyChannel2:
<<: *ChannelDefaults
Expand All @@ -314,7 +313,6 @@ Profiles:
<<: *ApplicationDefaults
Organizations:
- *Org2
# Profile used to create channeltx for my-channel3 #
MyChannel3:
<<: *ChannelDefaults
Expand Down
6 changes: 4 additions & 2 deletions e2e/__snapshots__/fabloCommands.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Validation warnings count: 0
"channel": "V2_0",
"orderer": "V2_0",
"application": "V2_0",
"isV2": true
"isV2": true,
"isV3": false
},
"tools": {}
},
Expand Down Expand Up @@ -2448,7 +2449,8 @@ Validation warnings count: 0
"channel": "V2_0",
"orderer": "V2_0",
"application": "V2_5",
"isV2": true
"isV2": true,
"isV3": false
},
"tools": {}
},
Expand Down
9 changes: 6 additions & 3 deletions src/extend-config/extendGlobal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import defaults from "./defaults";

const getNetworkCapabilities = (fabricVersion: string): Capabilities => {

if (version(fabricVersion).isGreaterOrEqual("2.5.0"))
return { channel: "V2_0", orderer: "V2_0", application: "V2_5", isV2: true };
if (version(fabricVersion).isGreaterOrEqual("2.5.0") && !version(fabricVersion).isGreaterOrEqual("3.0.0"))
return { channel: "V2_0", orderer: "V2_0", application: "V2_5", isV2: true, isV3: false };

return { channel: "V2_0", orderer: "V2_0", application: "V2_0", isV2: true };
if (version(fabricVersion).isGreaterOrEqual("3.0.0"))
return { channel: "V3_0", orderer: "V2_0", application: "V2_5", isV2: false, isV3: true};

return { channel: "V2_0", orderer: "V2_0", application: "V2_0", isV2: true , isV3: false};
};

const getVersions = (fabricVersion: string): FabricVersions => {
Expand Down
35 changes: 20 additions & 15 deletions src/setup-docker/templates/fabric-config/configtx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,46 +126,51 @@ Orderer: &<%= ordererGroup.configtxOrdererDefaults %>
# https://github:com/hyperledger/fabric/blob/master/sampleconfig/configtx.yaml

Profiles:
<%_ ordererGroups.forEach(function(ordererGroup) { _%>
<%_ ordererGroups.forEach(function(ordererGroup) { _%>
# Profile used to create Genesis block for group <%= ordererGroup.name %> #
<%= ordererGroup.profileName %>:
<<: *ChannelDefaults
Orderer:
<<: *<%= ordererGroup.configtxOrdererDefaults %>
Organizations:
<%_ ordererGroup.hostingOrgs.forEach(function(hostingOrg) { _%>
<%_ ordererGroup.hostingOrgs.forEach(function(hostingOrg) { _%>
- *<%= hostingOrg %>
<%_ }) _%>
<%_ }) _%>
Capabilities:
<<: *OrdererCapabilities
<%_ if (!global.capabilities.isV3) { _%>
Consortiums:
SampleConsortium:
Organizations:
<%_ orgs.forEach(function(org){ _%>
<%_ orgs.forEach(function(org){ _%>
- *<%= org.name %>
<%_ }) _%>
<%_ }) _%>
<%_ } _%>
<%_ }) _%>

<%_ }) _%>
<%_ channels.forEach(function(channel) { _%>
<%_ channels.forEach(function(channel) { _%>
# Profile used to create channeltx for <%= channel.name %> #
<%= channel.profileName %>:
<<: *ChannelDefaults
Orderer:
<<: *<%= channel.ordererGroup.configtxOrdererDefaults %>
Organizations:
<%_ channel.ordererGroup.hostingOrgs.forEach(function(hostingOrg) { _%>
<%_ channel.ordererGroup.hostingOrgs.forEach(function(hostingOrg) { _%>
- *<%= hostingOrg %>
<%_ }) _%>
<%_ }) _%>
Capabilities:
<<: *ApplicationCapabilities
Consortium: SampleConsortium
Consortiums:
SampleConsortium:
Organizations:<% channel.orgs.forEach(function(org){ %>
- *<%= org.name %><% }) %>
Organizations:
<%_ channel.orgs.forEach(function(org){ _%>
- *<%= org.name %>
<%_ }) _%>
Application:
<<: *ApplicationDefaults
Organizations:<% channel.orgs.forEach(function(org){ %>
- *<%= org.name %><% }) %>

<%_ }) _%>
Organizations:
<%_ channel.orgs.forEach(function(org){ _%>
- *<%= org.name %>
<%_ }) _%>
<%_ }) _%>
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ upgradeChaincode() {
<% if (global.capabilities.isV2) { -%>
<%- include('commands-generated/chaincode-install-v2.sh', { chaincode, global }); %>
<% } else { -%>
<%- include('commands-generated/chaincode-upgrade-v1.4.sh', { chaincode, global }); %>
<%- include('commands-generated/chaincode-upgrade-v2.sh', { chaincode, global }); %>
<% } -%>
else
echo "Warning! Skipping chaincode '<%= chaincode.name %>' upgrade. Chaincode directory is empty."
Expand Down
11 changes: 10 additions & 1 deletion src/types/FabloConfigExtended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface CapabilitiesV2 {
channel: "V2_0";
orderer: "V2_0";
isV2: true;
isV3: false;
}


Expand All @@ -21,11 +22,19 @@ interface CapabilitiesV_2_5 {
channel: "V2_0";
orderer: "V2_0";
isV2: true;
isV3: false;
}

interface CapabilitiesV3_0 {
application: "V2_5";
channel: "V3_0";
orderer: "V2_0";
isV2: false;
isV3: true;
}


export type Capabilities = CapabilitiesV2 | CapabilitiesV_2_5;
export type Capabilities = CapabilitiesV2 | CapabilitiesV_2_5 | CapabilitiesV3_0;

export interface Global extends FabricVersions {
tls: boolean;
Expand Down

0 comments on commit 740a894

Please sign in to comment.