Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init start support gatewayconfig #231

Merged

Conversation

gulshanvasnani
Copy link
Contributor

@gulshanvasnani gulshanvasnani commented Oct 17, 2019

Do not merge before #225
PR contains following changes :

  • Introduce gatewayconfig option in facilitator-init
  • Introduce gatewayconfig option in facilitator-start
  • Readme for facilitator-init and faciltiator-start command

fixes #212

@0xsarvesh 0xsarvesh self-assigned this Oct 22, 2019
Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work 👍

Some feedback and comments.

const facilitator: FacilitatorConfig = FacilitatorConfig.fromFile(facilitatorConfigPath);
const gatewayAddresses = mosaicConfigPath
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both params mosaicConfig and gatewayConfig are optional. It should check one of both exists.

Compiler is also complaining on same point on statement gatewayConfigPath! because of !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, added configType parameters in fromFile.

);
} else {
// only facilitator config is given.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should check if mosaic config exists. Because from chain with return blank object if it doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added suggested approach.
But i think, fromChain should throw error when path is not present.
It will be aligned to what we do in fromFile method.
What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created ticket to align fromChain and fromFile methods OpenST/mosaic-chains#196

* @param mosaicConfigPath Path to mosaic config.
* @returns originchain id and gatewayaddresses object.
*/
function getFromMosaicConfig(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these methods to some other class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move whole logic to file lib/facilitator-init and commander method will have only one statement of calling class in lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to create new ticket for moving other logic to file lib/facilitator-init

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created ticket #240 to address it.

commander
.option('-m, --mosaic-config <mosaic-config>', 'path to mosaic configuration')
.option('-q, --gateway-config <gateway-config>', 'path to gateway configuration')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you decide on q as option?
I think we should revisit all the options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially thought of -g, but it's already being used for --origin-graph-rpc option in facilitator-init command.
To make short-name for --gateway-config, I used -q in both init and start command.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abhayks1 @puneet-khushwani-eth what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with @puneet-khushwani-eth and @abhayks1 , decided to go for -g for --gateway-config. So, -n is now used for --origin-graph-rpc.

@@ -20,6 +20,6 @@
import facilitator from 'commander';

facilitator
.command('init <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config')
.command('init <token-config> <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is token config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to gateway-config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Her does mosaic-config option needed if gateway-config is present?

const originChain = '2';
const auxChain = 3;
const facilitatorConfigPath = './facilitator-config.json';
const mosaicConfigPath = './test/mosaic-config.json';
const gatewayConfigPath = './gateway-config.json';
const mosaicJson = `{"originChain":{"chain":"${originChain}"},"auxiliaryChains":{"${auxChain}":{"chainId": ${auxChain}}}}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unreadable, extract this json out in a method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of json, method can return JS object directly because you are parsing json.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -40,6 +56,16 @@ describe('FacilitatorOptionParser.getConfig()', () => {
return spy;
}

function spyGatewayConfigFromFile(gatewayConfig: any): any {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove any type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still many any types 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for method creating stub should return SinonStubStatic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@0xsarvesh 0xsarvesh removed their assignment Oct 22, 2019
Copy link
Contributor

@abhayks1 abhayks1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few inline comments.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@@ -20,6 +20,6 @@
import facilitator from 'commander';

facilitator
.command('init <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config')
.command('init <token-config> <mosaic-config> <aux-chain-id> <origin-password> <auxiliary-password> <origin-rpc> <auxiliary-rpc> <origin-graph-ws> <origin-graph-rpc> <auxiliary-graph-ws> <auxiliary-graph-rpc> <db-path>', 'initializes the facilitator config')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Her does mosaic-config option needed if gateway-config is present?

@gulshanvasnani
Copy link
Contributor Author

gulshanvasnani commented Oct 22, 2019

@sarvesh-ost @abhayks1
PR is available for review

Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@0xsarvesh 0xsarvesh merged commit 94a95c6 into OpenST:master Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facilitator init & start compatibility for Gateway Config
3 participants