Skip to content

Commit 22299ef

Browse files
committed
feat(weaver): weaver fabric driver connector implementation
Signed-off-by: Carlos Amaro <[email protected]>
1 parent 56e955d commit 22299ef

File tree

150 files changed

+21939
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+21939
-66
lines changed

packages/cactus-plugin-ccmodel-hephaestus/src/main/typescript/plugin-ccmodel-hephaestus.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ export class CcModelHephaestus implements ICactusPlugin, IPluginWebService {
260260
private createReceiptFromRunTxReqWithTxId(
261261
data: IRunTxReqWithTxId,
262262
): FabricV2TxReceipt {
263+
if (!data.request.signingCredential) {
264+
throw new Error(
265+
`Cannot create FabricV2TxReceipt if signingCredential is missing in IRunTxReqWithTxId`,
266+
);
267+
}
263268
return {
264269
caseID: this.caseID,
265270
blockchainID: LedgerType.Fabric2,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CONNECTION_PROFILE=path_to_connection_profile
2+
RELAY_ENDPOINT=localhost:9080
3+
RELAY_TLS=false
4+
RELAY_TLSCA_CERT_PATH=path_to_tls_ca_cert_pem_for_relay
5+
DRIVER_ENDPOINT=localhost:9090
6+
DRIVER_TLS=false
7+
DRIVER_TLS_CERT_PATH=path_to_tls_cert_pem_for_driver
8+
DRIVER_TLS_KEY_PATH=path_to_tls_key_pem_for_driver
9+
NETWORK_NAME=network1
10+
DRIVER_CONFIG=
11+
INTEROP_CHAINCODE=interop
12+
MOCK=false
13+
DB_PATH=driverdbs
14+
WALLET_PATH=
15+
DEBUG=true
16+
LEVELDB_LOCKED_MAX_RETRIES=
17+
LEVELDB_LOCKED_RETRY_BACKOFF_MSEC=
18+
ENABLE_MONITOR=false
19+
MONITOR_SYNC_PERIOD=
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.env
2+
wallet-network1/*.id
3+
!wallet-network1/relay.id
4+
wallet-network2/*.id
5+
!wallet-network2/relay.id
6+
driverdbs

packages/cactus-plugin-ledger-connector-fabric/README.md

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
- [4.3.1. response.type.ts](#431-responsetypets)
3030
- [4.3.2. data-fetcher.ts](#432-data-fetcherts)
3131
- [4.3.3. metrics.ts](#433-metricsts)
32-
- [5. Contributing](#5-contributing)
33-
- [6. License](#6-license)
34-
- [7. Acknowledgments](#7-acknowledgments)
32+
- [5. Deploying Fabric Driver for Weaver](#5-deploying-fabric-driver-for-weaver)
33+
- [5.1 Setup](#51-setup)
34+
- [5.1.1 Enabling TLS](#511-enabling-tls)
35+
- [5.1.2 Environment variables](#512-environment-variables)
36+
- [5.2 Running](#52-running)
37+
- [6. Contributing](#6-contributing)
38+
- [7. License](#7-license)
39+
- [8. Acknowledgments](#8-acknowledgments)
3540

3641

3742
## 1. Usage
@@ -688,14 +693,67 @@ This file contains functions encasing the logic to process the data points
688693
#### 4.3.3. metrics.ts
689694
This file lists all the prometheus metrics and what they are used for.
690695

691-
## 5. Contributing
696+
## 5. Deploying Fabric Driver for Weaver
697+
### 5.1 Setup
698+
699+
Create a `.env` file using `.env.template` as the base and setting suitable environment variable values (see [here](#512-environment-variables)) and `config.json` files need to be checked and updated to match the network and relay that it will be connecting to.
700+
The .env contains information related to the network and relay. The config.json contains information about the ca admin, user and its org, that is used when connecting to the network.
701+
702+
#### 5.1.1 Enabling TLS
703+
704+
If the relay is TLS-enabled, set the following values in the `.env`:
705+
```
706+
RELAY_TLS=true
707+
RELAY_TLSCA_CERT_PATH=path_to_tls_ca_cert_pem_for_relay
708+
```
709+
- `path_to_tls_ca_cert_pem_for_relay` should be set to CA certificate file path
710+
711+
To enforce secure communication over TLS with your driver, set the following values in the `.env`:
712+
```
713+
DRIVER_TLS=true
714+
DRIVER_TLS_CERT_PATH=path_to_tls_cert_pem_for_driver
715+
DRIVER_TLS_KEY_PATH=path_to_tls_key_pem_for_driver
716+
```
717+
- `path_to_tls_cert_pem_for_driver` should be set to driver's TLS certificate file path
718+
- `path_to_tls_key_pem_for_driver` should be set to driver's TLS private key file path
719+
720+
#### 5.1.2 Environment variables
721+
722+
The connection profile is required to set up the required material to communicate with the network. This should be supplied with the `CONNECTION_PROFILE` environment variable (ex: CONNECTION_PROFILE=path/to/con_profile.json)
723+
724+
`<Hostname>:<Port>` for connecting relay: `RELAY_ENDPOINT` (ex: RELAY_ENDPOINT=localhost:9081 )
725+
726+
Boolean for when to use mocked fabric communication: `MOCK` (ex: MOCK=true)
727+
728+
`<Hostname>:<Port>` for the driver to be run on: `DRIVER_ENDPOINT` (ex: DRIVER_ENDPOINT=localhost:9093) (Not required for docker)
729+
730+
Can pass in a variable 'local' for working with fabric and docker: `local` (ex: local=false)
731+
732+
Can pass in a config file for the driver to be run with: `DRIVER_CONFIG` (ex: DRIVER_CONFIG=./config.json)
733+
734+
`INTEROP_CHAINCODE` stores the name of the interop chaincode installed.
735+
736+
`DB_PATH` stores the path hosting the database files containing the event subscription information.
737+
738+
`WALLET_PATH` stores the path hosting the user wallets to access a network.
739+
740+
NOTE: When specifying ensure that they match the config that the relay is using.
741+
742+
### 5.2 Running
743+
Running the server: `yarn start-fabric-weaver-driver`
744+
745+
Note: Can also be run in mocked mode by setting environment variable `MOCK=true`
746+
747+
748+
749+
## 6. Contributing
692750

693751
We welcome contributions to Hyperledger Cactus in many forms, and there’s always plenty to do!
694752

695753
Please review [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.
696754

697-
## 6. License
755+
## 7. License
698756

699757
This distribution is published under the Apache License Version 2.0 found in the [LICENSE](../../LICENSE) file.
700758

701-
## 7. Acknowledgments
759+
## 8. Acknowledgments
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: v2
2+
clean: true
3+
plugins:
4+
- local: protoc-gen-es
5+
out: src/main/typescript/generated/protos/
6+
opt: target=ts
7+
strategy: directory
8+
- local: protoc-gen-connect-es
9+
out: src/main/typescript/generated/protos/
10+
opt:
11+
- target=ts
12+
- js_import_style=module
13+
strategy: directory
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: v2
2+
modules:
3+
- path: src/main/protos/driver-protos
4+
- path: src/main/protos/fabric-protos
5+
lint:
6+
use:
7+
- STANDARD
8+
except:
9+
- PACKAGE_VERSION_SUFFIX
10+
enum_zero_value_suffix: _UNSPECIFIED
11+
rpc_allow_same_request_response: true
12+
rpc_allow_google_protobuf_empty_requests: true
13+
rpc_allow_google_protobuf_empty_responses: true
14+
service_suffix: Service
15+
breaking:
16+
use:
17+
- FILE
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"admin":{
3+
"name":"admin",
4+
"secret":"adminpw"
5+
},
6+
"relay": {
7+
"name":"relay",
8+
"affiliation":"org1.department1",
9+
"role": "client",
10+
"attrs": [{ "name": "relay", "value": "true", "ecert": true }]
11+
},
12+
"mspId":"Org1MSP",
13+
"caUrl":""
14+
}

packages/cactus-plugin-ledger-connector-fabric/package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
"name": "Peter Somogyvari",
3434
"email": "[email protected]",
3535
"url": "https://accenture.com"
36+
},
37+
{
38+
"name": "Carlos Amaro",
39+
"email": "[email protected]",
40+
"url": "https://accenture.com"
3641
}
3742
],
3843
"main": "dist/lib/main/typescript/index.js",
@@ -43,8 +48,10 @@
4348
"dist/*"
4449
],
4550
"scripts": {
51+
"start-fabric-weaver-driver": "node ./dist/lib/main/typescript/plugin-ledger-connector-fabric-cli.js",
4652
"codegen": "yarn run --top-level run-s 'codegen:*'",
4753
"codegen:openapi": "npm run generate-sdk",
54+
"codegen:proto": "buf generate --verbose",
4855
"generate-sdk": "run-p 'generate-sdk:*'",
4956
"generate-sdk:go": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g go -o ./src/main/go/generated/openapi/go-client/ --git-user-id hyperledger --git-repo-id $(echo $npm_package_name | replace @hyperledger/ \"\" -z)/src/main/go/generated/openapi/go-client --package-name $(echo $npm_package_name | replace @hyperledger/ \"\" -z) --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
5057
"generate-sdk:kotlin": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin -o ./src/main/kotlin/generated/openapi/kotlin-client/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
@@ -56,14 +63,21 @@
5663
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
5764
},
5865
"dependencies": {
66+
"@bufbuild/protobuf": "2.2.2",
67+
"@connectrpc/connect": "2.0.0",
68+
"@connectrpc/connect-express": "2.0.0",
69+
"@connectrpc/connect-node": "2.0.0",
70+
"@connectrpc/protoc-gen-connect-es": "1.6.1",
5971
"@fidm/x509": "1.2.1",
72+
"@hyperledger/cacti-weaver-protos-js": "2.1.0",
6073
"@hyperledger/cactus-common": "2.1.0",
6174
"@hyperledger/cactus-core": "2.1.0",
6275
"@hyperledger/cactus-core-api": "2.1.0",
6376
"axios": "1.8.4",
6477
"bl": "6.1.0",
6578
"bn.js": "4.12.0",
6679
"dockerode": "3.3.0",
80+
"dotenv": "17.2.3",
6781
"elliptic": "6.6.1",
6882
"express": "5.1.0",
6983
"fabric-ca-client": "2.5.0-snapshot.23",
@@ -72,11 +86,14 @@
7286
"fabric-protos": "2.5.0-snapshot.23",
7387
"fast-safe-stringify": "2.1.1",
7488
"form-data": "4.0.0",
89+
"google-protobuf": "3.21.2",
7590
"http-errors": "2.0.0",
7691
"http-status-codes": "2.1.4",
92+
"http2": "^3.3.7",
7793
"joi": "17.13.3",
7894
"json5": "2.2.3",
7995
"jsrsasign": "11.0.0",
96+
"level": "8.0.0",
8097
"lodash": "4.17.21",
8198
"long": "5.2.3",
8299
"multer": "1.4.5-lts.1",
@@ -99,6 +116,10 @@
99116
"ws-identity-client": "1.0.2"
100117
},
101118
"devDependencies": {
119+
"@bufbuild/buf": "1.47.2",
120+
"@bufbuild/protoc-gen-es": "2.2.2",
121+
"@grpc/grpc-js": "1.13.3",
122+
"@grpc/proto-loader": "0.7.13",
102123
"@hyperledger/cactus-plugin-keychain-memory": "2.1.0",
103124
"@hyperledger/cactus-test-tooling": "2.1.0",
104125
"@types/bn.js": "5.1.0",
@@ -107,6 +128,7 @@
107128
"@types/elliptic": "6.4.16",
108129
"@types/express": "5.0.1",
109130
"@types/fs-extra": "11.0.4",
131+
"@types/google-protobuf": "3.15.12",
110132
"@types/http-errors": "2.0.4",
111133
"@types/jsrsasign": "8.0.13",
112134
"@types/lodash": "4.14.172",
@@ -118,7 +140,9 @@
118140
"@types/uuid": "10.0.0",
119141
"body-parser": "1.20.3",
120142
"fs-extra": "11.2.0",
143+
"grpc_tools_node_protoc_ts": "5.3.3",
121144
"internal-ip": "6.2.0",
145+
"protobufjs": "7.2.5",
122146
"socket.io": "4.6.2",
123147
"ws-wallet": "1.1.5"
124148
},

packages/cactus-plugin-ledger-connector-fabric/src/main/go/generated/openapi/go-client/.openapi-generator/FILES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ model_deploy_contract_v1_request_constructor_args.go
2222
model_deploy_contract_v1_response.go
2323
model_deployment_target_org_fabric2x.go
2424
model_deployment_target_organization.go
25+
model_endorsed_proposal_response.go
26+
model_endorsement.go
2527
model_error_exception_response_v1.go
28+
model_event_type.go
2629
model_fabric_certificate_identity_v1.go
2730
model_fabric_contract_invocation_type.go
2831
model_fabric_signing_credential.go
2932
model_fabric_signing_credential_type.go
33+
model_fabric_view.go
3034
model_fabric_x509_certificate_v1.go
3135
model_file_base64.go
3236
model_full_block_transaction_action_v1.go
@@ -53,8 +57,13 @@ model_get_discovery_results_response_v1_orderers_value_endpoints_inner.go
5357
model_get_discovery_results_response_v1_peers_by_msp_value.go
5458
model_get_discovery_results_response_v1_peers_by_msp_value_peers_inner.go
5559
model_get_discovery_results_response_v1_peers_by_msp_value_peers_inner_chaincodes_inner.go
60+
model_get_latest_block_number_request_v1.go
61+
model_get_latest_block_number_response_v1.go
5662
model_get_transaction_receipt_response.go
63+
model_proposal_response_payload.go
5764
model_run_delegated_sign_transaction_request.go
65+
model_run_invoke_request.go
66+
model_run_invoke_response.go
5867
model_run_transaction_request.go
5968
model_run_transaction_response.go
6069
model_run_transaction_response_type.go

packages/cactus-plugin-ledger-connector-fabric/src/main/go/generated/openapi/go-client/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Class | Method | HTTP request | Description
8181
*DefaultApi* | [**GetBlockV1**](docs/DefaultApi.md#getblockv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-block | Get block from the channel using one of selectors from the input. Works only on Fabric 2.x.
8282
*DefaultApi* | [**GetChainInfoV1**](docs/DefaultApi.md#getchaininfov1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-chain-info | Get fabric ledger chain info.
8383
*DefaultApi* | [**GetDiscoveryResultsV1**](docs/DefaultApi.md#getdiscoveryresultsv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-discovery-results | Get fabric ledger node structure (from the discovery service).
84+
*DefaultApi* | [**GetLatestBlockNumberV1**](docs/DefaultApi.md#getlatestblocknumberv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-latest-block-number | Get block number from the channel using one of selectors from the input. Works only on Fabric 2.x.
8485
*DefaultApi* | [**GetPrometheusMetricsV1**](docs/DefaultApi.md#getprometheusmetricsv1) | **Get** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-prometheus-exporter-metrics | Get the Prometheus Metrics
8586
*DefaultApi* | [**GetTransactionReceiptByTxIDV1**](docs/DefaultApi.md#gettransactionreceiptbytxidv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/get-transaction-receipt-by-txid | get a transaction receipt by tx id on a Fabric ledger.
8687
*DefaultApi* | [**RunDelegatedSignTransactionV1**](docs/DefaultApi.md#rundelegatedsigntransactionv1) | **Post** /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-fabric/run-delegated-sign-transaction | Runs a transaction on a Fabric ledger using user-provided signing callback.
@@ -105,11 +106,15 @@ Class | Method | HTTP request | Description
105106
- [DeployContractV1Response](docs/DeployContractV1Response.md)
106107
- [DeploymentTargetOrgFabric2x](docs/DeploymentTargetOrgFabric2x.md)
107108
- [DeploymentTargetOrganization](docs/DeploymentTargetOrganization.md)
109+
- [EndorsedProposalResponse](docs/EndorsedProposalResponse.md)
110+
- [Endorsement](docs/Endorsement.md)
108111
- [ErrorExceptionResponseV1](docs/ErrorExceptionResponseV1.md)
112+
- [EventType](docs/EventType.md)
109113
- [FabricCertificateIdentityV1](docs/FabricCertificateIdentityV1.md)
110114
- [FabricContractInvocationType](docs/FabricContractInvocationType.md)
111115
- [FabricSigningCredential](docs/FabricSigningCredential.md)
112116
- [FabricSigningCredentialType](docs/FabricSigningCredentialType.md)
117+
- [FabricView](docs/FabricView.md)
113118
- [FabricX509CertificateV1](docs/FabricX509CertificateV1.md)
114119
- [FileBase64](docs/FileBase64.md)
115120
- [FullBlockTransactionActionV1](docs/FullBlockTransactionActionV1.md)
@@ -136,8 +141,13 @@ Class | Method | HTTP request | Description
136141
- [GetDiscoveryResultsResponseV1PeersByMSPValue](docs/GetDiscoveryResultsResponseV1PeersByMSPValue.md)
137142
- [GetDiscoveryResultsResponseV1PeersByMSPValuePeersInner](docs/GetDiscoveryResultsResponseV1PeersByMSPValuePeersInner.md)
138143
- [GetDiscoveryResultsResponseV1PeersByMSPValuePeersInnerChaincodesInner](docs/GetDiscoveryResultsResponseV1PeersByMSPValuePeersInnerChaincodesInner.md)
144+
- [GetLatestBlockNumberRequestV1](docs/GetLatestBlockNumberRequestV1.md)
145+
- [GetLatestBlockNumberResponseV1](docs/GetLatestBlockNumberResponseV1.md)
139146
- [GetTransactionReceiptResponse](docs/GetTransactionReceiptResponse.md)
147+
- [ProposalResponsePayload](docs/ProposalResponsePayload.md)
140148
- [RunDelegatedSignTransactionRequest](docs/RunDelegatedSignTransactionRequest.md)
149+
- [RunInvokeRequest](docs/RunInvokeRequest.md)
150+
- [RunInvokeResponse](docs/RunInvokeResponse.md)
141151
- [RunTransactionRequest](docs/RunTransactionRequest.md)
142152
- [RunTransactionResponse](docs/RunTransactionResponse.md)
143153
- [RunTransactionResponseType](docs/RunTransactionResponseType.md)

0 commit comments

Comments
 (0)