-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connector-besu): add gRPC support for operations
1. The Besu connector now can be reached via the gRPC interface. 2. The same operations are exposed as via HTTP+SocketIO 3. gRPC supports bi-directional streaming so the block watching is also supported and test coverage verifies that it works. 4. To see an example of how to use the gRPC client of the Besu connector read the source code of the test case that provides the verification that the functionality works: ``` packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/ integration/grpc-services/connector-besu-grpc-services.test.ts ``` Depends on #3173 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
- Loading branch information
Showing
107 changed files
with
9,119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...connector-besu/src/main/mustache/openapi-generator/templates/protobuf-schema/api.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{#lambda.lowercase}}{{{packageName}}}.{{{apiPackage}}}.{{{classname}}};{{/lambda.lowercase}} | ||
|
||
import "google/protobuf/empty.proto"; | ||
{{#imports}} | ||
{{#import}} | ||
import "{{{modelPackage}}}/{{{.}}}.proto"; | ||
{{/import}} | ||
{{/imports}} | ||
|
||
service {{classname}} { | ||
{{#operations}} | ||
{{#operation}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
rpc {{operationId}} ({{#hasParams}}{{operationId}}Request{{/hasParams}}{{^hasParams}}google.protobuf.Empty{{/hasParams}}) returns ({{#vendorExtensions.x-grpc-response}}{{.}}{{/vendorExtensions.x-grpc-response}}{{^vendorExtensions.x-grpc-response}}{{operationId}}Response{{/vendorExtensions.x-grpc-response}}); | ||
|
||
{{/operation}} | ||
{{/operations}} | ||
} | ||
|
||
{{#operations}} | ||
{{#operation}} | ||
{{#hasParams}} | ||
message {{operationId}}Request { | ||
{{#allParams}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
{{#vendorExtensions.x-protobuf-type}}{{.}} {{/vendorExtensions.x-protobuf-type}}{{vendorExtensions.x-protobuf-data-type}} {{paramName}} = {{vendorExtensions.x-protobuf-index}}; | ||
{{/allParams}} | ||
|
||
} | ||
|
||
{{/hasParams}} | ||
{{^vendorExtensions.x-grpc-response}} | ||
message {{operationId}}Response { | ||
{{{vendorExtensions.x-grpc-response-type}}} data = 1; | ||
} | ||
|
||
{{/vendorExtensions.x-grpc-response}} | ||
{{/operation}} | ||
{{/operations}} |
41 changes: 41 additions & 0 deletions
41
...nnector-besu/src/main/mustache/openapi-generator/templates/protobuf-schema/model.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{#lambda.lowercase}}{{{packageName}}};{{/lambda.lowercase}} | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
{{#imports}} | ||
{{#import}} | ||
import "{{{modelPackage}}}/{{{import}}}.proto"; | ||
{{/import}} | ||
{{/imports}} | ||
|
||
{{#models}} | ||
{{#model}} | ||
{{#isEnum}}{{>enum}}{{/isEnum}}{{^isEnum}}message {{classname}} { | ||
{{#vars}} | ||
{{#description}} | ||
// {{{.}}} | ||
{{/description}} | ||
{{^isEnum}} | ||
{{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{{name}}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}}; | ||
{{/isEnum}} | ||
{{#isEnum}} | ||
enum {{enumName}} { | ||
{{#allowableValues}} | ||
{{#enumVars}} | ||
{{{name}}} = {{{protobuf-enum-index}}}; | ||
{{/enumVars}} | ||
{{/allowableValues}} | ||
} | ||
|
||
{{enumName}} {{name}} = {{vendorExtensions.x-protobuf-index}}; | ||
{{/isEnum}} | ||
|
||
{{/vars}} | ||
} | ||
{{/isEnum}} | ||
{{/model}} | ||
{{/models}} |
22 changes: 22 additions & 0 deletions
22
...onnector-besu/src/main/mustache/openapi-generator/templates/protobuf-schema/root.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{>partial_header}} | ||
syntax = "proto3"; | ||
|
||
package {{{packageName}}}; | ||
|
||
{{#vendorExtensions.x-grpc-options}} | ||
option {{{.}}}; | ||
{{/vendorExtensions.x-grpc-options}} | ||
|
||
// Models | ||
{{#models}} | ||
{{#model}} | ||
import "{{modelPackage}}/{{classFilename}}.proto"; | ||
{{/model}} | ||
{{/models}} | ||
|
||
// APIs | ||
{{#apiInfo}} | ||
{{#apis}} | ||
import "{{apiPackage}}/{{classFilename}}.proto"; | ||
{{/apis}} | ||
{{/apiInfo}} |
44 changes: 44 additions & 0 deletions
44
...us-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/FILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
README.md | ||
models/besu_private_transaction_config_pb.proto | ||
models/besu_transaction_config_pb.proto | ||
models/besu_transaction_config_to_pb.proto | ||
models/consistency_strategy_pb.proto | ||
models/deploy_contract_solidity_bytecode_v1_request_pb.proto | ||
models/deploy_contract_solidity_bytecode_v1_response_pb.proto | ||
models/eth_contract_invocation_type_pb.proto | ||
models/evm_block_pb.proto | ||
models/evm_log_pb.proto | ||
models/evm_transaction_pb.proto | ||
models/get_balance_v1_request_pb.proto | ||
models/get_balance_v1_response_pb.proto | ||
models/get_besu_record_v1_request_pb.proto | ||
models/get_besu_record_v1_response_pb.proto | ||
models/get_block_v1_request_pb.proto | ||
models/get_block_v1_response_pb.proto | ||
models/get_past_logs_v1_request_pb.proto | ||
models/get_past_logs_v1_response_pb.proto | ||
models/get_transaction_v1_request_pb.proto | ||
models/get_transaction_v1_response_pb.proto | ||
models/invoke_contract_v1_request_pb.proto | ||
models/invoke_contract_v1_response_pb.proto | ||
models/receipt_type_pb.proto | ||
models/run_transaction_request_pb.proto | ||
models/run_transaction_response_pb.proto | ||
models/sign_transaction_request_pb.proto | ||
models/sign_transaction_response_pb.proto | ||
models/solidity_contract_json_artifact_compiler_pb.proto | ||
models/solidity_contract_json_artifact_gas_estimates_creation_pb.proto | ||
models/solidity_contract_json_artifact_gas_estimates_pb.proto | ||
models/solidity_contract_json_artifact_pb.proto | ||
models/watch_blocks_v1_pb.proto | ||
models/watch_blocks_v1_progress_pb.proto | ||
models/watch_blocks_v1_request_pb.proto | ||
models/web3_block_header_pb.proto | ||
models/web3_block_header_timestamp_pb.proto | ||
models/web3_signing_credential_cactus_keychain_ref_pb.proto | ||
models/web3_signing_credential_none_pb.proto | ||
models/web3_signing_credential_pb.proto | ||
models/web3_signing_credential_private_key_hex_pb.proto | ||
models/web3_signing_credential_type_pb.proto | ||
models/web3_transaction_receipt_pb.proto | ||
services/default_service.proto |
1 change: 1 addition & 0 deletions
1
...-plugin-ledger-connector-besu/src/main/proto/generated/openapi/.openapi-generator/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.6.0 |
31 changes: 31 additions & 0 deletions
31
.../cactus-plugin-ledger-connector-besu/src/main/proto/generated/openapi/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# gPRC for org.hyperledger.cacti.plugin.ledger.connector.besu | ||
|
||
Can perform basic tasks on a Besu ledger | ||
|
||
## Overview | ||
These files were generated by the [OpenAPI Generator](https://openapi-generator.tech) project. | ||
|
||
- API version: v2.0.0-alpha.2 | ||
- Package version: | ||
- Build package: org.openapitools.codegen.languages.ProtobufSchemaCodegen | ||
|
||
## Usage | ||
|
||
Below are some usage examples for Go and Ruby. For other languages, please refer to https://grpc.io/docs/quickstart/. | ||
|
||
### Go | ||
``` | ||
# assuming `protoc-gen-go` has been installed with `go get -u github.com/golang/protobuf/protoc-gen-go` | ||
mkdir /var/tmp/go/org.hyperledger.cacti.plugin.ledger.connector.besu | ||
protoc --go_out=/var/tmp/go/org.hyperledger.cacti.plugin.ledger.connector.besu services/* | ||
protoc --go_out=/var/tmp/go/org.hyperledger.cacti.plugin.ledger.connector.besu models/* | ||
``` | ||
|
||
### Ruby | ||
``` | ||
# assuming `grpc_tools_ruby_protoc` has been installed via `gem install grpc-tools` | ||
RUBY_OUTPUT_DIR="/var/tmp/ruby/org.hyperledger.cacti.plugin.ledger.connector.besu" | ||
mkdir $RUBY_OUTPUT_DIR | ||
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib services/* | ||
grpc_tools_ruby_protoc --ruby_out=$RUBY_OUTPUT_DIR --grpc_out=$RUBY_OUTPUT_DIR/lib models/* | ||
``` |
24 changes: 24 additions & 0 deletions
24
...tor-besu/src/main/proto/generated/openapi/models/besu_private_transaction_config_pb.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Connector Besu | ||
Can perform basic tasks on a Besu ledger | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.ledger.connector.besu; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message BesuPrivateTransactionConfigPB { | ||
|
||
string privateFrom = 360593360; | ||
|
||
repeated google.protobuf.Any privateFor = 265462717; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...r-connector-besu/src/main/proto/generated/openapi/models/besu_transaction_config_pb.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Connector Besu | ||
Can perform basic tasks on a Besu ledger | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.ledger.connector.besu; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
import "models/besu_transaction_config_to_pb.proto"; | ||
import "models/web3_block_header_timestamp_pb.proto"; | ||
|
||
message BesuTransactionConfigPB { | ||
|
||
string rawTransaction = 185047449; | ||
|
||
Web3BlockHeaderTimestampPB from = 3151786; | ||
|
||
BesuTransactionConfigToPB to = 3707; | ||
|
||
Web3BlockHeaderTimestampPB value = 111972721; | ||
|
||
Web3BlockHeaderTimestampPB gas = 102105; | ||
|
||
Web3BlockHeaderTimestampPB gasPrice = 5271059; | ||
|
||
float nonce = 105002991; | ||
|
||
BesuTransactionConfigToPB data = 3076010; | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...onnector-besu/src/main/proto/generated/openapi/models/besu_transaction_config_to_pb.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Connector Besu | ||
Can perform basic tasks on a Besu ledger | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.ledger.connector.besu; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
|
||
message BesuTransactionConfigToPB { | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...dger-connector-besu/src/main/proto/generated/openapi/models/consistency_strategy_pb.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Hyperledger Cactus Plugin - Connector Besu | ||
Can perform basic tasks on a Besu ledger | ||
The version of the OpenAPI document: v2.0.0-alpha.2 | ||
Generated by OpenAPI Generator: https://openapi-generator.tech | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
package org.hyperledger.cacti.plugin.ledger.connector.besu; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
import "models/receipt_type_pb.proto"; | ||
|
||
message ConsistencyStrategyPB { | ||
|
||
ReceiptTypePB receiptType = 423008661; | ||
|
||
// The amount of milliseconds to wait for the receipt to arrive to the connector. Defaults to 0 which means to wait for an unlimited amount of time. Note that this wait may be interrupted still by other parts of the infrastructure such as load balancers cutting of HTTP requests after some time even if they are the type that is supposed to be kept alive. The question of re-entrance is a broader topic not in scope to discuss here, but it is important to mention it. | ||
int32 timeoutMs = 51479271; | ||
|
||
// The number of blocks to wait to be confirmed in addition to the block containing the transaction in question. Note that if the receipt type is set to only wait for node transaction pool ACK and this parameter is set to anything, but zero then the API will not accept the request due to conflicting parameters. | ||
int32 blockConfirmations = 207555762; | ||
|
||
} |
Oops, something went wrong.