-
Notifications
You must be signed in to change notification settings - Fork 4
Gateway
Rough notes for Gateway development
Enable the Gateway feature flag in core.yaml by adding the following:
peer:
gateway:
enabled: true
Alternatively, using yq:
docker run --rm -v "${PWD}":/workdir mikefarah/yq eval '.peer.gateway.enabled = true' --inplace core.yaml
microfab is the containerized Hyperledger Fabric runtime which is used in the IBP VSCode extension, which is a nice option for running a lightweight Gateway development environment.
There are currently no Fabric releases which includes Gateway support so you'll need to build the latest Fabric binaries.
With the latest Fabric code, create all the required binaries and configuration files by running the following commands:
make "release/linux-amd64"
mkdir -p "release/linux-amd64/config"
cp sampleconfig/*yaml "release/linux-amd64/config"
curl -sSL https://github.com/hyperledger/fabric-ca/releases/download/v1.4.9/hyperledger-fabric-ca-linux-amd64-1.4.9.tar.gz | tar xzf - -C "release/linux-amd64"
Update the core.yaml file to enable the Gateway. The ledger.snapshots.rootDir setting also needs to be updated to /opt/microfab/data/snapshots to work in microfab. Edit the file manually, or us the following yq command:
docker run --rm -v "${PWD}/release/linux-amd64/config":/workdir mikefarah/yq eval '.peer.gateway.enabled = true | .ledger.snapshots.rootDir = "/opt/microfab/data/snapshots"' --inplace core.yaml
Set the MICROFAB_CONFIG environment variable:
export MICROFAB_CONFIG='{
"endorsing_organizations":[
{
"name": "SampleOrg"
}
],
"channels":[
{
"name": "mychannel",
"endorsing_organizations":[
"SampleOrg"
]
}
]
}'
Start microfab:
docker run --name microfab --rm -v ${PWD}/chaincode:/chaincode:ro -v ${PWD}/release/linux-amd64:/opt/fabric:ro -p 8080:8080 -e MICROFAB_CONFIG ibmcom/ibp-microfab
Tip: you can follow the peer logs in another terminal using:
docker exec -it microfab /bin/tail -f /opt/microfab/data/peer-sampleorg/logs/peer.log
Create an environment file for the admin identity you want to use. For example, admin-sampleorg.env:
CORE_PEER_LOCALMSPID=SampleOrgMSP
CORE_PEER_MSPCONFIGPATH=/opt/microfab/data/admin-sampleorg
CORE_PEER_ADDRESS=sampleorgpeer-api.127-0-0-1.nip.io:8080
Then run peer commands using this environment file. For example:
docker exec -it --env-file admin-sampleorg.env microfab /opt/fabric/bin/peer channel list
docker exec -it --env-file admin-sampleorg.env microfab /opt/fabric/bin/peer lifecycle chaincode install /chaincode/fabcar.tgz
Or for moar orgs...
export MICROFAB_CONFIG='{
"ordering_organization": {
"name": "Orderer"
},
"endorsing_organizations":[
{
"name": "Org1"
},
{
"name": "Org2"
},
{
"name": "Org3"
}
],
"channels":[
{
"name": "mychannel",
"endorsing_organizations":[
"Org1",
"Org2",
"Org3"
]
}
],
"capability_level":"V2_0"
}'
To be continued...
- how to connect a gateway client!