Ledger Initialization
Once the two Fabric networks and the Corda network are up and running along with their associated relays and drivers, we must initialize states in those networks to prepare them for interoperation. For the Fabric networks, this involves recording state in the channel ledgers, and for the Corda network, in the nodes' vaults. The configuration and bootstrapping takes different form depending on what interoperability mode you wish to test.
Preparation for Data Sharing¶
Follow the below instructions to prepare your networks for data sharing tests.
Initializing the Fabric Networks¶
We use the Fabric CLI (fabric-cli) built earlier (in weaver/samples/fabric/fabric-cli for the Node.js version and weaver/samples/fabric/go-cli for the Golang version) for this purpose.
Configuring the Fabric CLI¶
During bootstrap, the ledgers in both network1 and network2 must be populated with the following information scoped by the interoperation chaincode:
- Access control policies governing requests from foreign networks
- Security group info for foreign networks (i.e., identities of network units and their membership providers' certificate chains)
- Verification policies for proofs supplied by foreign networks
Knowledge of foreign networks that must be configured in this stage is as follows:
network1has policies and security group info fornetwork2andCorda_Networknetwork2has policies and security group info fornetwork1andCorda_Network
(Corda_Network will be launched later.)
The ledgers must also be populated with sample key-value pairs for testing interoperation flows, scoped by the sample application chaincode.
Prepare fabric-cli for configuration suitably as follows.
- Navigate to the
weaver/samples/fabric/fabric-cli(for the Node.js version) or theweaver/samples/fabric/go-cli(for the Golang version) folder. - Create a
config.jsonfile by copying theconfig.template.jsonand setting (or adding or removing) suitable values:- For each network, the relay port and connection profile paths are specified using the keys
relayPortandconnProfilePathrespectively.- Replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone. - Otherwise, leave the default values unchanged.
- Replace
- For each network, the relay port and connection profile paths are specified using the keys
- Create a
chaincode.jsonfile by copying thechaincode.json.templateand leaving the default values unchanged. This file specified the arguments of the transaction to be locally invoked after fetching a remote view. - Create a
.envfile by copying.env.templateand setting the following parameter values:- If Relays and Drivers are deployed in the host machine:
- If Relays and Drivers are deployed in the Docker containers:
- In each case, replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone and<chaincode-name>with the name of the deployed chaincode, eithersimplestateorsimplestatewithacl. - If
simplestateis deployed, set<function-name>toCreate, and ifsimplestatewithaclif deployed, set<function-name>toCreateFromRemote. - Leave the default values unchanged for the other parameters.
- Run the following command:
| Notes |
|---|
If the CONFIG_PATH environment variable is omitted from .env, then you must also run:./bin/fabric-cli config set-file ./config.json |
Bootstrapping Network and Application State¶
Finally, to prepare both network1 and network2 for interoperation, run:
If Fabric networks were launched with 2 organizations, run:
Instead, if you launched only one of the two Fabric networks, run the following after replacing <network-id> with either network1 or network2, and <1/2> with number of organizations in the network:
Wait for at least 5 minutes before moving on to the next step (testing interoperability modes) to allow the networks' IIN Agents to sync their respective memberships (which occur after every 5 minutes by default).
Optionally, fabric-cli can be used to trigger sync manually by running following command:
./bin/fabric-cli configure membership --local-network=network1 --target-network=network2 --iin-agent-endpoint=localhost:9500
network2's membership (target-network) in network1 (local-network) using IIN Agent of Org1MSP as initiator. Similarly network1's membership can be synced to network2's ledger by running:
./bin/fabric-cli configure membership --local-network=network2 --target-network=network1 --iin-agent-endpoint=localhost:9501
Initializing the Corda Networks¶
Once the Corda networks are launched, the client applications (built earlier) needs to be exercised to generate network (ledger) state in preparation to test interoperation flows.
Bootstrapping Networks and Application States¶
Just as we did for either Fabric network, the Corda network ledger (or vault on each node) must be initialized with access control policies, verification policies, and security group information for the two Fabric networks. Further, sample key-value pairs need to be recorded so we can later share them with a Fabric network via an interoperation flow.
Bootstrap the Corda networks and application states as follows (the following instructions will initialize either or both Corda networks, depending on which of those are up and running):
- Navigate to the
weaver/samples/corda/corda-simple-applicationfolder. - Run the following:
- If Relays and Drivers are deployed in the host machine:
- If Relays and Drivers are deployed in the Docker containers:
Even upon successful execution (as indicated by the console output), you may see errors of the following form:
You can ignore these as they are transient errors that don't impact the operations.
[ERROR] 07:51:17.206 [epollEventLoopGroup-19-1] client.exceptionCaught - AMQ214015: Failed to execute connection life cycle listener java.util.concurrent.RejectedExecutionException: Task org.apache.activemq.artemis.utils.actors.ProcessorBase$$Lambda$34/681158875@666df796 rejected from java.util.concurrent.ThreadPoolExecutor@236f653f[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 6] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[?:1.8.0_402] ..........
Next Steps¶
The test networks are now configured and their ledgers are initialized. You can now run the data sharing flows.
Preparation for Asset Exchange¶
Follow the below instructions to prepare your networks for asset exchange tests.
Initializing the Fabric Networks¶
We use the Fabric CLI (fabric-cli) built earlier (in weaver/samples/fabric/fabric-cli for the Node.js version and weaver/samples/fabric/go-cli for the Golang version) for this purpose.
Configuring the Fabric CLI¶
The ledgers must be populated with sample key-value pairs for testing interoperation flows, scoped by the sample application chaincode.
Prepare fabric-cli for configuration suitably as follows.
- Navigate to the
weaver/samples/fabric/fabric-cli(for the Node.js version) or theweaver/samples/fabric/go-cli(for the Golang version) folder. - Create a
config.jsonfile by copying theconfig.template.jsonand setting (or adding or removing) suitable values:- For each network, the relay port and connection profile paths are specified using the keys
relayPortandconnProfilePathrespectively.- Replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone. - Set the
chaincodeattribute in each network to the deployed chaincode name (simpleassetorsimpleassetandinteroporsimpleassettransfer). - Otherwise, leave the default values unchanged.
- Replace
- For each network, the relay port and connection profile paths are specified using the keys
- Create a
.envfile by copying.env.templateand setting following parameter values:- If Relays and Drivers are deployed in the host machine:
- If Relays and Drivers are deployed in the Docker containers:
- In each case, replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone. - Leave the default values unchanged for the other parameters.
- Run the following command:
| Notes |
|---|
If the CONFIG_PATH environment variable is omitted from .env, then you must also run:./bin/fabric-cli config set-file ./config.json |
Bootstrapping Network and Application State¶
Finally, to prepare both network1 and network2 for interoperation, run:
Initializing the Corda Networks¶
Corda Network needs to be initialized with assets for asset-exchange to be performed: Bootstrap the Corda network and application states as follows:
- Navigate to the
weaver/samples/corda/corda-simple-applicationfolder. - Run the following:
- For
cordaSimpleApplicationapp, run:
- For
Initializing the Besu Networks¶
Let's assume that network1 can either manage NFT AliceERC721 or Hybrid AliceERC1155 tokens, while network2 manages fungible BobERC20 tokens. Here we use account 1 for Alice and account 2 for Bob in both neworks. To prepare Besu networks for asset exchange, navigate to the weaver/samples/besu/besu-cli and then follow the steps in next subsections.
Configuring the Besu-CLI¶
Create a config.json file by copying the config.template.json, keep the default values for managing AliceERC721 tokens in network1 and BobERC20 tokens in network2.
If you want to change the token type used in the network1 to Hybrid AliceERC1155 tokens, in config.json update tokenContract field with value "../simpleasset/build/contracts/AliceERC1155.json".
Bootstrapping Network and Application State¶
Finally, to prepare both network1 and network2 for interoperation, run:
- If you wish to test the default exchange (ERC-20 tokens for ERC-721 tokens), run::
This will issue
100 BobERC20tokens to each account innetwork2andAliceERC721token with id0toAliceand id1toBobinnetwork1. - Instead, if you wish to test Alice's exchange of ERC-1155 tokens for Bob's ERC-20 tokens, run:
This will issue
100 BobERC20tokens to each account innetwork2and100 AliceERC1155tokens with id0toAliceand id1toBobinnetwork1.
Next Steps¶
The test networks are now configured and their ledgers are initialized. You can now run the asset exchange flows.
Preparation for Asset Transfer¶
Follow the below instructions to prepare your networks for asset transfer tests.
Initializing the Fabric Networks¶
We use the Fabric CLI (fabric-cli) built earlier (in weaver/samples/fabric/fabric-cli for the Node.js version and weaver/samples/fabric/go-cli for the Golang version) for this purpose.
Configuring the Fabric CLI¶
During bootstrap, the ledgers in both network1 and network2 must be populated with the following information scoped by the interoperation chaincode:
- Access control policies governing requests from foreign networks
- Security group info for foreign networks (i.e., identities of network units and their membership providers' certificate chains)
- Verification policies for proofs supplied by foreign networks
Knowledge of foreign networks that must be configured in this stage is as follows:
network1has policies and security group info fornetwork2andCorda_Networknetwork2has policies and security group info fornetwork1andCorda_Network
(The Corda sample application doesn't support asset transfer yet, but there is no harm in including it above.) The ledgers must also be populated with sample key-value pairs for testing interoperation flows, scoped by the sample application chaincode.
Prepare fabric-cli for configuration suitably as follows.
- Navigate to the
weaver/samples/fabric/fabric-clifolder (the Go CLI doesn't support asset transfer yet). - Create a
config.jsonfile by copying theconfig.template.jsonand setting (or adding or removing) suitable values:- For each network, the relay port and connection profile paths are specified using the keys
relayPortandconnProfilePathrespectively.- Replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone. - Set the
chaincodeattribute in each network tosimpleassettransfer. - Set the
aclPolicyPrincipalTypeattribute innetwork2toca. - Otherwise, leave the default values unchanged.
- Replace
- For each network, the relay port and connection profile paths are specified using the keys
- Create
remote-network-config.jsonfile by copyingremote-network-config.json.template. Use default values if relays and drivers are deployed in the host machine; else if they are deployed in Docker, update as follows:- Update value for
relayEndpointfornetwork1asrelay-network1:9080. - Update value for
relayEndpointfornetwork2asrelay-network2:9083. - Update value for
relayEndpointforCorda_Networkasrelay-corda:9081. - Update value for
relayEndpointforCorda_Network2asrelay-corda2:9082. - Update value for
partyEndPointforCorda_Networkascorda_partya_1:10003. - Update value for
partyEndPointforCorda_Network2ascorda_network2_partya_1:10003.
- Update value for
- Create
chaincode.jsonfile by copyingchaincode.json.template. Keep the default values unchanged. - Create a
.envfile by copying.env.templateand setting the following parameter values:- If Relays and Drivers are deployed in the host machine:
- If Relays and Drivers are deployed in the Docker containers:
- In each case, replace
<PATH-TO-WEAVER>with the absolute path location of theweaverfolder within your Cacti repository clone. - Leave the default values unchanged for the other parameters.
- Run the following command:
| Notes |
|---|
If the CONFIG_PATH environment variable is omitted from .env, then you must also run:./bin/fabric-cli config set-file ./config.json |
Bootstrapping Network and Application State¶
Create appropriate access control and verification policies for network1 and network2 by running:
./bin/fabric-cli configure create all --local-network=network1
./bin/fabric-cli configure create all --local-network=network2
Load access control and verification policies onto the ledgers of network1 and network2 by running (replace <1/2> with number of organizations in the network):
./bin/fabric-cli configure network --local-network=network1 --num-orgs=<1/2>
./bin/fabric-cli configure network --local-network=network2 --num-orgs=<1/2>
Wait for at least 5 minutes before moving on to the next step (testing interoperability modes) to allow the networks' IIN Agents to sync their respective memberships (which occur after every 5 minutes by default).
Optionally, fabric-cli can be used to trigger sync manually by running following command:
./bin/fabric-cli configure membership --local-network=network1 --target-network=network2 --iin-agent-endpoint=localhost:9500
network2's membership (target-network) in network1 (local-network) using IIN Agent of Org1MSP as initiator. Similarly network1's membership can be synced to network2's ledger by running:
./bin/fabric-cli configure membership --local-network=network2 --target-network=network1 --iin-agent-endpoint=localhost:9501
Initialize bond and token asset states and ownerships on the network1 ledger by running the following (this step will also create a user alice in network1 and a user bob in network2):
Initializing the Corda Networks¶
Once the Corda networks (Corda_Network and Corda_Network2) are launched, the client applications (built earlier) needs to be exercised to generate ledger state in both exporting/source and importing/destination networks in preparation to test asset transfer interoperation flows.
Bootstrapping Networks and Application States¶
The Corda network ledger (or vault on each node) must be initialized with access control policies, verification policies, and security group information for the other networks (two Fabric networks and other Corda network).
Bootstrap the Corda networks and application states as follows (the following instructions will initialize either or both Corda networks, depending on which of those are up and running):
- Navigate to the
weaver/samples/corda/corda-simple-applicationfolder. - Run the following:
Use default values in
cp clients/src/main/resources/config/remote-network-config.json.template clients/src/main/resources/config/remote-network-config.jsonremote-network-config.jsonif relays and drivers are deployed in the host machine; else if they are deployed in Docker, update as follows:- Update value for
relayEndpointfornetwork1asrelay-network1:9080. - Update value for
relayEndpointfornetwork2asrelay-network2:9083. - Update value for
relayEndpointforCorda_Networkasrelay-corda:9081. - Update value for
relayEndpointforCorda_Network2asrelay-corda2:9082. - Update value for
partyEndPointforCorda_Networkascorda_partya_1:10003. - Update value for
partyEndPointforCorda_Network2ascorda_network2_partya_1:10003.
- Update value for
- Run the following:
- If Relays and Drivers are deployed in the host machine:
- If Relays and Drivers are deployed in the Docker containers:
Even upon successful execution (as indicated by the console output), you may see errors of the following form:
You can ignore these as they are transient errors that don't impact the operations.
[ERROR] 07:51:17.206 [epollEventLoopGroup-19-1] client.exceptionCaught - AMQ214015: Failed to execute connection life cycle listener java.util.concurrent.RejectedExecutionException: Task org.apache.activemq.artemis.utils.actors.ProcessorBase$$Lambda$34/681158875@666df796 rejected from java.util.concurrent.ThreadPoolExecutor@236f653f[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 6] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[?:1.8.0_402] ..........
Next Steps¶
The test networks are now configured and their ledgers are initialized. You can now run the asset transfer flows.