Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ cscope.*
common/protos
internal/protos
coverage.out
vendor
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: 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
97 changes: 97 additions & 0 deletions commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ############################## Commands in order #######################################


# ################################### For CC-tools inside the fpc

# - Copy all chaincode files using the same way as simple-asset-go
# - replace the "CHAINCODE_ID" env with "CHAINCODE_PKG_ID" in main.go
# - Run `go get` inside the cc-tools-demo folder after putting it inside the fpc repo
# ------ There are huge problem with using FPC outside the FPC repository. Even go get doesn't work and you need to specify a certain version and there are conflicting packages-----------------'
# # - You have to add dummy implementation for the PurgePrivate data method in the MockStup of cc-tools but be careful you need to do it in the package installed inside the FPC dev env not your local
# # For example do: vim /project/pkg/mod/github.com/hyperledger-labs/cc-tools@v1.0.0/mock/mockstub.go and add this:
# # // PurgePrivateData ...
# # func (stub *MockStub) PurgePrivateData(collection, key string) error {
# # return errors.New("Not Implemented")
# # }.
# # A good idea is to use go mod vendor and download all go packages in the vendor directory and edit it one time there.
# # nano $FPC_PATH/vendor/github.com/hyperledger-labs/cc-tools/mock/mockstub.go
# # // PurgePrivateData ...
# # func (stub *MockStub) PurgePrivateData(collection, key string) error {
# # return errors.New("Not Implemented")
# # }

cd $FPC_PATH/samples/deployment/test-network
docker compose down

cd $FPC_PATH/samples/deployment/test-network/fabric-samples/test-network
./network.sh down
docker system prune
sleep 5

cd $FPC_PATH/samples/chaincode/cc-tools-demo/
export CC_NAME=fpc-cc-tools-demo
make

# - run docker images | grep fpc-cc-tools-demo to make sure of the image
# - complete the tutorial normally:
cd $FPC_PATH/samples/deployment/test-network
./setup.sh

cd $FPC_PATH/samples/deployment/test-network/fabric-samples/test-network
./network.sh up createChannel -ca -c mychannel
sleep 5

export CC_ID=cc-tools-demo
export CC_PATH="$FPC_PATH/samples/chaincode/cc-tools-demo/"
export CC_VER=$(cat "$FPC_PATH/samples/chaincode/cc-tools-demo/mrenclave")

cd $FPC_PATH/samples/deployment/test-network
./installFPC.sh
sleep 5
make ercc-ecc-start
sleep 5

# # prepare connections profile
cd $FPC_PATH/samples/deployment/test-network
./update-connection.sh

# # update the connection profile for external clients outside the fpc dev environment
cd $FPC_PATH/samples/deployment/test-network
./update-external-connection.sh

# make fpcclient
cd $FPC_PATH/samples/application/simple-cli-go
make

# export fpcclient settings
export CC_NAME=cc-tools-demo
export CHANNEL_NAME=mychannel
export CORE_PEER_ADDRESS=localhost:7051
export CORE_PEER_ID=peer0.org1.example.com
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_MSPCONFIGPATH=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_TLS_CERT_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
export CORE_PEER_TLS_ENABLED="true"
export CORE_PEER_TLS_KEY_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
export CORE_PEER_TLS_ROOTCERT_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export ORDERER_CA=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export GATEWAY_CONFIG=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml

sleep 5
# init our enclave
./fpcclient init $CORE_PEER_ID
sleep 5
# invoke the getSchema transaction which is implemented internally by cc-tools
./fpcclient invoke getSchema

########################## Some transactions to test ####################################
# sleep 5
# ./fpcclient invoke createNewLibrary "{\"name\":\"samuel\"}"
# sleep 5
# ./fpcclient invoke createAsset "{\"asset\":[{\"@assetType\":\"person\",\"id\":\"51027337023\",\"name\":\"samuel\"}]}"
# sleep 5
# ./fpcclient invoke createAsset "{\"asset\":[{\"@assetType\":\"book\", \"title\": \"Fairy tail\" ,\"author\":\"Martin\",\"currentTenant\":{\"@assetType\": \"person\", \"@key\": \"person:f6c10e69-32ae-5dfb-b17e-9eda4a039cee\"}}]}"
# sleep 5
# ./fpcclient invoke getBooksByAuthor "{\"authorName\":\"samuel\"}" # --> Fails as GetQueryResult is not implemented. I tried to implement it but the fabric implementation needs what's called handler and it's not ther


2 changes: 1 addition & 1 deletion ecc_go/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ECC_BUNDLE ?= $(ECC_BINARY)-bundle
build: ecc docker env

ecc: ecc_dependencies
ego-go build $(GOTAGS) -o $(ECC_BINARY) main.go
ego-go build $(GOTAGS) -o $(ECC_BINARY)
cp $(EGO_CONFIG_FILE) .
ego sign
ego uniqueid $(ECC_BINARY) > mrenclave
Expand Down
35 changes: 30 additions & 5 deletions ecc_go/chaincode/enclave_go/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ SPDX-License-Identifier: Apache-2.0
package enclave_go

import (
"fmt"

"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-private-chaincode/internal/utils"
pb "github.com/hyperledger/fabric-protos-go/peer"
"github.com/pkg/errors"
timestamp "google.golang.org/protobuf/types/known/timestamppb"
)

Expand Down Expand Up @@ -177,7 +180,11 @@ func (f *FpcStubInterface) SplitCompositeKey(compositeKey string) (string, []str
}

func (f *FpcStubInterface) GetQueryResult(query string) (shim.StateQueryIteratorInterface, error) {
panic("not implemented") // TODO: Implement
it, err := f.stub.GetQueryResult(query)
if err != nil {
return it, errors.Wrap(err, "stub.GetQueryResult call error")
}
return it, nil
}

func (f *FpcStubInterface) GetQueryResultWithPagination(query string, pageSize int32, bookmark string) (shim.StateQueryIteratorInterface, *pb.QueryResponseMetadata, error) {
Expand Down Expand Up @@ -233,7 +240,7 @@ func (f *FpcStubInterface) GetCreator() ([]byte, error) {
}

func (f *FpcStubInterface) GetTransient() (map[string][]byte, error) {
panic("not implemented") // TODO: Implement
return nil, nil
}

func (f *FpcStubInterface) GetBinding() ([]byte, error) {
Expand All @@ -248,10 +255,28 @@ func (f *FpcStubInterface) GetSignedProposal() (*pb.SignedProposal, error) {
return f.stub.GetSignedProposal()
}

func (f *FpcStubInterface) GetTxTimestamp() (*timestamp.Timestamp, error) {
panic("not implemented") // TODO: Implement
// GetTxTimestamp documentation can be found in interfaces.go
func (s *FpcStubInterface) GetTxTimestamp() (*timestamp.Timestamp, error) {
// hdr := &common.Header{}
// if err := proto.Unmarshal(s.proposal.Header, hdr); err != nil {
// return nil, fmt.Errorf("error unmarshaling Header: %s", err)
// }

// chdr := &common.ChannelHeader{}
// if err := proto.Unmarshal(hdr.ChannelHeader, chdr); err != nil {
// return nil, fmt.Errorf("error unmarshaling ChannelHeader: %s", err)
// }
// return chdr.GetTimestamp(), nil
println(timestamp.Now())
return timestamp.Now(), nil

}

func (f *FpcStubInterface) SetEvent(name string, payload []byte) error {
panic("not implemented") // TODO: Implement
if name == "" {
return errors.New("event name can not be empty string")
}
fmt.Println("Trying to set event name: ", name, "\n with payload: ", payload)
fmt.Println("NO event is bieng set as function is not implemented yet")
return nil
}
8 changes: 8 additions & 0 deletions ecc_go/enclave.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
"name": "CHAINCODE_PKG_ID",
"fromHost": true
},
{
"name": "FPC_ENABLED",
"fromHost": true
},
{
"name": "RUN_CCAAS",
"fromHost": true
},
{
"name": "FABRIC_LOGGING_SPEC",
"fromHost": true
Expand Down
61 changes: 39 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,49 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.29.1

require (
github.com/client9/misspell v0.3.4
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/golang/protobuf v1.5.3
github.com/hyperledger/fabric v1.4.0-rc1.0.20230405174026-695dd57e01c2
github.com/hyperledger-labs/cc-tools v1.0.0
github.com/hyperledger/fabric v2.1.1+incompatible
github.com/hyperledger/fabric-chaincode-go v0.0.0-20230228194215-b84622ba6a7a
github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-gateway v1.5.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-protos-go-apiv2 v0.3.3
github.com/hyperledger/fabric-sdk-go v1.0.1-0.20221020141211-7af45cede6af
github.com/maxbrunsfeld/counterfeiter/v6 v6.6.1
github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.3
golang.org/x/sync v0.5.0
golang.org/x/tools v0.14.0
google.golang.org/protobuf v1.33.0
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.34.1
gopkg.in/yaml.v2 v2.4.0
honnef.co/go/tools v0.4.3
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/IBM/idemix v0.0.2-0.20231107110441-534ea4193b8f // indirect
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/idemix/bccsp/types v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20231023164747-f3f972769504 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/cfssl v1.4.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containerd/containerd v1.7.13 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -69,22 +73,29 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsouza/go-dockerclient v1.10.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/envy v1.10.1 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gobuffalo/packr v1.30.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
Expand All @@ -93,24 +104,29 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand All @@ -125,6 +141,8 @@ require (
github.com/spf13/viper v1.10.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/sykesm/zap-logfmt v0.0.4 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/weppos/publicsuffix-go v0.5.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand All @@ -133,17 +151,16 @@ require (
github.com/zmap/zlint v0.0.0-20190806154020-fd021b4cfbeb // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading