Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade fabric test-network #770

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

munapower
Copy link
Contributor

What this PR does / why we need it:
It updates the fabric version used in the test-network samples directory to align with the docker versions
Which issue(s) this PR fixes:

Fixes #768

Special notes for your reviewer:

Does this PR introduce a user-facing changes and/or breaks backward compatability?:

@mbrandenburger
Copy link
Contributor

@munapower I've pushed a bunch of changes as promised. Can you please have a look?

I still would like to take the opportunity to rework the "Prepare FPC Containers" section and maybe even the "Interact with the FPC Chaincode" section. This could also go into a seperate PR - Let's discuss/

@mbrandenburger
Copy link
Contributor

@osamamagdy can you please check and test this PR as well?

@munapower
Copy link
Contributor Author

munapower commented Jul 23, 2024

@munapower I've pushed a bunch of changes as promised. Can you please have a look?

I still would like to take the opportunity to rework the "Prepare FPC Containers" section and maybe even the "Interact with the FPC Chaincode" section. This could also go into a seperate PR - Let's discuss/

@mbrandenburger I tried it, up to standing the network. Had to make changes to setup.sh and Readme for it to work .... the first part where we set echo and do a make build ... that doesn't work on my laptop ...

@@ -26,68 +27,52 @@ Use `CC_ID` and `CC_PATH` to define the FPC Chaincode you want to build.
cd $FPC_PATH/samples/deployment/test-network
export CC_ID=echo
export CC_PATH=$FPC_PATH/samples/chaincode/echo
# TODO this needs to be changed!
export CC_VER=$(cat CC_PATH/)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't work with me either. I also tried to type export CC_VER=$(echo $CC_PATH) as cat was erroring out No such file or directory but the make also failed with

# github.com/hyperledger/fabric-private-chaincode/ercc/attestation
attestation/pdo.go:16:19: undefined: pdo.NewEpidLinkableVerifier
attestation/pdo.go:17:19: undefined: pdo.NewEpidUnlinkableVerifier
make[1]: *** [Makefile:18: ercc] Error 1

Copy link
Contributor

@osamamagdy osamamagdy Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should point to the mrenclave file like the example here https://github.com/munapower/fabric-private-chaincode/tree/upgradeTestNetwork/samples/chaincode/simple-asset-go#start-the-test-network

And since the mrenclave should not be created at this point I think the command should be moved a little further

Copy link
Contributor

@osamamagdy osamamagdy Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After applying

cd $FPC_PATH/samples/deployment/test-network
export CC_ID=echo
export CC_PATH=$FPC_PATH/samples/chaincode/echo
make build
export CC_VER=$(cat $CC_PATH/mrenclave)

It failed with

docker  build --build-arg FPC_VERSION=main -t fpc/fpc-echo:main -f Dockerfile.fpc-app \
                --build-arg HW_EXTENSION=\
 		
ERROR: "docker buildx build" requires exactly 1 argument.
See 'docker buildx build --help'.

Usage:  docker buildx build [OPTIONS] PATH | URL | -

Start a build
make[1]: *** [Makefile:73: docker-fpc-app] Error 1
make[1]: Leaving directory '/project/src/github.com/hyperledger/fabric-private-chaincode/ecc'
make: *** [Makefile:22: ecc-container] Error 2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Makefile in the $FPC_PATH/samples/deployment/test-network is not working for any example I test. But the Makefile inside echo-go and simple-asset-go works.
It's noteworthy that even the fpc-echo-go image was built successfully and the ./installFPC worked for it but I wasn't able to initialize the enclave and faced this error

cd $FPC_PATH/samples/application/simple-go
CC_ID=echo ORG_NAME=Org1 go run . -withLifecycleInitEnclave
2024-07-23 21:52:51.870 UTC 0001 INFO [sdk-test] main -> --> Invoke LifecycleInitEnclave
2024-07-23 21:52:51.885 UTC 0002 FATA [sdk-test] main -> Failed to invoke LifecycleInitEnclave: Failed to query init enclave: Transaction processing for endorser [localhost:7051]: Endorser Client Status Code: (23) CHAINCODE_NAME_NOT_FOUND. Description: make sure the chaincode echo has been successfully defined on channel mychannel and try again: chaincode echo not found
exit status 1

if [ ! -d "${FABRIC_SAMPLES}/bin" ]; then
echo "Error: no fabric binaries found. Let's run 'network.sh prereq'"
pushd "${FABRIC_SAMPLES}/test-network"
./network.sh prereq
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before deleting my already present fabric_samples folder, I run ./setup.sh and the bin folder wasn't there but ./network.sh prereq doesn't work if you run it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osamamagdy be careful because setup is now using a newer commit of fabric samples ....

@mbrandenburger
Copy link
Contributor

mbrandenburger commented Jul 24, 2024

I was thinking that we maybe should remove anything related to "how to build" the fpc chaincode (and ercc) somewhere else .... and focus in the test-network tutorial on how to run the thing.

For instance, in could provide a "how to build" tutorial of the "auction-go" in https://github.com/hyperledger/fabric-private-chaincode/tree/main/samples/chaincode/auction-go and link it in the test network tutorial.

WDYT?

@munapower
Copy link
Contributor Author

I was thinking that we maybe should remove anything related to "how to build" the fpc chaincode (and ercc) somewhere else .... and focus in the test-network tutorial on how to run the thing.

For instance, in could provide a "how to build" tutorial of the "auction-go" in https://github.com/hyperledger/fabric-private-chaincode/tree/main/samples/chaincode/auction-go and link it in the test network tutorial.

WDYT?

I would just leave that to be able to deploy a chaincode they need to have these env variables set and the chaincode compiled. They can choose any of the chaincode samples to test on the network.

Copy link
Contributor

@mbrandenburger mbrandenburger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mbrandenburger mbrandenburger added the bug Something isn't working label Jul 25, 2024
Copy link
Contributor

@bvavala bvavala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have several comments and questions. Overall, it seems unusual to me that a minor fabric (samples) version upgrade requires such a substantial overhaul under the samples deployment section -- also considering that this is not tested in the CI.

samples/deployment/test-network/Makefile Outdated Show resolved Hide resolved
@@ -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}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to move from using a module to clone a repo?
What was wrong with the previous approach?

samples/deployment/test-network/README.md Outdated Show resolved Hide resolved
# Note: to see only log and not peer command output (which is all on stderr),
# run the script with '... 2>/dev/null' ..
CHANNEL_NAME=${CHANNEL_NAME:-mychannel}
FABRIC_SAMPLES=${FPC_PATH}/samples/deployment/test-network/fabric-samples
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right.
Isn't the fabric-samples module removed from this PR, and placed in a temp folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it is still cloned into the test-network directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, the tutorial uses the setup script to clone the fabric samples on demand. The integration test just does a spatial clone to get a single chaincode. While github allows to download individual files via curl, they don't allow to download entire folders.

Comment on lines +26 to +29
git clone https://github.com/hyperledger/fabric-samples "${FABRIC_SAMPLES}"
pushd "${FABRIC_SAMPLES}"
git checkout -b "works" 50b69f6
popd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now there is a download in a temp folder, and a clone in what was the original module folder.
Any reason for this added complexity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bvavala what temp directory? this was always like this, but before we had the user manually execute these instructions, now we have just automated it for them .... the git clone and git checkout were in the Readme before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See deployment-test.sh.
I see that the commands were in the repo, but now I'm wondering:

  • why do we have a git clone in a folder where the same repo is already supposed to be initialized as a module?
  • also, we have the module initialized at commit X, but we clone and checkout commit Y. Why so?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about having fabric-samples as git submodule. When working with the test-network is often happens that you want to wipe out the entire folder and start from scratch. Unfortunately, their test-network does not have a neat make clean to do that job. Well one could argue one could just use git to reset. I don't see any issue with a quick git clone. But maybe keeping fabric samples a submodule would be better. mhhhhh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bvavala @mbrandenburger but, for this PR we are just upgrading from what we currently had. I do think we can think about changing it, but I would do that in another PR ... Remember the objective for this PR is to upgrade the fabric network used in the test-network samples because it broke when we upgraded the docker version used in the project.

samples/deployment/test-network/setup.sh Outdated Show resolved Hide resolved
@mbrandenburger mbrandenburger force-pushed the upgradeTestNetwork branch 3 times, most recently from 65b1cfb to 4236ad9 Compare July 26, 2024 16:07
@bvavala
Copy link
Contributor

bvavala commented Aug 6, 2024

Just run the CI on main and it passes -- the PR needs some debug.

@mbrandenburger mbrandenburger marked this pull request as draft August 30, 2024 15:55
munapower and others added 2 commits September 3, 2024 15:56
- Simplify test-network setup
- Remove fpc ccaas scripts
- Use network.sh CCaaS install script
- Update Blockchain explorer setup
- Add test-network sample test

Signed-off-by: munapower <mmunaro@hotmail.com>
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
@mbrandenburger mbrandenburger changed the title Upgrade test network fabric version Upgrade fabric test-network Sep 3, 2024
@mbrandenburger mbrandenburger marked this pull request as ready for review September 3, 2024 14:33
@mbrandenburger
Copy link
Contributor

@munapower @bvavala Can you please have a look at the this PR again. As discussed today in the FPC community meeting today, it should be "feature" complete and works fine on my local linux box.

Copy link
Contributor Author

@munapower munapower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the small change to how to compile the chaincode everything that I could test of this sample on my M1 worked.

samples/deployment/test-network/README.md Show resolved Hide resolved
Signed-off-by: Marcus Brandenburger <bur@zurich.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible docker versions between dev containers and sample test networks
4 participants