Setup with Imported Weaver Components
In this document, we detail the steps using which you can bring up networks using the default configuration settings and by fetching pre-built Weaver interoperation modules, SDK libraries, and relay drivers from GitHub Package repositories. To customize these settings (e.g., hostnames, ports), refer to the Advanced Configuration page.
| Notes |
|---|
The default configuration is for a development setup, therefore all components are run on localhost, many within Docker containers. |
Follow the instructions below to build and run components followed by interoperation flows. These instructions have been tested on Ubuntu Linux (bash shell) and Mac OS. In general, they should work on any system and shell as long as the various dependencies have been installed and configured.
Prerequisites¶
Software¶
Before starting, make sure you have the following software installed on your host machine:
- Curl: install using package manager, like
apton Debian/Ubuntu Linux - Git: sample instructions
- Docker: sample instructions (Latest version)
- Docker-Compose: sample instructions (Version 2 or higher)
- Golang: sample instructions (Version 1.20 or higher)
- Java (JDK and JRE): sample instructions (Version 8)
- Node.js and NPM: sample instructions (Version 16 Supported)
- Yarn: sample instructions
- Rust: sample instructions
- To avoid errors during Weaver Relay compilation, update certain packages (on which the Weaver Relay is dependent) to their latest versions as follows:
Credentials¶
Make sure you have an SSH or GPG key registered in https://github.com to allow seamless cloning of repositories (at present, various setup scripts clone repositories using the https:// prefix but this may change to git@ in the future).
Create a personal access token with read:packages access in GitHub in order to use modules published in GitHub packages. Refer Creating a Personal Access Token for help.
Getting the Code and Documentation¶
Clone the cacti repository. The code to get a basic test network up and running and test data-sharing interoperation flows lies in the subfolder weaver/tests/network-setups, which should be your starting point, though the setups will rely on other parts of the repository, as you will find out in the instructions given on this page.
Securing Components¶
| Notes |
|---|
| The relays and drivers corresponding to the different test networks you will encounter below can be run with or without TLS enabled. But the default files used in the demonstrations assume that either all relays and drivers are TLS-enabled or none are. Therefore, you should determine at the outset whether or not you wish to run the entire set of components in TLS-enabled mode, and select appropriate commands in the provided instructions. |
Hyperledger Fabric Components¶
Using the sequence of instructions below, you can start two separate Fabric networks, each with a single channel and application contract (chaincode). You can also start an interoperation contract, a relay, and a driver acting on behalf of each network. You can build a Fabric CLI tool with which you can initialize both networks' ledgers with access control policies, foreign networks' security groups (i.e., membership providers' certificate chains), and some sample key-value pairs that can be shared during subsequent interoperation flows.
Fabric Network¶
The code for this lies in the weaver/tests/network-setups folder.
This folder contains code to create and launch networks network1 and network2 of identical specifications:
- Network: 1 peer, 1 peer CA, 1 ordering service node, 1 ordering service CA
- Single channel named
mychannel - One of the following contracts deployed on
mychannel, the choice depending on the interoperability mode you wish to test:simplestate(Data Sharing): supports simple transactions (Create,Read,Update,Delete) involving storage and lookup ofpairs. simplestatewithacl(Data Sharing): identical tosimplestatebut with extra security features to ensure that the Weaver infrastructure cannot be bypassed by a malicious client of the network.simpleasset(Asset Exchange): supports creation, modification, transfer, and deletion, as well as locking, unlocking, and claiming, of simple bonds and tokens (examples of non-fungible and fungible assets respectively).simpleassetandinterop(Asset Exchange): identical tosimpleassetbut where the locking, unlocking, and claiming logic is imported as a library in the chaincode rather than available in the common Fabric Interoperation Chaincode (a Weaver component).simpleassettransfer(Asset Exchange or Asset Transfer): augmentation ofsimpleassetwith asset pledging, claiming, and reclaiming features for cross-network transfers.
| Notes |
|---|
For new users, we recommend testing the Data Sharing feature first with the simplestate contract. To test the other modes, you can simply tear down the Fabric networks and restart them with the appropriate chaincodes installed. |
Follow the instructions below to build and launch the networks:
- Navigate to the
weaver/tests/network-setups/fabric/devfolder. - To spin up both network1 and network2 with the interoperation chaincode and the default
simplestatechaincode installed, run: - To launch the networks with a different application chaincode from the above list, run:
- To launch the networks with 2 organizations, each with a peer (this will enable more variation and experimentation, which you can attempt after testing interoperation protocols across basic network configurations), run:
| Notes |
|---|
If you do not wish to test Fabric-Fabric interoperation, you can choose to launch only one of the two networks along with its interoperation chaincode. For network1, run make start-interop-network1, and for network2, run make start-interop-network2 |
If you wish to enable end-to-end confidentiality by default in the interoperation modules that are deployed during network launch, set the environment variable E2E_CONFIDENTIALITY to true in the command line as follows: E2E_CONFIDENTIALITY=true make start-interop |
For more information, refer to the associated README.
Troubleshooting Tips:
- If you see any errors during the launches, re-check the prerequisites (software installations and credentials). Ensure your network connection is working. As a safe bet, you can retry after cleanup: kill and remove all Docker containers and associated volumes.
Fabric Client (fabric-cli)¶
The CLI is used to interact with a Fabric network, configure it and run chaincode transactions to record data on the channel ledger or query data. It is also used to interact with remote networks through the relay to trigger an interoperation flow for data request and acceptance.
The fabric-cli Node.js source code is located in the weaver/samples/fabric/fabric-cli folder and the Golang source code in the weaver/samples/fabric/go-cli folder.
Prerequisites¶
If you are using a Linux system, make sure that lib64 is installed.
| Notes |
|---|
For the Node.js version of the fabric-cli, the setup and running instructions below were tested with all Node.js versions from v11.14.0 to v14.17.3. |
Installation¶
You can install fabric-cli as follows (for both the Node.js and Golang versions):
- Navigate to the
weaver/samples/fabric/fabric-clifolder (for the Node.js version) or theweaver/samples/fabric/go-cli(for the Golang version) folder. - Create
.npmrcfrom template.npmrc.template, by replacing<personal-access-token>with yours created above.. - Run the following to install dependencies (for the Node.js version) or the executable (for the Golang version):
- Use the
fabric-cliexecutable in thebinfolder for subsequent actions.
Fabric Relay¶
The relay is a module acting on behalf of a network, enabling interoperation flows with other networks by communicating with their relays.
The code for this lies in the weaver/core/relay folder.
Building¶
Prerequisite: make sure Rust is already installed and that the cargo executable is in your system path (after installation of Rust, this should be available in $HOME/.cargo/bin); you can also ensure this by running source "$HOME/.cargo/env".
Build the generic (i.e., common to all DLTs) relay module as follows:
- Navigate to the
weaver/core/relayfolder. - Run the following:
- If you observe errors during the above compilation, update certain packages (on which the Weaver Relay is dependent) to their latest versions and recompile as follows:
Deployment¶
An instance or a relay can be run using a suitable configuration file. Samples are available in the weaver/core/relay/config folder.
Run a relay for network1 as follows:
- Navigate to the
weaver/core/relayfolder. - To launch the server without TLS, leave the configuration file
config/Fabric_Relay.tomlin its default state. Otherwise, edit it to set TLS flags for this relay and the other relays and drivers it will connect to in this demonstration as follows:. . cert_path="credentials/fabric_cert.pem" key_path="credentials/fabric_key" tls=true . . [relays] [relays.Corda_Relay] hostname="localhost" port="9081" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Corda_Relay2] hostname="localhost" port="9082" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Fabric_Relay2] hostname="localhost" port="9083" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . [drivers] [drivers.Fabric] hostname="localhost" port="9090" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . - To launch the server, simply run the following:
Run a relay for network2 as follows (do this only if you have launched both Fabric networks network1 and network2 and wish to test interoperation between them)
- Navigate to the
weaver/core/relayfolder. - To launch the server without TLS, leave the configuration file
config/Fabric_Relay2.tomlin its default state. Otherwise, edit it to set TLS flags for this relay and the other relays and drivers it will connect to in this demonstration as follows:. . cert_path="credentials/fabric_cert.pem" key_path="credentials/fabric_key" tls=true . . [relays] [relays.Corda_Relay] hostname="localhost" port="9081" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Corda_Relay2] hostname="localhost" port="9082" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Fabric_Relay] hostname="localhost" port="9080" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . [drivers] [drivers.Fabric] hostname="localhost" port="9095" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . - To launch the server, simply run the following:
For more information, see the relay README.
Fabric Driver¶
A driver is a DLT-specific plugin invoked by the relay while conveying external data queries to the local peer network and collecting a response with proofs. The Fabric driver is built as a Fabric client application on the fabric-network NPM package.
The code for this lies in the weaver/core/drivers/fabric-driver folder.
Configuring¶
In the weaver/core/drivers/fabric-driver folder, copy .env.template to .env and update CONNECTION_PROFILE to point to the connection profile of the Fabric network (e.g. <PATH-TO-WEAVER>/tests/network-setups/fabric/shared/network1/peerOrganizations/org1.network1.com/connection-org1.json)
Configure fabric-driver for network1 as follows:
- Navigate to the
weaver/core/drivers/fabric-driverfolder. - Create a
.envfile by copying.env.templateand setting suitable parameter values:- The
CONNECTION_PROFILEshould point to the absolute path of the connection profile fornetwork1.- For this exercise, specify the path
<PATH-TO-WEAVER>/tests/network-setups/fabric/shared/network1/peerOrganizations/org1.network1.com/connection-org1.json(you must specify the full absolute path here). <PATH-TO-WEAVER>here is the absolute path of theweaverfolder within your Cacti repository clone.
- For this exercise, specify the path
- If you wish to start the driver without TLS, set the following parameter values:
Otherwise, if you wish to start the driver with TLS enabled, set the following parameter values (replace
<PATH-TO-WEAVER>with the absolute path of theweaverfolder within your Cacti repository clone): - Leave the default values unchanged for the other parameters. The relay and driver endpoints as well as the network name are already specified.
- The
Building¶
Build the Fabric driver module as follows:
- Navigate to the
weaver/core/drivers/fabric-driverfolder. - Create
.npmrcfrom template.npmrc.template, by replacing<personal-access-token>with yours created above. - Run the following:
Running¶
Run a Fabric driver for network1 as follows:
- Navigate to the
weaver/core/drivers/fabric-driverfolder. - Run the following:
Run a Fabric driver for network2 as follows (do this only if you wish to test interoperation between the two Fabric networks network1 and network2)
- Navigate to the
weaver/core/drivers/fabric-driverfolder. - Run the following:
| Notes |
|---|
The variables we specified earlier in the .env for network1 are now passed in the command line. Alternatively, you can make a copy of the fabric-driver folder with a different name and create a separate .env file within it that contains links to the connection profile, relay, and driver for network2. |
Fabric IIN Agent¶
IIN Agent is a client of a member of a DLT network or security domain with special permissions to update security domain identities and configurations on the ledger via the network's interoperation module. The code for this lies in the weaver/core/identity-management/iin-agent folder. Navigate to the weaver/core/identity-management/iin-agent folder.
Building¶
Build the IIN Agent as follows:
- Navigate to the
weaver/core/drivers/fabric-driverfolder. - Create
.npmrcfrom template.npmrc.template, by replacing<personal-access-token>with yours created above. - Run the following:
Configuration¶
Ledger config file specifies ledger specific IIN Agent details such as identity and which network and organization to connect to.
-
To create config file for
Org1MSP's Fabric IIN Agent ofnetwork1, follow the steps:- Create copy of template config file for Fabric IIN Agent:
src/fabric-ledger/config.json.template, say to locationsrc/fabric-ledger/config-n1-org1.json. - Replace
<path-to-connection-profile>with<PATH-TO-WEAVER>/tests/network-setups/fabric/shared/network1/peerOrganizations/org1.network1.com/connection-org1.json, where replace<PATH-TO-WEAVER>with the absolute path of theweaverfolder within your Cacti repository clone. - Set
mspIdasOrg1MSP. - Set
agent.affiliationasorg1.department1.
- Create copy of template config file for Fabric IIN Agent:
-
To create config file for
Org2MSP's Fabric IIN Agent ofnetwork1, repeatStep 1with different name for config file, saysrc/fabric-ledger/config-n1-org2.json, and replaceorg1withorg2andOrg1MSPwithOrg2MSP. - To create config file for
Org1MSP's Fabric IIN Agent ofnetwork2, repeatStep 1with different name for config file, saysrc/fabric-ledger/config-n2-org1.json, and replacenetwork1withnetwork2. - To create config file for
Org2MSP's Fabric IIN Agent ofnetwork2, repeatStep 1with different name for config file, saysrc/fabric-ledger/config-n2-org2.json, and replacenetwork1withnetwork2,org1withorg2andOrg1MSPwithOrg2MSP.
Security Domain Configuration¶
Security Domain config file specifies the scope of security domain, which can be a channel in Fabric networks or list of nodes. File docker-testnet/configs/security-domain-config.json can be used for Weaver testnets.
DNS Configuration¶
To allow an IIN Agent's to be able to discover other IIN Agents, a config file for DNS is required. Create one dnsconfig.json by creating a copy of template dnsconfig.json.template, and replace the values with:
-
If Fabric networks are started with 1 org, and IIN Agent are to be started without TLS, use following values:
-
If Fabric networks are started with 1 org, and IIN Agent are to be started with TLS, use following values:
-
If Fabric networks are started with 2 orgs, and IIN Agent are to be started without TLS, use following values:
{ "network1": { "Org1MSP": { "endpoint": "localhost:9500", "tls": false, "tlsCACertPath": "" }, "Org2MSP": { "endpoint": "localhost:9510", "tls": false, "tlsCACertPath": "" } }, "network2": { "Org1MSP": { "endpoint": "localhost:9501", "tls": false, "tlsCACertPath": "" }, "Org2MSP": { "endpoint": "localhost:9511", "tls": false, "tlsCACertPath": "" } } } -
If Fabric networks are started with 2 orgs, and IIN Agent are to be started with TLS, use following values:
{ "network1": { "Org1MSP": { "endpoint": "localhost:9500", "tls": true, "tlsCACertPath": "../../relay/credentials/fabric_ca_cert.pem" }, "Org2MSP": { "endpoint": "localhost:9510", "tls": true, "tlsCACertPath": "../../relay/credentials/fabric_ca_cert.pem" } }, "network2": { "Org1MSP": { "endpoint": "localhost:9501", "tls": true, "tlsCACertPath": "../../relay/credentials/fabric_ca_cert.pem" }, "Org2MSP": { "endpoint": "localhost:9511", "tls": true, "tlsCACertPath": "../../relay/credentials/fabric_ca_cert.pem" } } }
| Notes |
|---|
The variables we specified earlier in the .env for network1 are now passed in the command line. Alternatively, you can make a copy of the fabric-driver folder with a different name and create a separate .env file within it that contains links to the connection profile, relay, and driver for network2. |
Environment Variables¶
To configure environment variables for Org1MSP's Fabric IIN Agent of network1, follow the steps:
- Create a copy of
.env.templateas.env, and update following values based on previous configuration file paths:IIN_AGENT_ENDPOINT=localhost:9500 MEMBER_ID=Org1MSP SECURITY_DOMAIN=network1 DLT_TYPE=fabric CONFIG_PATH=./src/fabric-ledger/config-n1-org1.json DNS_CONFIG_PATH=./dnsconfig.json SECURITY_DOMAIN_CONFIG_PATH=./docker-testnet/configs/security-domain-config.json WEAVER_CONTRACT_ID=interop AUTO_SYNC=true - If IIN Agent has to be started with TLS enabled, also update following values:
Deployment¶
Use the following steps to run Fabric IIN Agents in host machine:
- To start IIN Agent for
Org1MSPofnetwork1, run: - To start IIN Agent for
Org2MSPofnetwork1(only required if Fabric network was started with 2 orgs), run: - To start IIN Agent for
Org1MSPofnetwork2, run: - To start IIN Agent for
Org2MSPofnetwork2(only required if Fabric network was started with 2 orgs), run:
Corda Components¶
Using the sequence of instructions below, you can start a Corda network and run an application CorDapp on it. You can also run an interoperation CorDapp, a relay and a driver acting on behalf of the network. You can initialize the network's vault with access control policies, foreign networks' security groups (i.e., membership providers' certificate chains), and some sample state values that can be shared during subsequent interoperation flows.
Corda Network¶
The Corda networks' code lies in the weaver/tests/network-setups/corda folder. You can launch two separate Corda networks, namely Corda_Network and Corda_Network2. Each network runs the weaver/samples/corda/corda-simple-application CorDapp by default, which maintains a state named SimpleState containing a set of key-value pairs (of strings).
The following steps will, in addition to launching the network, build the CorDapp and a Corda client in weaver/samples/corda/corda-simple-application/client.
Running with Interoperation CorDapp from GitHub Packages¶
Follow the instructions below to build and launch the network:
- Navigate to the
weaver/tests/network-setups/cordafolder. - Create a copy of
github.properties.templateasgithub.properties. - Replace
<GITHUB email>with your GitHub email, and<GITHUB Personal Access Token>with the access token created above. - To spin up the Corda networks with the Interoperation CorDapps:
- Each consisting of 1 node and a notary (for data-transfer), run:
- Each consisting of 2 nodes and a notary (for asset-exchange/transfer), run:
- Each consisting of 3 nodes and a notary (for asset-exchange/transfer), run:
You should see the following message in the terminal:
The Corda nodes and notary may take a while (several minutes on memory-constrained systems) to start. If they start up successfully, you should something like the following for each network, though the number of node entries will depend on the profile you used to start the network with (replace<network-name> with Corda_Network or Corda_Network2):
PartyA node services started for network <network-name>
PartyB node services started for network <network-name>
PartyC node services started for network <network-name>
Notary node services started for network <network-name>
Corda Relay¶
The relay was built earlier, so you just need to use a different configuration file to start a relay for the Corda network.
Run a relay for Corda_Network as follows:
- Navigate to the
weaver/core/relayfolder. - (Make sure you've already built the relay by running
make.) - To launch the server without TLS, leave the configuration file
config/Corda_Relay.tomlin its default state. Otherwise, edit it to set TLS flags for this relay and the other relays and drivers it will connect to in this demonstration as follows:. . cert_path="credentials/fabric_cert.pem" key_path="credentials/fabric_key" tls=true . . [relays] [relays.Fabric_Relay] hostname="localhost" port="9080" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Fabric_Relay2] hostname="localhost" port="9083" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Corda_Relay2] hostname="localhost" port="9082" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . [drivers] [drivers.Corda] hostname="localhost" port="9099" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . - To launch the server, simply run the following:
If the relay starts up successfully, the following will be logged on your terminal:
Run a relay for Corda_Network2 as follows (do this only if you have launched both Corda networks Corda_Network and Corda_Network2 and wish to test interoperation between them)
- Navigate to the
weaver/core/relayfolder. - To launch the server without TLS, leave the configuration file
config/Corda_Relay2.tomlin its default state. Otherwise, edit it to set TLS flags for this relay and the other relays and drivers it will connect to in this demonstration as follows:. . cert_path="credentials/fabric_cert.pem" key_path="credentials/fabric_key" tls=true . . [relays] [relays.Fabric_Relay] hostname="localhost" port="9080" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Fabric_Relay2] hostname="localhost" port="9083" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" [relays.Corda_Relay] hostname="localhost" port="9081" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . [drivers] [drivers.Corda] hostname="localhost" port="9098" tls=true tlsca_cert_path="credentials/fabric_ca_cert.pem" . . - To launch the server, simply run the following:
If the relay starts up successfully, the following will be logged on your terminal:
Corda Driver¶
The code for this lies in the weaver/core/drivers/corda-driver folder.
Building Corda Driver¶
Build the Corda driver module as follows:
- Navigate to the
weaver/core/drivers/corda-driverfolder. - Create a copy of
github.properties.templateasgithub.properties. - Replace
<GITHUB email>with your GitHub email, and<GITHUB Personal Access Token>with the access token created above. - Run the following:
Configuring¶
Configure the drivers as follows (you can skip this if you wish to run the drivers without TLS):
- Navigate to the
weaver/core/drivers/corda-driverfolder and create a.envfile. - To run the drivers without TLS, set the following default values:
- To run the drivers with TLS, set the following values (replace
<PATH-TO-WEAVER>with the absolute path of theweaverfolder within your Cacti repository clone):
Running¶
Run a Corda driver as follows:
- Navigate to the
weaver/core/drivers/corda-driverfolder. - Run the following to start Corda driver for
Corda_Network: If the driver starts successfully, it should log the following message on your terminal: - Run the following to start Corda driver for
Corda_Network2: If the driver starts successfully, it should log the following message on your terminal:
Tear Down the Setup¶
Bring down the test network's components as follows:
- Simply terminate the various relays and drivers, which are running in the foreground in different terminals
- To bring down the running Corda network:
- Navigate to the
weaver/tests/network-setups/cordafolder. - Run the following:
- Navigate to the
- To bring down all the running Fabric networks:
- Navigate to the
weaver/tests/network-setups/fabric/devfolder. - Run the following:
- Navigate to the