Skip to content

Commit

Permalink
Merge branch 'feat/fpc-with-cc-tools-design-document' of https://gith…
Browse files Browse the repository at this point in the history
…ub.com/osamamagdy/fabric-private-chaincode into feat/fpc-with-cc-tools-design-document
  • Loading branch information
osamamagdy committed Oct 10, 2024
2 parents 8b405f8 + f70fc30 commit c9650c2
Show file tree
Hide file tree
Showing 38 changed files with 419 additions and 402 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# SPDX-License-Identifier: Apache-2.0
#


name: Git checks

on: [pull_request]

permissions:
contents: read

jobs:
block-fixup:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Block Fixup Commit Merge
uses: 13rac1/[email protected]
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
[submodule "common/crypto/pdo"]
path = common/crypto/pdo
url = https://github.com/hyperledger-labs/private-data-objects
[submodule "samples/deployment/test-network/fabric-samples"]
path = samples/deployment/test-network/fabric-samples
url = https://github.com/hyperledger/fabric-samples.git
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Code of Conduct Guidelines
==========================

Please review the Hyperledger [Code of
Conduct](https://wiki.hyperledger.org/community/hyperledger-project-code-of-conduct)
Conduct](https://lf-decentralized-trust.github.io/governance/governing-documents/code-of-conduct.html#code-of-conduct)
before participating. It is important that we keep things civil.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Make sure that you have the following required dependencies installed:
* [Intel Software Guard Extensions SSL](https://github.com/intel/intel-sgx-ssl)
(we recommend using tag `3.0_Rev2` OpenSSL `3.0.12`)
* Hyperledger [Fabric](https://github.com/hyperledger/fabric/tree/v2.5.4) v2.5.4
* Hyperledger [Fabric](https://github.com/hyperledger/fabric/tree/v2.5.9) v2.5.9
* Clang-format 6.x or higher
Expand Down Expand Up @@ -349,15 +349,15 @@ export PROTOC_CMD=/usr/local/proto3/bin/protoc
#### Hyperledger Fabric
Our project fetches the latest supported Fabric binaries during the build process automatically.
However, if you want to use your own Fabric binaries, please checkout Fabric 2.5.4 release using the following commands:
However, if you want to use your own Fabric binaries, please checkout Fabric 2.5.9 release using the following commands:
```bash
export FABRIC_PATH=$GOPATH/src/github.com/hyperledger/fabric
git clone https://github.com/hyperledger/fabric.git $FABRIC_PATH
cd $FABRIC_PATH; git checkout tags/v2.5.4
cd $FABRIC_PATH; git checkout tags/v2.5.9
```
Note that Fabric Private Chaincode may not work with the Fabric `main` branch.
Therefore, make sure you use the Fabric `v2.5.4` tag.
Therefore, make sure you use the Fabric `v2.5.9` tag.
Make sure the source of Fabric is in your `$GOPATH`.
## Build Fabric Private Chaincode
Expand Down
2 changes: 2 additions & 0 deletions build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ include $(TOP)/config.mk

# define composites only here and not in config.mk so we can override parts in config.override.mk
DOCKER := $(DOCKER_CMD) $(DOCKERFLAGS)
DOCKER_COMPOSE := $(DOCKER_CMD) compose

ifeq (${SGX_MODE}, HW)
GOTAGS = -tags sgx_hw_mode
endif
Expand Down
4 changes: 2 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ PLANTUML_IMG_FORMAT ?= png # pdf / png / svg
#--------------------------------------------------
PROJECT_NAME=fabric-private-chaincode

export FABRIC_VERSION ?= 2.5.4
export FABRIC_CA_VERSION ?= 1.5.7
export FABRIC_VERSION ?= 2.5.9
export FABRIC_CA_VERSION ?= 1.5.12

export FPC_VERSION := main
export FPC_CCENV_IMAGE ?= hyperledger/fabric-private-chaincode-ccenv:$(FPC_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion fabric/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To clean the native build, type `cd $FPC_PATH/fabric; make clean-native`.
### Wrong Fabric version
```
Patching Fabric ...
Aborting! Tag on current HEAD () does not match expected tag/v2.5.4!
Aborting! Tag on current HEAD () does not match expected tag/v2.5.9!
...
```

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-protos-go v0.3.0
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b
github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.11.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ github.com/hyperledger/fabric-protos-go v0.3.0 h1:MXxy44WTMENOh5TI8+PCK2x6pMj47G
github.com/hyperledger/fabric-protos-go v0.3.0/go.mod h1:WWnyWP40P2roPmmvxsUXSvVI/CF6vwY1K1UFidnKBys=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec h1:drq6iuHjLc3H41zGfvljRZky45aLsWfc/J/lc52KjLY=
github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go v0.0.0-20230505123407-84f9ba1dc4ec/go.mod h1:Y4ClFGIk5nmTlFOtryAY+sC55tYCpA6YZItPaKwPY6s=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af h1:/DGxnlhN6Cg1PKj/5K01GUt4X1wN8nRVkZiJiQ05sCw=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b h1:ioSmXcO2r9+Sf7QbeaCQkWuTy5uHd+4u5CtFKLJhvRU=
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20240123083657-5d6ca326e01b/go.mod h1:JRplpKBeAvXjsBhOCCM/KvMRUbdDyhsAh80qbXzKc10=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down
26 changes: 22 additions & 4 deletions integration/deployment_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ CC_EP="OR('SampleOrg.member')" # note that we use .member as NodeOUs is disabled
NUM_FAILURES=0
NUM_TESTS=0

# downloads github.com/hyperledger/fabric-samples/asset-transfer-basic/chaincode-go
download_chaincode() {
# download destination
local samples_path=$1

git clone -n --depth=1 --filter=tree:0 https://github.com/hyperledger/fabric-samples "$samples_path"
cd "$samples_path" || { echo "$samples_path does not exist" ; exit 1; }
git sparse-checkout set --no-cone asset-transfer-basic/chaincode-go
git checkout
}

run_test() {

# install samples/chaincode/auction
Expand All @@ -42,9 +53,11 @@ run_test() {

# install something non-fpc
# following the official fabric docs at https://hyperledger-fabric.readthedocs.io/en/release-2.5/deploy_chaincode.html
CC_PATH="${FPC_PATH}/samples/deployment/test-network/fabric-samples/asset-transfer-basic/chaincode-go/"
local tmp_dir=$(mktemp -d -t fabric-samples-XXXXXXXXXX --tmpdir="${TMP_DIR}")
download_chaincode "${tmp_dir}"
CC_PATH="${tmp_dir}/asset-transfer-basic/chaincode-go/"
# jump to the basic chaincode sample and fetch deps
(cd ${CC_PATH} && GO111MODULE=on go mod vendor)
(cd "${CC_PATH}" && GO111MODULE=on go mod vendor)

CC_VER="0"
CC_SEQ="1"
Expand Down Expand Up @@ -110,8 +123,13 @@ say "Preparing Test with mixed concurrent chaincodes, FPC and non-FPC ..."
docker_clean ${ERCC_ID}
docker_clean example02

trap ledger_shutdown EXIT

# create tmp folder to store artefacts
TMP_DIR=$(mktemp -d -t tmp-XXXXXXXXXX --tmpdir="${SCRIPTDIR}")
trap cleanup SIGINT SIGTERM ERR EXIT
cleanup() {
rm -rf "${TMP_DIR}"
ledger_shutdown
}

para
say "Run test"
Expand Down
4 changes: 2 additions & 2 deletions samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
TOP = ..
include $(TOP)/build.mk

SAMPLES = application chaincode demos #deployment
SAMPLES = application chaincode demos deployment

build clean:
build test clean clobber:
$(foreach DIR, $(SAMPLES), $(MAKE) -C $(DIR) $@ || exit;)

2 changes: 1 addition & 1 deletion samples/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(TOP)/build.mk

SUB_DIRS = simple-cli-go simple-go

all build test clean clobber:
build test clean clobber:
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@ || exit ;)
2 changes: 1 addition & 1 deletion samples/chaincode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ include $(TOP)/build.mk

SUB_DIRS = auction auction-go echo echo-go kv-test kv-test-go

all build test clean clobber:
build test clean clobber:
$(foreach DIR, $(SUB_DIRS), $(MAKE) -C $(DIR) $@ || exit ;)
2 changes: 1 addition & 1 deletion samples/chaincode/simple-asset-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ git clone https://github.com/hyperledger/fabric-samples
cd $FPC_PATH/samples/deployment/test-network/fabric-samples
# no we pick a specific version here to have stable experience :)
git checkout -b "works" 98028c7
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.4 1.5.7 -s
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.9 1.5.12 -s
cd $FPC_PATH/samples/deployment/test-network
./setup.sh
```
Expand Down
12 changes: 12 additions & 0 deletions samples/deployment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0

TOP = ../..
include $(TOP)/build.mk

DEPLOYMENT_SAMPLES = test-network

build test clean clobber:
$(foreach DIR, $(DEPLOYMENT_SAMPLES), $(MAKE) -C $(DIR) $@ || exit;)

2 changes: 1 addition & 1 deletion samples/deployment/k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ If you have installed them somewhere else on your system, please set `FABIC_BIN_
For instance, you can download the binaries and use them by following the commands:
```bash
cd $FPC_PATH/samples/deployment/k8s
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.4 1.5.7 -d -s
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 2.5.9 1.5.12 -d -s
export FABRIC_BIN_DIR=$(pwd)/bin
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
value: /var/hyperledger/orderer/tls/server.key
- name: ORDERER_GENERAL_CLUSTER_ROOTCAS
value: "[/var/hyperledger/orderer/tls/ca.crt]"
image: hyperledger/fabric-orderer:2.5.4
image: hyperledger/fabric-orderer:2.5.9
name: orderer
ports:
- containerPort: 7050
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
value: /var/hyperledger/orderer/tls/server.key
- name: ORDERER_GENERAL_CLUSTER_ROOTCAS
value: "[/var/hyperledger/orderer/tls/ca.crt]"
image: hyperledger/fabric-orderer:2.5.4
image: hyperledger/fabric-orderer:2.5.9
name: orderer
ports:
- containerPort: 7050
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ spec:
value: /var/hyperledger/orderer/tls/server.key
- name: ORDERER_GENERAL_CLUSTER_ROOTCAS
value: "[/var/hyperledger/orderer/tls/ca.crt]"
image: hyperledger/fabric-orderer:2.5.4
image: hyperledger/fabric-orderer:2.5.9
name: orderer
ports:
- containerPort: 7050
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org1/org1-cli-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
configMapKeyRef:
name: chaincode-config
key: FPC_MRENCLAVE
image: hyperledger/fabric-tools:2.5.4
image: hyperledger/fabric-tools:2.5.9
name: cli
tty: true
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org1/org1-peer0-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
value: 0.0.0.0:9443
- name: CORE_METRICS_PROVIDER
value: prometheus
image: hyperledger/fabric-peer:2.5.4
image: hyperledger/fabric-peer:2.5.9
name: peer0
ports:
- containerPort: 7051
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org2/org2-cli-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
configMapKeyRef:
name: chaincode-config
key: FPC_MRENCLAVE
image: hyperledger/fabric-tools:2.5.4
image: hyperledger/fabric-tools:2.5.9
name: cli
tty: true
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org2/org2-peer0-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
value: 0.0.0.0:9443
- name: CORE_METRICS_PROVIDER
value: prometheus
image: hyperledger/fabric-peer:2.5.4
image: hyperledger/fabric-peer:2.5.9
name: peer0
ports:
- containerPort: 7051
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org3/org3-cli-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
configMapKeyRef:
name: chaincode-config
key: FPC_MRENCLAVE
image: hyperledger/fabric-tools:2.5.4
image: hyperledger/fabric-tools:2.5.9
name: cli
tty: true
volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion samples/deployment/k8s/org3/org3-peer0-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
value: 0.0.0.0:9443
- name: CORE_METRICS_PROVIDER
value: prometheus
image: hyperledger/fabric-peer:2.5.4
image: hyperledger/fabric-peer:2.5.9
name: peer0
ports:
- containerPort: 7051
Expand Down
5 changes: 3 additions & 2 deletions samples/deployment/test-network/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

**/packages/*
blockchain-explorer
blockchain-explorer/
fabric-samples/
.env
36 changes: 15 additions & 21 deletions samples/deployment/test-network/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,7 @@
TOP = ../../..
include $(TOP)/build.mk

ifeq ($(CC_ID),)
$(error CC_ID is not set)
endif
ifeq ($(CC_PATH),)
$(error CC_PATH is not set)
endif

build: ercc-container ecc-container

ercc-container:
make -C ${FPC_PATH}/ercc all docker

ecc-container:
if [ "${SGX_MODE}" = "HW" ]; then \
export HW_EXTENSION="-hw" ; \
fi && \
make -C ${CC_PATH} && \
make -C ${FPC_PATH}/ecc DOCKER_IMAGE=fpc/fpc-${CC_ID}$${HW_EXTENSION} DOCKER_ENCLAVE_SO_PATH=${CC_PATH}/_build/lib all docker

.PHONY: ercc-ecc-start
ercc-ecc-start:
if [ ! -z "${DOCKERD_FPC_PATH}" ]; then \
export SGX_CREDENTIALS_PATH="${DOCKERD_FPC_PATH}/integration/config/ias"; \
Expand All @@ -35,7 +17,19 @@ ercc-ecc-start:
SGX_DEVICE_PATH=$$(if [ -e "/dev/isgx" ]; then echo "/dev/isgx"; elif [ -e "/dev/sgx/enclave" ]; then echo "/dev/sgx/enclave"; else echo "none"; fi) && \
[ "$${SGX_DEVICE_PATH}" != "none" ] || ( echo "ERROR: SGX_MODE is HW but no sgx device found"; exit 1; ) \
fi && \
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} docker-compose up
env FPC_VERSION=${FPC_VERSION} ${DOCKER_COMPOSE} up -d

.PHONY: ercc-ecc-start
ercc-ecc-stop:
env CC_ID=${CC_ID} FPC_VERSION=${FPC_VERSION} docker-compose down
${DOCKER_COMPOSE} down

clean:
docker compose down -v
./fabric-samples/test-network/network.sh down || true
rm -rf blockchain-explorer fabric-samples .env
docker system prune --force
docker network prune --force
docker volume prune --force

test:
./test.sh
Loading

0 comments on commit c9650c2

Please sign in to comment.