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

Update Commercial Paper to v2.0 Lifecycle #109

Merged
merged 2 commits into from
Feb 11, 2020

Conversation

mbwhite
Copy link
Member

@mbwhite mbwhite commented Jan 27, 2020

@mbwhite mbwhite force-pushed the update-cp-lifecycle branch 12 times, most recently from 89a6d18 to 4820b3f Compare January 29, 2020 10:26
@mbwhite mbwhite changed the title Update Commercial Paper to v2.0 Lifecycle... (WIP - Do Not Merge) Update Commercial Paper to v2.0 Lifecycle Jan 29, 2020
@mbwhite mbwhite changed the title Update Commercial Paper to v2.0 Lifecycle Update Commercial Paper to v2.0 Lifecycle (only merge when docs are ready) Jan 29, 2020
Copy link
Contributor

@nikhil550 nikhil550 left a comment

Choose a reason for hiding this comment

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

I was able to use the new lifecycle commands, but was not able to use the scripts that set the env variables. I have started writing the tutorial using env variables instead. Can switch over if the scripts work. Not that the script also needs to set a path the the config and binary folders in the fabric samples. Otherwise I was getting an order version of the peer binaries.

commercial-paper/README.md Outdated Show resolved Hide resolved
commercial-paper/README.md Show resolved Hide resolved
commercial-paper/roles/network-starter.sh Outdated Show resolved Hide resolved
commercial-paper/README.md Show resolved Hide resolved
commercial-paper/README.md Outdated Show resolved Hide resolved
commercial-paper/README.md Outdated Show resolved Hide resolved
commercial-paper/README.md Outdated Show resolved Hide resolved
commercial-paper/roles/network-starter.sh Outdated Show resolved Hide resolved
commercial-paper/README.md Show resolved Hide resolved
commercial-paper/README.md Outdated Show resolved Hide resolved
@nikhil550
Copy link
Contributor

nikhil550 commented Feb 4, 2020

In the process of updating the tutorial, I am finding that we ask users to go back and forth between a lot of terminals. As part of making it easier on the user, I think we need to move the scripts setting the environment variables to to the organizatation/magnetocorp and organizations/digibank folder respectively. That way users can change into those folders and set the environment without any additional changes. That would also allow you to more the network starter and network stop commands out of the roles folder and into the main commercial paper repo.

I made those changes on my own branch (updated after latest run through): https://github.com/nikhil550/fabric-samples/tree/update-cp-lifecycle/commercial-paper

.gitignore Outdated Show resolved Hide resolved
commercial-paper/README.md Show resolved Hide resolved
commercial-paper/README.md Outdated Show resolved Hide resolved
cd fabric-samples/commercial-paper
```

This `README.md` file is in the `commercial-paper` directory, the source code for client applications and the contracts ins in the `organization` directory, and some helper scripts are in the `roles` directory.

## Running the Infrastructure

In one console window, run the `./roles/network-starter.sh` script; this will start the basic infrastructure and also start monitoring all the docker containers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "and also start monitoring all the docker containers." since the script no longer does this.

docker exec cliMagnetoCorp peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name papercontract -c '{"Args":["org.papernet.commercialpaper:instantiate"]}' --waitForEvent
Then when you package the contract, use this variation of the command to specify language
```
peer lifecycle chaincode package cp.tar.gz --lang golang --path /opt/gopath/src/github.com/contract-go --label cp_0
Copy link
Contributor

Choose a reason for hiding this comment

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

The path should be ./contract-go


```
cd fabric-samples/commercial-paper
source <(./roles/magnetocorp.sh)
Copy link
Contributor

Choose a reason for hiding this comment

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

I got this to work, but I need to use the command source roles/magnetcorp.sh instead, and make some changes to the script. I am on mac.

### Install and Instantiate the contract
```
cd fabric-samples/commercial-paper
source <(./roles/digibank.sh)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.


echo "Suggest that you change to this dir> cd ${DIR}/organization/magnetocorp/"
env | sort | comm -1 -3 /tmp/env.orig - | sed -E 's/(.*)=(.*)/export \1="\2"/'
rm /tmp/env.orig
Copy link
Contributor

Choose a reason for hiding this comment

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

Needed to add this line at the bottom to get this to work.
cd "${DIR}/../commercial-paper"

parsePeerConnectionParameters 1 2
export PEER_PARMS="${PEER_CONN_PARMS##*( )}"
# set the fabric config path
export FABRIC_CFG_PATH="${DIR}/../config"
Copy link
Contributor

Choose a reason for hiding this comment

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

Needed to add the path directory to this script to get it to work
export PATH="${DIR}/../bin:${PWD}:$PATH"

`fabric-samples/commercial-paper/` directory

`./roles/digibank.sh`
This is running as *Digibank*;

You can now run the applications to buy and redeem the paper. Change to either the
`commercial-paper/organization/digibank/application` directory or `commercial-paper/organization/digibank/application-java`
Copy link
Contributor

Choose a reason for hiding this comment

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

I would say something about cleaning the network at the bottom

Clean up

When you are finished using the Fabric test network and the commercial paper smart contract and applications, you can use the following command to clean up the network:

./roles/network-clean.sh 

# Exit on first error, print all commands.
set -ev
set -o pipefail

Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the identity artifacts as well
rm -rf organization/digibank/identity/user/balaji/wallet/*
rm -rf organization/magnetocorp/identity/user/isabella/wallet/*

@mbwhite
Copy link
Member Author

mbwhite commented Feb 5, 2020

In the process of updating the tutorial, I am finding that we ask users to go back and forth between a lot of terminals. As part of making it easier on the user, I think we need to move the scripts setting the environment variables to to the organizatation/magnetocorp and organizations/digibank folder respectively. That way users can change into those folders and set the environment without any additional changes. That would also allow you to more the network starter and network stop commands out of the roles folder and into the main commercial paper repo.

I made those changes on my own branch (updated after latest run through): https://github.com/nikhil550/fabric-samples/tree/update-cp-lifecycle/commercial-paper

Yes agree with moving those

@mbwhite mbwhite force-pushed the update-cp-lifecycle branch 2 times, most recently from fd33c6e to 6056e67 Compare February 5, 2020 11:35
@mbwhite mbwhite changed the title Update Commercial Paper to v2.0 Lifecycle (only merge when docs are ready) Update Commercial Paper to v2.0 Lifecycle Feb 6, 2020
@@ -14,16 +14,13 @@ set -o pipefail
# Where am I?
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

docker kill cliDigiBank cliMagnetoCorp logspout || true
./teardown.sh || true
./start.sh || _exit "Failed to start Fabric"
cd "${DIR}/../test-network/"

Copy link
Contributor

Choose a reason for hiding this comment

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

Clean the wallets too

rm -rf organization/digibank/identity/user/balaji/wallet/*
rm -rf organization/magnetocorp/identity/user/isabella/wallet/*

set -o pipefail

# Where am I?
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
Copy link
Contributor

Choose a reason for hiding this comment

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

should be

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
- move to using the test-network
- updating README.md to include commands to use v2.0 lifecylce
- update Contracts and Applications to use 2.0 libraries

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
Copy link

@sstone1 sstone1 left a comment

Choose a reason for hiding this comment

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

LGTM

@nikhil550
Copy link
Contributor

Corresponding tutorial update: hyperledger/fabric#610

@pamandrejko
Copy link

pamandrejko commented Feb 10, 2020

@mbwhite When I checkout this PR and run ./network-starter.sh, it fails with:

set -o pipefail

# Where am I?
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
 cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd 
 dirname "${BASH_SOURCE[0]}" 

export FABRIC_CFG_PATH="${DIR}/../config"

cd "${DIR}/../test-network/"
./network-starter.sh: line 19: cd: /Users/pamaibm.com/fabric-samples/fabric-samples/../test-network/: No such file or directory

Nik says this line:
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

needs to be
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

@mbwhite mbwhite merged commit b89ee34 into hyperledger:master Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants