Skip to content

Commit

Permalink
modify fabric config file for gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
nklincoln committed Jun 16, 2020
1 parent 3cbb0e7 commit 8c9fac5
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 120 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"packages/caliper-gui-server",
"packages/generator-caliper"
],
"version": "0.3.2",
"version": "0.4.0-unstable",
"hoist": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "caliper",
"description": "Performance benchmarking for Hyperledger blockchain technologies. You must install [Lerna](https://lernajs.io) to build this multi-package repository.",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper"
Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-burrow/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperledger/caliper-burrow",
"description": "Hyperledger Burrow adaptor for Caliper, enabling the running of performance benchmarks that interact with Burrow",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper",
Expand All @@ -22,7 +22,7 @@
"npm": ">=5.6.0"
},
"dependencies": {
"@hyperledger/caliper-core": "0.3.2",
"@hyperledger/caliper-core": "0.4.0-unstable",
"google-protobuf": "^3.11.4"
},
"devDependencies": {
Expand Down
16 changes: 8 additions & 8 deletions packages/caliper-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperledger/caliper-cli",
"description": "Hyperledger Caliper CLI, for convenience running of a performance benchmark to test blockchain technologies",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper",
Expand All @@ -26,13 +26,13 @@
"npm": ">=5.6.0"
},
"dependencies": {
"@hyperledger/caliper-core": "0.3.2",
"@hyperledger/caliper-burrow": "0.3.2",
"@hyperledger/caliper-fabric": "0.3.2",
"@hyperledger/caliper-iroha": "0.3.2",
"@hyperledger/caliper-sawtooth": "0.3.2",
"@hyperledger/caliper-ethereum": "0.3.2",
"@hyperledger/caliper-fisco-bcos": "0.3.2",
"@hyperledger/caliper-core": "0.4.0-unstable",
"@hyperledger/caliper-burrow": "0.4.0-unstable",
"@hyperledger/caliper-fabric": "0.4.0-unstable",
"@hyperledger/caliper-iroha": "0.4.0-unstable",
"@hyperledger/caliper-sawtooth": "0.4.0-unstable",
"@hyperledger/caliper-ethereum": "0.4.0-unstable",
"@hyperledger/caliper-fisco-bcos": "0.4.0-unstable",
"yargs": "15.3.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-core/lib/common/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ const keys = {
SkipCreateChannelPrefix: 'caliper-fabric-skipcreatechannel-',
Gateway: {
Discovery: 'caliper-fabric-gateway-discovery',
Enabled: 'caliper-fabric-gateway-enabled',
EventStrategy: 'caliper-fabric-gateway-eventstrategy',
GatewayLocalHost: 'caliper-fabric-gateway-gatewaylocalhost',
LocalHost: 'caliper-fabric-gateway-localhost',
QueryStrategy: 'caliper-fabric-gateway-querystrategy',
UseGateway: 'caliper-fabric-gateway-usegateway',
}
}
};
Expand Down
5 changes: 3 additions & 2 deletions packages/caliper-core/lib/common/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ caliper:
countqueryasload: true
# Settings for the Fabric Gateway API
gateway:
usegateway: false
# Indicates whether to use the Fabric Gateway API
enabled: false
# Indicates whether to use the localhost default within the Fabric Gateway API
gatewaylocalhost: true
localhost: true
# Indicates whether to use the Fabric discovery mechanism (via Gateway API)
discovery: false
# Which event strategy to use
Expand Down
2 changes: 1 addition & 1 deletion packages/caliper-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperledger/caliper-core",
"description": "Core Hyperledger Caliper module, used for running performance benchmarks that interact with blockchain technologies",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper",
Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-ethereum/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperledger/caliper-ethereum",
"description": "Ethereum adaptor for Caliper, enabling the running of performance benchmarks that interact with Ethereum",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper",
Expand All @@ -22,7 +22,7 @@
"npm": ">=5.6.0"
},
"dependencies": {
"@hyperledger/caliper-core": "0.3.2",
"@hyperledger/caliper-core": "0.4.0-unstable",
"ethereumjs-wallet": "^0.6.3"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const { BlockchainInterface, CaliperUtils, TxStatus, ConfigUtil } = require('@hy
const logger = CaliperUtils.getLogger('adapters/fabric');

const FabricNetwork = require('../../fabricNetwork.js');
const ConfigValidator = require('../../configValidator.js');
const fs = require('fs');
const semver = require('semver');

Expand Down Expand Up @@ -132,26 +131,18 @@ const QueryStrategies = {
class Fabric extends BlockchainInterface {
/**
* Initializes the Fabric adapter.
* @param {string|object} networkConfig The relative or absolute file path, or the object itself of the Common Connection Profile settings.
* @param {object} networkObject The parsed network configuration.
* @param {string} workspace_root The absolute path to the root location for the application configuration files.
* @param {number} clientIndex the client index
*/
constructor(networkConfig, workspace_root, clientIndex) {
super(networkConfig);
constructor(networkObject, workspace_root, clientIndex) {
super(networkObject);
this.bcType = 'fabric';
this.workspaceRoot = workspace_root;
this.version = require('fabric-client/package').version;

this.network = undefined;
if (typeof networkConfig === 'string') {
const configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkObject));

this.clientProfiles = new Map();
this.adminProfiles = new Map();
Expand Down Expand Up @@ -179,14 +170,11 @@ class Fabric extends BlockchainInterface {
this.configCountQueryAsLoad = ConfigUtil.get(ConfigUtil.keys.Fabric.CountQueryAsLoad, true);

// Gateway adaptor
this.configLocalHost = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.GatewayLocalHost, true);
this.configLocalHost = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.LocalHost, true);
this.configDiscovery = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Discovery, false);
this.eventStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.EventStrategy, 'msp_all');
this.queryStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.QueryStrategy, 'msp_single');

ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(),
this.configDiscovery, true);

this.networkUtil = new FabricNetwork(this.network, workspace_root);
this.fileWalletPath = this.networkUtil.getFileWalletPath();
this.defaultInvoker = Array.from(this.networkUtil.getClients())[0];
Expand Down
22 changes: 5 additions & 17 deletions packages/caliper-fabric/lib/adaptor-versions/v1/fabric-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const {BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil} = requi
const logger = CaliperUtils.getLogger('adapters/fabric');

const FabricNetwork = require('../../fabricNetwork.js');
const ConfigValidator = require('../../configValidator.js');
const fs = require('fs');


Expand Down Expand Up @@ -126,26 +125,18 @@ const fs = require('fs');
class Fabric extends BlockchainInterface {
/**
* Initializes the Fabric adapter.
* @param {string|object} networkConfig The relative or absolute file path, or the object itself of the Common Connection Profile settings.
* @param {object} networkObject The parsed network configuration.
* @param {string} workspace_root The absolute path to the root location for the application configuration files.
* @param {number} clientIndex the client index
*/
constructor(networkConfig, workspace_root, clientIndex) {
super(networkConfig);
constructor(networkObject, workspace_root, clientIndex) {
super(networkObject);
this.bcType = 'fabric';
this.workspaceRoot = workspace_root;
this.version = new Version(require('fabric-client/package').version);

this.network = undefined;
if (typeof networkConfig === 'string') {
const configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkObject));

this.clientProfiles = new Map();
this.adminProfiles = new Map();
Expand Down Expand Up @@ -174,9 +165,6 @@ class Fabric extends BlockchainInterface {
this.configClientBasedLoadBalancing = ConfigUtil.get(ConfigUtil.keys.Fabric.LoadBalancing, 'client') === 'client';
this.configCountQueryAsLoad = ConfigUtil.get(ConfigUtil.keys.Fabric.CountQueryAsLoad, true);

ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(),
this.configDiscovery, false);

this.networkUtil = new FabricNetwork(this.network, workspace_root);
this.defaultInvoker = Array.from(this.networkUtil.getClients())[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, Gateway, W
const { BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil } = require('@hyperledger/caliper-core');

const FabricNetwork = require('../../fabricNetwork.js');
const ConfigValidator = require('../../configValidator.js');
const RegistrarHelper = require('./registrarHelper');

const logger = CaliperUtils.getLogger('adapters/fabric');
Expand Down Expand Up @@ -115,26 +114,18 @@ const QueryStrategies = {
class Fabric extends BlockchainInterface {
/**
* Initializes the Fabric adapter.
* @param {string|object} networkConfig The relative or absolute file path, or the object itself of the Common Connection Profile settings.
* @param {object} networkObject The parsed network configuration.
* @param {string} workspace_root The absolute path to the root location for the application configuration files.
* @param {number} clientIndex the client index
*/
constructor(networkConfig, workspace_root, clientIndex) {
super(networkConfig);
constructor(networkObject, workspace_root, clientIndex) {
super(networkObject);
this.bcType = 'fabric';
this.workspaceRoot = workspace_root;
this.version = new Version(require('fabric-network/package').version);

this.network = undefined;
if (typeof networkConfig === 'string') {
const configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkObject));

this.clientIndex = clientIndex;
this.txIndex = -1;
Expand All @@ -152,13 +143,10 @@ class Fabric extends BlockchainInterface {
this.configCountQueryAsLoad = ConfigUtil.get(ConfigUtil.keys.Fabric.CountQueryAsLoad, true);

// Gateway adaptor
this.configLocalHost = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.GatewayLocalHost, true);
this.configLocalHost = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.LocalHost, true);
this.configDiscovery = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Discovery, false);
this.eventStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.EventStrategy, 'msp_all');
this.queryStrategy = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.QueryStrategy, 'msp_single');

// validate the network
ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(), this.configDiscovery, true);
}

////////////////////////////////
Expand Down
22 changes: 5 additions & 17 deletions packages/caliper-fabric/lib/adaptor-versions/v2/fabric-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const {BlockchainInterface, CaliperUtils, TxStatus, Version, ConfigUtil} = requi
const logger = CaliperUtils.getLogger('adapters/fabric');

const FabricNetwork = require('../../fabricNetwork.js');
const ConfigValidator = require('../../configValidator.js');
const fs = require('fs');


Expand Down Expand Up @@ -126,26 +125,18 @@ const fs = require('fs');
class Fabric extends BlockchainInterface {
/**
* Initializes the Fabric adapter.
* @param {string|object} networkConfig The relative or absolute file path, or the object itself of the Common Connection Profile settings.
* @param {object} networkObject The parsed network configuration.
* @param {string} workspace_root The absolute path to the root location for the application configuration files.
* @param {number} clientIndex the client index
*/
constructor(networkConfig, workspace_root, clientIndex) {
super(networkConfig);
constructor(networkObject, workspace_root, clientIndex) {
super(networkObject);
this.bcType = 'fabric';
this.workspaceRoot = workspace_root;
this.version = new Version(require('fabric-client/package').version);

this.network = undefined;
if (typeof networkConfig === 'string') {
const configPath = CaliperUtils.resolvePath(networkConfig, workspace_root);
this.network = CaliperUtils.parseYaml(configPath);
} else if (typeof networkConfig === 'object' && networkConfig !== null) {
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkConfig));
} else {
throw new Error('[FabricNetwork.constructor] Parameter \'networkConfig\' is neither a file path nor an object');
}
// clone the object to prevent modification by other objects
this.network = CaliperUtils.parseYamlString(CaliperUtils.stringifyYaml(networkObject));

this.clientProfiles = new Map();
this.adminProfiles = new Map();
Expand Down Expand Up @@ -174,9 +165,6 @@ class Fabric extends BlockchainInterface {
this.configClientBasedLoadBalancing = ConfigUtil.get(ConfigUtil.keys.Fabric.LoadBalancing, 'client') === 'client';
this.configCountQueryAsLoad = ConfigUtil.get(ConfigUtil.keys.Fabric.CountQueryAsLoad, true);

ConfigValidator.validateNetwork(this.network, CaliperUtils.getFlowOptions(),
this.configDiscovery, false);

this.networkUtil = new FabricNetwork(this.network, workspace_root);
this.defaultInvoker = Array.from(this.networkUtil.getClients())[0];

Expand Down
11 changes: 9 additions & 2 deletions packages/caliper-fabric/lib/fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const { BlockchainInterface, CaliperUtils, ConfigUtil } = require('@hyperledger/caliper-core');
const ConfigValidator = require('./configValidator.js');
const Logger = CaliperUtils.getLogger('adapters/fabric');

const semver = require('semver');
Expand Down Expand Up @@ -42,7 +43,8 @@ const Fabric = class extends BlockchainInterface {
throw new Error(msg);
}

const useGateway = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.UseGateway, false);
const useGateway = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Enabled, false);
const useDiscovery = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Discovery, false);

Logger.info(`Initializing ${useGateway ? 'gateway' : 'standard' } adaptor compatible with installed SDK: ${version}`);

Expand Down Expand Up @@ -72,8 +74,13 @@ const Fabric = class extends BlockchainInterface {
const networkConfig = CaliperUtils.resolvePath(ConfigUtil.get(ConfigUtil.keys.NetworkConfig));
const workspaceRoot = path.resolve(ConfigUtil.get(ConfigUtil.keys.Workspace));

// validate the passed network file before use in underlying adaptor(s)
const configPath = CaliperUtils.resolvePath(networkConfig, workspaceRoot);
const networkObject = CaliperUtils.parseYaml(configPath);
ConfigValidator.validateNetwork(networkObject, CaliperUtils.getFlowOptions(), useDiscovery, useGateway);

const Fabric = require(modulePath);
this.fabric = new Fabric(networkConfig, workspaceRoot, workerIndex);
this.fabric = new Fabric(networkObject, workspaceRoot, workerIndex);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-fabric/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hyperledger/caliper-fabric",
"description": "Hyperledger Fabric adaptor for Caliper, enabling the running of performance benchmarks that interact with Fabric",
"version": "0.3.2",
"version": "0.4.0-unstable",
"repository": {
"type": "git",
"url": "https://github.com/hyperledger/caliper",
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@hapi/joi": "^15.1.1",
"@hyperledger/caliper-core": "0.3.2",
"@hyperledger/caliper-core": "0.4.0-unstable",
"semver": "7.1.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/caliper-fisco-bcos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperledger/caliper-fisco-bcos",
"version": "0.3.2",
"version": "0.4.0-unstable",
"description": "FISCO BCOS adaptor for Caliper, enabling the running of a performance benchmarks that interact with FISCO BCOS",
"repository": {
"type": "git",
Expand All @@ -22,7 +22,7 @@
"npm": ">=5.6.0"
},
"dependencies": {
"@hyperledger/caliper-core": "0.3.2",
"@hyperledger/caliper-core": "0.4.0-unstable",
"bn.js": "^4.11.8",
"crypto-js": "^3.1.9-1",
"ethereumjs-util": "^6.1.0",
Expand Down
Loading

0 comments on commit 8c9fac5

Please sign in to comment.