Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CO-390] Run Demo Cluster #3629

Merged
merged 3 commits into from
Oct 16, 2018
Merged

[CO-390] Run Demo Cluster #3629

merged 3 commits into from
Oct 16, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Sep 19, 2018

Description

@disassembler, you'll recognize some parts of an old PR. I've resurrected it and adjusted a few things:

  • Now we pick a system temporary directory as a state-dir (unless given one)
  • Topology is generated on the fly
  • TLS certs are generated on the fly

This is still WIP but I'd appreciate your inputs before I move forward ❤️

Linked issue

[CO-390]

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

@KtorZ KtorZ requested a review from disassembler September 19, 2018 10:10
@KtorZ
Copy link
Contributor Author

KtorZ commented Sep 19, 2018

NOTE (@disassembler): I haven't tested anything yet so don't try to run it ^^" ... It's more about grooming the general idea.

know:

- ENV variables define "base" arguments for a node.
When it makes sense (.e.g `DB_PATH`, `LOG_CONFIG`), these "base" arguments
Copy link
Contributor

Choose a reason for hiding this comment

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

will you also support a prefix where logs are put?
--logs-prefix FILEPATH Prefix to logger output path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since it reuses the CLI parsers, everything that is supported by the CLI will be seemingly supported by this. 👍

@KtorZ
Copy link
Contributor Author

KtorZ commented Sep 19, 2018

Just realised there's no need to run most of those actions in plain IO. The ENV can be read once and put in a Map, then we can use normal lenses to perform the same operation in a pure fashion.

Will do.

@KtorZ KtorZ force-pushed the KtorZ/CO-390/run-demo-cluster branch 3 times, most recently from cca17c9 to 337b08f Compare September 25, 2018 16:15
genesisConfig
txpConfig
nodeRes
(runNode genesisConfig txpConfig nodeRes plugins)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved from node/Main.hs to be re-used elsewhere.

@KtorZ KtorZ added the wip label Sep 25, 2018
@KtorZ KtorZ force-pushed the KtorZ/CO-390/run-demo-cluster branch from 337b08f to f30a720 Compare September 28, 2018 12:04
@KtorZ KtorZ removed the wip label Sep 28, 2018
@KtorZ KtorZ changed the title [CO-390] WIP - Run Demo Cluster [CO-390] Run Demo Cluster Sep 28, 2018
@KtorZ KtorZ force-pushed the KtorZ/CO-390/run-demo-cluster branch 6 times, most recently from 4d71034 to 963ec1e Compare October 5, 2018 08:11
@KtorZ KtorZ force-pushed the KtorZ/CO-390/run-demo-cluster branch 8 times, most recently from 73333d0 to be213ad Compare October 10, 2018 16:31
......system start: 1539179292
......address: 127.0.0.1:3100
...wallet OK!
......system start: 1539179292
Copy link
Contributor

Choose a reason for hiding this comment

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

@disassembler tells me the inconsistent start times have been fixed. Let's update the example text here too.

Copy link
Contributor

@jmitchell jmitchell left a comment

Choose a reason for hiding this comment

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

Only a minor doc nitpick, but otherwise LGTM.

KtorZ added 3 commits October 12, 2018 10:11
This code makes use of the 'Cardano.Wallet.Demo' module and show
how it can be used to spawn a demo cluster of nodes.
More details in the README.md
@KtorZ KtorZ force-pushed the KtorZ/CO-390/run-demo-cluster branch from e6b18c3 to 8b76d29 Compare October 12, 2018 08:11
@KtorZ
Copy link
Contributor Author

KtorZ commented Oct 16, 2018

Still waiting for review from @akegalj, though this is needed for debugging and assessing results for a fix of 1.4.0.
It's quite isolated work so we can simply iterate with @akegalj 's feedback (if any).

@KtorZ KtorZ merged commit 8e26a7a into develop Oct 16, 2018
@KtorZ KtorZ deleted the KtorZ/CO-390/run-demo-cluster branch October 16, 2018 12:47
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

yield (RunningRelayNode nodeId nodeEnv)

NodeEdge -> do
genesisKeys <- init topology >> init logger >> init genesis
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how this makes it clear what options are being included 👍

-> (Maybe SyncPercentage -> IO ())
-> IO ()
waitForNode wc (MaxWaitingTime s) reportProgress = do
res <- race (threadDelay $ s * oneSecond) retry
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

:: NodeType -- ^ Target node type (core, relay, edge ...)
-> [(NodeName, NodeType, NetworkAddress)] -- ^ All fully qualified nodes
-> Topology
demoTopology nodeType =
Copy link
Contributor

Choose a reason for hiding this comment

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

I have just skimmed over this one as I am lacking more indepth knowledge about the internals of topology

-- terminating "normally" which can't happen.
mvar <- newEmptyMVar
handle <- async (action (putMVar mvar))
result <- race (wait handle) (takeMVar mvar)
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, clever

sToK = map (Char.toLower . replaceIf '_' '-')


-- | Split a string on the given character
Copy link
Contributor

Choose a reason for hiding this comment

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

prop_runAsync n = ioProperty $ do
((handle, res), t) <- time (runAsync io)
cancel handle
return $ classify (t < 100) "< 100μs" $ res === n .&&. t < (10 * oneSecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder will this sometimes fail (with low probability) if thread scheduler paused async action

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not. I took a veeeeery large time for the property to fail (10 seconds). That's also what the classify is for. I've actually seen some runs where 99.9% only are under 100us and some got above. The property still passes fine as it's not about measuring any time execution, but just measuring that yields correctly returns a result prematurely, before the end of the thread.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants