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

Runtime ENVironment configuration #179

Merged
merged 2 commits into from
Apr 27, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Apr 24, 2019

Issue Number

#95

Overview

  • I have made the protocol magic and network available through an ENV var. If the ENV var isn't set, the application will simply fail to start with a clear error message.

Comments

Deprecates #162

@KtorZ KtorZ requested a review from Anviking April 24, 2019 16:42
"local" -> Right Local
s -> Left $ TextDecodingError $
T.unpack s <> " is neither \"mainnet\", \"testnet\", \"staging\" \
\nor \"local\"."
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to Cardano.Environment

@@ -64,4 +66,4 @@ spec = do
threadDelay 1000000
(handle,) <$> (mkWalletLayer
<$> MVar.newDBLayer
<*> HttpBridge.newNetworkLayer "testnet" port)
<*> HttpBridge.newNetworkLayer Testnet port)
Copy link
Member

Choose a reason for hiding this comment

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

Seeing this… 🤔 won't this lead to inconsistencies between the network layers and the CLI param in future tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm.. I am not sure to see what you mean here? There's no more "--network" in the CLI, and the CLI itself reads the environment to get this network value.

Copy link
Member

@Anviking Anviking Apr 25, 2019

Choose a reason for hiding this comment

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

If we call mkStdTx the protocol magic it uses will depend on network and the ENV var. If we ever create a network layer with a custom network, like here (Testnet), we can never safely use the two together.

Would it be possible to have one network for the entire integration tests?

Also:

  • Does the choice of network matter for the integration tests? (Could we default to testnet everywhere and be done with it?)

Copy link
Member Author

Choose a reason for hiding this comment

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

@Anviking Hmm... That's not possible no, because we are running some integration tests against testnet, but some against a local cluster (the scenarios) because we need the ability to have faucets wallets there, and submit transactions at will.

So yeah, if the application is configured with a protocol magic / network that is different from the one used by the bridge, we can an error; but that's pretty much what we have already anyway.

@KtorZ KtorZ self-assigned this Apr 25, 2019
@paweljakubas paweljakubas mentioned this pull request Apr 26, 2019
Copy link
Contributor

@akegalj akegalj left a comment

Choose a reason for hiding this comment

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

LGTM

--
-- ENV[NETWORK] = ?
--
-- What about trying to provide a valid ENV var `NETWORK=value cardano-wallet-launcher` ?
Copy link
Contributor

Choose a reason for hiding this comment

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

will this error be presentet using stack exec -- cardano-wallet server .... as well? If it will be, maybe this error message will be missleading as it constrains only to cardano-wallet-launcher binary

EDIT: I see command is not hardcoded - so everything is ok

deriving (Generic, Show, Eq, Enum)

instance FromText Network where
fromText = \case
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess both FromText and ToText instances can be made more generic by using Show and Read classes - but Network seems so small and selfcontained that I don't find that necessary

-- Note that the 'ProtocolMagic' for 'Local' and 'Testnet' are the same.
protocolMagic :: Network -> ProtocolMagic
protocolMagic = \case
Mainnet -> ProtocolMagic 764824073
Copy link
Contributor

Choose a reason for hiding this comment

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

I hope these hardcoded values are right - because I am not sure where to look up for the proof/source that these are the right numbers?

Maybe it would be usefull for other readers to add a comment where from or why these specific numbers were picked

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I am not even sure where I got them from :| ... I think I now mostly go for the ~/.hermes configuration files generated by the http bridge to be honest...

@KtorZ KtorZ force-pushed the KtorZ/95/runtime-environment-configuration branch from 7a9d3b7 to 4931fb5 Compare April 26, 2019 21:55
@KtorZ KtorZ merged commit baf2cf6 into master Apr 27, 2019
@KtorZ KtorZ deleted the KtorZ/95/runtime-environment-configuration branch April 27, 2019 11:51
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.

3 participants