Skip to content

Commit

Permalink
feat: besu private transaction support
Browse files Browse the repository at this point in the history
This PR enables the use of private transacations in Hyperledger Besu.
This is done by add privateFor and privateFrom parameters in the run
transaction endpoint.

Signed-off-by: Travis Payne <travis.payne@accenture.com>
  • Loading branch information
Travis Payne authored and travis-payne committed Aug 20, 2021
1 parent 4cc6f2c commit 53b4980
Show file tree
Hide file tree
Showing 38 changed files with 4,851 additions and 4,538 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"openapi-types": "7.0.1",
"typescript-optional": "2.0.1",
"uuid": "8.3.0",
"web3-core": "1.2.7",
"web3-utils": "1.2.7"
"web3-core": "1.3.5",
"web3-utils": "1.3.5"
},
"devDependencies": {
"@types/express": "4.17.8",
Expand Down
2 changes: 1 addition & 1 deletion examples/cactus-example-supply-chain-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"solc": "0.7.1",
"typescript-optional": "2.0.1",
"uuid": "8.3.0",
"web3-core": "1.3.0"
"web3-core": "1.3.5"
},
"devDependencies": {
"@types/express": "4.17.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class IpfsHttpClientMock implements IIpfsHttpClient {
this.dag = {} as DAGAPI;
this.dht = {} as DHTAPI;
this.diag = {} as DiagAPI;
this.files = new FilesApiMock({ logLevel: this.options.logLevel });
this.files = new FilesApiMock({ logLevel: this.options.logLevel }) as any;
this.key = {} as KeyAPI;
this.log = {} as LogAPI;
this.name = {} as NameAPI;
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"test:plugin-ledger-connector-besu": "tap --ts --jobs=1 --timeout=60 \"packages/cactus-*-besu/src/test/typescript/{unit,integration}/\"",
"build:dev:plugin-htlc-eth-besu-erc20": "lerna exec --stream --scope 'packages/*htlc-eth-besu-erc20' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --env=dev --target=node --config ../../webpack.config.js'",
"test:plugin-htlc-besu-erc20": "tap --jobs=1 --timeout=600 \"packages/*htlc-eth-besu-erc20/src/test/typescript/{unit,integration}/\"",
"test:plugin": "tap --jobs=1 --timeout=600 \"packages/*test-plugin-htlc-eth-besu/src/test/typescript/{unit,integration}/\"",
"build:dev:plugin-ledger-connector-quorum": "lerna exec --stream --scope '*/*connector-quorum' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --env=dev --target=node --config ../../webpack.config.js'",
"test:plugin-ledger-connector-quorum": "tap --ts --jobs=1 --timeout=60 \"packages/cactus-*-quorum/src/test/typescript/{unit,integration}/\"",
"build:dev:plugin-ledger-connector-fabric": "lerna exec --stream --scope '*/*connector-fabric' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --env=dev --target=node --config ../../webpack.config.js'",
Expand Down Expand Up @@ -129,17 +130,13 @@
"typescript": "4.2.4",
"webpack": "5.36.2",
"webpack-bundle-analyzer": "4.4.2",
"webpack-cli": "4.7.2"
"webpack-cli": "4.7.2",
"cspell": "5.4.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"dependencies": {
"@types/ssh2": "0.5.46",
"artillery": "1.7.2",
"cspell": "5.4.0"
}
}
3 changes: 2 additions & 1 deletion packages/cactus-cmd-api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"socket.io": "4.0.1",
"socket.io-client": "4.0.1",
"typescript-optional": "2.0.1",
"uuid": "7.0.2"
"uuid": "7.0.2",
"artillery": "1.7.2"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-vault": "0.8.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-plugin-htlc-eth-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"joi": "14.3.1",
"openapi-types": "7.0.1",
"typescript-optional": "2.0.1",
"web3": "1.2.7",
"web3-eea": "0.10.0"
"web3": "1.3.5",
"web3-eea": "0.11.0"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "0.6.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/cactus-plugin-ledger-connector-besu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ enum Web3SigningCredentialType {
NONE = 'NONE'
}
```

> Extensive documentation and examples in the [readthedocs](https://readthedocs.org/projects/hyperledger-cactus/) (WIP)

## Transaction Privacy Feature
Private transactions using Besu are currently enabled.

### Building/running the container image locally

In the Cactus project root say:
Expand Down
12 changes: 7 additions & 5 deletions packages/cactus-plugin-ledger-connector-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,20 @@
"joi": "14.3.1",
"openapi-types": "7.0.1",
"prom-client": "13.1.0",
"run-time-error": "1.4.0",
"rxjs": "6.6.7",
"socket.io-client": "4.0.1",
"typescript-optional": "2.0.1",
"web3": "1.2.7",
"web3-utils": "1.2.7"
"web3": "1.3.5",
"web3-eea": "0.11.0",
"web3-utils": "1.3.5",
"web3-core": "1.3.5",
"web3-eth": "1.3.5"
},
"devDependencies": {
"@hyperledger/cactus-plugin-keychain-memory": "0.8.0",
"@hyperledger/cactus-test-tooling": "0.8.0",
"@types/express": "4.17.8",
"socket.io": "4.0.1",
"web3-core": "1.2.7",
"web3-eth": "1.2.7"
"socket.io": "4.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,26 @@
}
}
},
"BesuPrivateTransactionConfig" : {
"type": "object",
"required" : [
"privateFrom",
"privateFor"
],
"properties" : {
"privateFrom": {
"type": "string",
"nullable": false
},
"privateFor": {
"type": "array",
"default": [],
"items": {},
"nullable": false
}

}
},
"Web3TransactionReceipt": {
"type": "object",
"required": [
Expand Down Expand Up @@ -715,6 +735,9 @@
},
"consistencyStrategy": {
"$ref": "#/components/schemas/ConsistencyStrategy"
},
"privateTransactionConfig": {
"$ref": "#/components/schemas/BesuPrivateTransactionConfig"
}
}
},
Expand Down Expand Up @@ -790,6 +813,9 @@
"minimum": 0,
"default": 60000,
"nullable": false
},
"privateTransactionConfig": {
"$ref": "#/components/schemas/BesuPrivateTransactionConfig"
}
}
},
Expand Down Expand Up @@ -896,6 +922,9 @@
"description": "The keychainId for retrieve the contracts json.",
"minLength": 1,
"maxLength": 100
},
"privateTransactionConfig": {
"$ref": "#/components/schemas/BesuPrivateTransactionConfig"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';

/**
*
* @export
* @interface BesuPrivateTransactionConfig
*/
export interface BesuPrivateTransactionConfig {
/**
*
* @type {string}
* @memberof BesuPrivateTransactionConfig
*/
privateFrom: string;
/**
*
* @type {Array<any>}
* @memberof BesuPrivateTransactionConfig
*/
privateFor: Array<any>;
}
/**
*
* @export
Expand Down Expand Up @@ -163,6 +182,12 @@ export interface DeployContractSolidityBytecodeV1Request {
* @memberof DeployContractSolidityBytecodeV1Request
*/
timeoutMs?: number;
/**
*
* @type {BesuPrivateTransactionConfig}
* @memberof DeployContractSolidityBytecodeV1Request
*/
privateTransactionConfig?: BesuPrivateTransactionConfig;
}
/**
*
Expand Down Expand Up @@ -692,6 +717,12 @@ export interface InvokeContractV1Request {
* @memberof InvokeContractV1Request
*/
keychainId?: string;
/**
*
* @type {BesuPrivateTransactionConfig}
* @memberof InvokeContractV1Request
*/
privateTransactionConfig?: BesuPrivateTransactionConfig;
}
/**
*
Expand Down Expand Up @@ -752,6 +783,12 @@ export interface RunTransactionRequest {
* @memberof RunTransactionRequest
*/
consistencyStrategy: ConsistencyStrategy;
/**
*
* @type {BesuPrivateTransactionConfig}
* @memberof RunTransactionRequest
*/
privateTransactionConfig?: BesuPrivateTransactionConfig;
}
/**
*
Expand Down
Loading

0 comments on commit 53b4980

Please sign in to comment.