Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Commit

Permalink
Initial support for Fabric v2.0.0 (contributes to #94)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Stone <sstone1@uk.ibm.com>
  • Loading branch information
Simon Stone committed Jan 22, 2020
1 parent 2d80846 commit 8df0135
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 65 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ steps:
displayName: Install Python dependencies
- script: |
set -ex
wget -qO fabric-bins.tar.gz https://github.com/hyperledger/fabric/releases/download/v1.4.4/hyperledger-fabric-linux-amd64-1.4.4.tar.gz
wget -qO fabric-bins.tar.gz https://github.com/hyperledger/fabric/releases/download/v2.0.0-beta/hyperledger-fabric-linux-amd64-2.0.0-beta.tar.gz
sudo tar xvf fabric-bins.tar.gz -C /usr/local
rm fabric-bins.tar.gz
displayName: Download Fabric CLI
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN wget -qO docker-19.03.5.tgz https://download.docker.com/linux/static/stable/
chmod +x /usr/local/bin/docker-compose
RUN mkdir /lib64 && \
ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 && \
wget -qO fabric-bins.tar.gz https://github.com/hyperledger/fabric/releases/download/v1.4.4/hyperledger-fabric-linux-amd64-1.4.4.tar.gz && \
wget -qO fabric-bins.tar.gz https://github.com/hyperledger/fabric/releases/download/v2.0.0-beta/hyperledger-fabric-linux-amd64-2.0.0-beta.tar.gz && \
tar xvf fabric-bins.tar.gz -C /usr/local && \
wget -qO fabric-ca-bins.tar.gz https://github.com/hyperledger/fabric-ca/releases/download/v1.4.4/hyperledger-fabric-ca-linux-amd64-1.4.4.tar.gz && \
tar xvf fabric-ca-bins.tar.gz -C /usr/local && \
Expand Down
12 changes: 6 additions & 6 deletions tasks/docker/create-orderer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@
- name: Start orderer container
docker_container:
name: "{{ orderer.docker.name }}"
image: hyperledger/fabric-orderer:1.4.4
image: hyperledger/fabric-orderer:2.0.0-beta
networks:
- name: "{{ infrastructure.docker.network }}"
aliases:
- "{{ orderer.docker.hostname | mandatory }}"
networks_cli_compatible: yes
hostname: "{{ orderer.docker.hostname | mandatory }}"
env:
ORDERER_GENERAL_GENESISMETHOD: file
ORDERER_GENERAL_GENESISFILE: /var/hyperledger/production/genesis.block
ORDERER_GENERAL_BOOTSTRAPMETHOD: file
ORDERER_GENERAL_BOOTSTRAPFILE: /var/hyperledger/production/genesis.block
ORDERER_GENERAL_LISTENADDRESS: 0.0.0.0
ORDERER_GENERAL_LISTENPORT: "{{ orderer.docker.port }}"
ORDERER_GENERAL_LOCALMSPID: "{{ organization.msp.id }}"
ORDERER_GENERAL_SYSTEMCHANNEL: testchainid
ORDERER_GENERAL_SYSTEMCHANNEL: system-channel
ORDERER_GENERAL_TLS_ENABLED: "{{ 'true' if orderer.tls.enabled else 'false' }}"
ORDERER_OPERATIONS_LISTENADDRESS: 0.0.0.0:{{ orderer.docker.operations_port }}
ORDERER_OPERATIONS_TLS_ENABLED: "{{ 'true' if orderer.tls.enabled else 'false' }}"
Expand Down Expand Up @@ -181,7 +181,7 @@

- name: Test for orderer genesis block in orderer container
command: >
docker exec {{ orderer.docker.name }} test -d /var/hyperledger/production/orderer/chains/testchainid
docker exec {{ orderer.docker.name }} test -d /var/hyperledger/production/orderer/chains/system-channel
register: check_orderer_genesis_block
failed_when: False
changed_when: False
Expand All @@ -197,7 +197,7 @@
configtxgen
-configPath {{ tempdir.path }}
-profile Solo
-channelID testchainid
-channelID system-channel
-outputBlock {{ tempdir.path }}/genesis.block
when: check_orderer_genesis_block.rc != 0

Expand Down
10 changes: 5 additions & 5 deletions tasks/docker/create-peer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
- name: Start peer container
docker_container:
name: "{{ peer.docker.name }}"
image: hyperledger/fabric-peer:1.4.4
image: hyperledger/fabric-peer:2.0.0-beta
networks:
- name: "{{ infrastructure.docker.network }}"
aliases:
Expand All @@ -143,10 +143,10 @@
CORE_PEER_GOSSIP_EXTERNALENDPOINT: "{{ peer.docker.hostname }}:{{ peer.docker.port }}"
CORE_PEER_TLS_ENABLED: "{{ 'true' if peer.tls.enabled else 'false' }}"
CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE: "{{ infrastructure.docker.network }}"
CORE_CHAINCODE_BUILDER: hyperledger/fabric-ccenv:1.4.4
CORE_CHAINCODE_GOLANG_RUNTIME: hyperledger/fabric-baseos:0.4.18
CORE_CHAINCODE_JAVA_RUNTIME: hyperledger/fabric-javaenv:1.4.4
CORE_CHAINCODE_NODE_RUNTIME: hyperledger/fabric-baseimage:0.4.18
CORE_CHAINCODE_BUILDER: hyperledger/fabric-ccenv:2.0.0-beta
CORE_CHAINCODE_GOLANG_RUNTIME: hyperledger/fabric-baseos:2.0.0-beta
CORE_CHAINCODE_JAVA_RUNTIME: hyperledger/fabric-javaenv:2.0.0-beta
CORE_CHAINCODE_NODE_RUNTIME: hyperledger/fabric-nodeenv:2.0.0-beta
CORE_LEDGER_STATE_STATEDATABASE: "{{ 'CouchDB' if peer.database_type is defined and peer.database_type == 'couchdb' else 'goleveldb' }}"
CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS: "{{
peer.docker.couchdb.hostname + ':5984' if peer.database_type is defined and peer.database_type == 'couchdb' else ''
Expand Down
6 changes: 3 additions & 3 deletions tasks/manage-consortium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
peer channel fetch config
{{ tempdir.path }}/config_block.pb
-o {{ ibp[orderer.id].hostname }}:{{ ibp[orderer.id].port }}
-c testchainid
-c system-channel
{{ '--tls' if ibp[orderer.id].protocol == 'grpcs' else '' }}
{{ '--cafile "' + ibp[orderer.id].pem + '"' if ibp[orderer.id].protocol == 'grpcs' else '' }}
{{ '--ordererTLSHostnameOverride ' + ibp[orderer.id].internal_hostname if ibp[orderer.id].internal_hostname is defined else '' }}
Expand Down Expand Up @@ -58,7 +58,7 @@
- name: Compute system channel configuration update
command: >
configtxlator compute_update
--channel_id=testchainid
--channel_id=system-channel
--original={{ tempdir.path }}/config.pb
--updated={{ tempdir.path }}/updated_config.pb
--output={{ tempdir.path }}/config_update.pb
Expand Down Expand Up @@ -96,7 +96,7 @@
peer channel update
-f {{ tempdir.path }}/config_update_as_envelope.pb
-o {{ ibp[orderer.id].hostname }}:{{ ibp[orderer.id].port }}
-c testchainid
-c system-channel
{{ '--tls' if ibp[orderer.id].protocol == 'grpcs' else '' }}
{{ '--cafile "' + ibp[orderer.id].pem + '"' if ibp[orderer.id].protocol == 'grpcs' else '' }}
{{ '--ordererTLSHostnameOverride ' + ibp[orderer.id].internal_hostname if ibp[orderer.id].internal_hostname is defined else '' }}
Expand Down
57 changes: 24 additions & 33 deletions templates/docker/configtx.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ Organizations:
Admins:
Type: Signature
Rule: "OR('{{ organization.msp.id }}.admin')"
Endorsement:
Type: Signature
Rule: "OR('{{ organization.msp.id }}.peer')"

################################################################################
#
Expand All @@ -69,52 +72,34 @@ Capabilities:
# supported by both.
# Set the value of the capability to true to require it.
Channel: &ChannelCapabilities
# V1.4.3 for Channel is a catchall flag for behavior which has been
# determined to be desired for all orderers and peers running at the v1.4.3
# V2.0 for Channel is a catchall flag for behavior which has been
# determined to be desired for all orderers and peers running at the v2.0.0
# level, but which would be incompatible with orderers and peers from
# prior releases.
# Prior to enabling V1.4.3 channel capabilities, ensure that all
# orderers and peers on a channel are at v1.4.3 or later.
V1_4_3: true
# V1.3 for Channel enables the new non-backwards compatible
# features and fixes of fabric v1.3
V1_3: false
# V1.1 for Channel enables the new non-backwards compatible
# features and fixes of fabric v1.1
V1_1: false
# 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
# V1.4.2 for Orderer is a catchall flag for behavior which has been
# determined to be desired for all orderers running at the v1.4.2
# V1.1 for Orderer is a catchall flag for behavior which has been
# determined to be desired for all orderers running at the v1.1.x
# level, but which would be incompatible with orderers from prior releases.
# Prior to enabling V1.4.2 orderer capabilities, ensure that all
# orderers on a channel are at v1.4.2 or later.
V1_4_2: true
# V1.1 for Orderer enables the new non-backwards compatible
# features and fixes of fabric v1.1
V1_1: false
# Prior to enabling V2.0 orderer capabilities, ensure that all
# orderers on a channel are at v2.0.0 or later.
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
# V1.4.2 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.4.2
V1_4_2: true
# V1.3 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.3.
V1_3: false
# V1.2 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.2 (note, this need not be set if
# later version capabilities are set)
V1_2: false
# V1.1 for Application enables the new non-backwards compatible
# features and fixes of fabric v1.1 (note, this need not be set if
# later version capabilities are set).
V1_1: false
# V2.0 for Application enables the new non-backwards compatible
# features and fixes of fabric v2.0.
# Prior to enabling V2.0 orderer capabilities, ensure that all
# orderers on a channel are at v2.0.0 or later.
V2_0: true

################################################################################
#
Expand Down Expand Up @@ -210,6 +195,12 @@ Application: &ApplicationDefaults
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
LifecycleEndorsement:
Type: ImplicitMeta
Rule: "MAJORITY Endorsement"
Endorsement:
Type: ImplicitMeta
Rule: "MAJORITY Endorsement"

# Capabilities describes the application level capabilities, see the
# dedicated Capabilities section elsewhere in this file for a full
Expand Down
64 changes: 63 additions & 1 deletion templates/manage-channel/fabric-channel-config-update.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,76 @@
]
}
}
},
"LifecycleEndorsement": {
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
"rule": {
"n_out_of": {
"n": 1,
"rules": [
{% for member in channel.members %}
{
"signed_by": {{ loop.index0 }}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
},
"identities": [
{% for member in channel.members %}
{
"principal_classification": "ROLE",
"principal": {
"msp_identifier": "{{ member.msp.id }}",
"role": "MEMBER"
}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
}
},
"Endorsement": {
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
"rule": {
"n_out_of": {
"n": 1,
"rules": [
{% for member in channel.members %}
{
"signed_by": {{ loop.index0 }}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
},
"identities": [
{% for member in channel.members %}
{
"principal_classification": "ROLE",
"principal": {
"msp_identifier": "{{ member.msp.id }}",
"role": "MEMBER"
}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
}
}
},
"values": {
"Capabilities": {
"mod_policy": "Admins",
"value": {
"capabilities": {
"V1_4_2": {}
"V2_0": {}
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions templates/manage-channel/fabric-msp.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@
}
}
}
},
"Endorsement": {
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
"identities": [
{
"principal": {
"msp_identifier": "{{ member.msp.id }}",
"role": "MEMBER"
},
"principal_classification": "ROLE"
}
],
"rule": {
"n_out_of": {
"n": 1,
"rules": [
{
"signed_by": 0
}
]
}
}
}
}
}
},
"values": {
Expand Down
62 changes: 62 additions & 0 deletions templates/manage-channel/fabric-policies.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,67 @@
]
}
}
},
"LifecycleEndorsement": {
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
"rule": {
"n_out_of": {
"n": 1,
"rules": [
{% for member in channel.members %}
{
"signed_by": {{ loop.index0 }}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
},
"identities": [
{% for member in channel.members %}
{
"principal_classification": "ROLE",
"principal": {
"msp_identifier": "{{ member.msp.id }}",
"role": "MEMBER"
}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
}
},
"Endorsement": {
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
"rule": {
"n_out_of": {
"n": 1,
"rules": [
{% for member in channel.members %}
{
"signed_by": {{ loop.index0 }}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
},
"identities": [
{% for member in channel.members %}
{
"principal_classification": "ROLE",
"principal": {
"msp_identifier": "{{ member.msp.id }}",
"role": "MEMBER"
}
}{%- if not loop.last -%},{% endif %}
{% endfor %}
]
}
}
}
}
2 changes: 1 addition & 1 deletion templates/manage-consortium/fabric-config-envelope.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"payload":{
"header":{
"channel_header":{
"channel_id":"testchainid",
"channel_id":"system-channel",
"type":2
}
},
Expand Down
Loading

0 comments on commit 8df0135

Please sign in to comment.