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 16, 2020
1 parent fc64d51 commit 2041753
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 74 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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
12 changes: 6 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM alpine:3.10
FROM alpine:3.11
RUN apk add --no-cache ansible bash jq moreutils && \
pip3 install docker
RUN wget -qO docker-19.03.2.tgz https://download.docker.com/linux/static/stable/x86_64/docker-19.03.2.tgz && \
tar xzvf docker-19.03.2.tgz --strip 1 -C /usr/local/bin docker/docker && \
rm docker-19.03.2.tgz && \
wget -qO /usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" && \
RUN wget -qO docker-19.03.5.tgz https://download.docker.com/linux/static/stable/x86_64/docker-19.03.5.tgz && \
tar xzvf docker-19.03.5.tgz --strip 1 -C /usr/local/bin docker/docker && \
rm docker-19.03.5.tgz && \
wget -qO /usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/1.25.1/docker-compose-$(uname -s)-$(uname -m)" && \
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,17 +95,17 @@
- 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 }}"
networks_cli_compatible: yes
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 @@ -178,7 +178,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 @@ -194,7 +194,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 @@ -123,7 +123,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 }}"
networks_cli_compatible: yes
Expand All @@ -137,10 +137,10 @@
CORE_PEER_GOSSIP_EXTERNALENDPOINT: "{{ peer.docker.name }}:{{ 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.name + ':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
68 changes: 65 additions & 3 deletions templates/manage-channel/fabric-channel-config-update.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}
},
"Readers": {
"mod_policy": "Readers",
"mod_policy": "Admins",
"policy": {
"type": 1,
"value": {
Expand Down Expand Up @@ -92,7 +92,69 @@
}
},
"Writers": {
"mod_policy": "Writers",
"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 %}
]
}
}
},
"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": {
Expand Down Expand Up @@ -128,7 +190,7 @@
"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
Loading

0 comments on commit 2041753

Please sign in to comment.