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

generalize Node.run for invocation from both real node and from ThreadNet tests and refine interface used by real node #2720

Merged
merged 17 commits into from
Nov 12, 2020

Conversation

nfrisby
Copy link
Contributor

@nfrisby nfrisby commented Nov 2, 2020

This PR makes three changes to the RunNodeArgs interface.

  1. It splits off some arguments of RunNodeArgs into a separate LowLevelRunNodeArgs record. RunNodeArgs are necessary arguments to run. LowLeveRunNodeArgs are the kinds of arguments that a "power user" such as the tests would use.

  2. It introduces a new record StdRunNodeArgs that captures the exact fields that the real invocation from cardano-node would like to provide when invoking run. We also provide a function that maps StdRunNodeArgs to LowLevelRunNodeArgs by providing defaults, setting typical file paths, etc. This is how we hide LowLevelRunNodeArgs from the real invocation in cardano-node.

  3. It renames the internal NodeArgs to NodeKernelArgs.

@nfrisby
Copy link
Contributor Author

nfrisby commented Nov 2, 2020

I integrated the simplifications we discussed.

@nfrisby nfrisby force-pushed the nfrisby/generalize-node-run branch 2 times, most recently from dee7a16 to 7f1976e Compare November 3, 2020 18:07
@nfrisby nfrisby changed the title generalize Node.run for invocation from both real node and from ThreadNet tests generalize Node.run for invocation from both real node and from ThreadNet tests and refine interface used by real node Nov 10, 2020
@nfrisby
Copy link
Contributor Author

nfrisby commented Nov 10, 2020

I've updated the PR description and pushed a commit that satisfies everything we discussed. I'm marking this as ready to review.

@nfrisby nfrisby marked this pull request as ready for review November 10, 2020 22:41
nfrisby and others added 13 commits November 12, 2020 09:56
Adds the following parameters to the DiIffusionApplications record type, so
that it can be used both for the real diffusion layer and for a mock layer in
the ThreadNet tests.

  * addresses: real uses RemoteAddress and LocalAddress, ThreadNet uses
    CoreNodeId

  * version data: real uses NodeToNodeVersionData and NodeToClientVersionData,
    ThreadNet uses UnversionedProtocolData

  * monad: real uses IO, ThreadNet uses IOLike m => m
The ThreadNet tests will run a mock diffusion layer. It's simpler than the real
diffusion layer, and it's connection/disconnection timeline can be scripted
according to each generated " test plan " (eg enabling shrinking to an
explicitly static topology).
The ThreadNet tests use a mock filesystem, so .run must not directly use
Ouroboros.Consensus.Storage.FS.IO.ioHasFS to initialize the ChainDB.

Moreover, the tests use fully separate mock FSs for each internal database, for
example to better localize reporting of unclosed file handles. So .run should
not even directly organize the internal databases as sibling folders.
Moreover, the ThreadNet tests limit the ChainSync delays by construction
instead of dynamically.
The ThreadNet tests uses CoreNodeId whereas the real node uses RemoteAddress
(ie SockAddr) and LocalAddress (ie FilePath).
The cardano-node invocation currently uses these functions. We therefore add
sufficient corresponding fields to StdRunNodeArgs so that the cardano-node
invocation can be simplified: it just passes the data without having to first
interpret it as these customisation functions.
It is not an option the real node likely has to override, better to not require
them to provide it.
Copy link
Contributor

@mrBliss mrBliss left a comment

Choose a reason for hiding this comment

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

@nfrisby I left a number of comments, but you can ignore them as I addressed (most of) them. I have pushed a few more commits. Let me know whether you agree with them.

ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
mrBliss added a commit to IntersectMBO/cardano-node that referenced this pull request Nov 12, 2020
In IntersectMBO/ouroboros-network#2720 we reorganised
the arguments to `Node.run` so that the consensus ThreadNet tests can use the
same `Node.run` function as the real node while using a custom network layer.

In this commit we propagate that change.

For people that want to override some arguments that now seem to have
disappeared: they have been moved to the `LowLevelRunNodeArgs` record in
consensus. See the `stdLowLevelRunNodeArgsIO` and `Node.runWith` functions for
constructing and running with custom `LowLevelRunNodeArgs`.
@mrBliss
Copy link
Contributor

mrBliss commented Nov 12, 2020

I have opened a draft PR in cardano-node propagating this change: IntersectMBO/cardano-node#2080

mrBliss added a commit to IntersectMBO/cardano-node that referenced this pull request Nov 12, 2020
In IntersectMBO/ouroboros-network#2720 we reorganised
the arguments to `Node.run` so that the consensus ThreadNet tests can use the
same `Node.run` function as the real node while using a custom network layer.

In this commit we propagate that change.

For people that want to override some arguments that now seem to have
disappeared: they have been moved to the `LowLevelRunNodeArgs` record in
consensus. See the `stdLowLevelRunNodeArgsIO` and `Node.runWith` functions for
constructing and running with custom `LowLevelRunNodeArgs`.
Left-over from alignment in the distant past.
In `cardano-node`, the default values for node-to-node and node-to-client
versions are used. The only reason for having them in `RunNodeArgs` was to make
it possible for the network team to test the node with different versions. They
can still do this by using `.runWith` and `stdLowLevelRunNodeArgsIO`, and
overriding the fields manually.
`RunNodeArgs` contains the `ProtocolInfo`, which already contains the
`NetworkMagic`. So don't require it in `StdRunNodeArgs` but derive it from the
`RunNodeArgs`. This means we have to pass `RunNodeArgs` to
`stdLowLevelRunNodeArgsIO`.
@mrBliss
Copy link
Contributor

mrBliss commented Nov 12, 2020

bors merge

mrBliss added a commit to IntersectMBO/cardano-node that referenced this pull request Nov 12, 2020
In IntersectMBO/ouroboros-network#2720 we reorganised
the arguments to `Node.run` so that the consensus ThreadNet tests can use the
same `Node.run` function as the real node while using a custom network layer.

In this commit we propagate that change.

For people that want to override some arguments that now seem to have
disappeared: they have been moved to the `LowLevelRunNodeArgs` record in
consensus. See the `stdLowLevelRunNodeArgsIO` and `Node.runWith` functions for
constructing and running with custom `LowLevelRunNodeArgs`.
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Nov 12, 2020

Build succeeded:

@iohk-bors iohk-bors bot merged commit 35c5950 into master Nov 12, 2020
@iohk-bors iohk-bors bot deleted the nfrisby/generalize-node-run branch November 12, 2020 16:00
iohk-bors bot added a commit to IntersectMBO/cardano-node that referenced this pull request Nov 12, 2020
2080: Adapt to the reorganised Node.run arguments in consensus r=intricate a=mrBliss

In IntersectMBO/ouroboros-network#2720 we reorganised
the arguments to `Node.run` so that the consensus ThreadNet tests can use the
same `Node.run` function as the real node while using a custom network layer.

In this commit we propagate that change.

For people that want to override some arguments that now seem to have
disappeared: they have been moved to the `LowLevelRunNodeArgs` record in
consensus. See the `stdLowLevelRunNodeArgsIO` and `Node.runWith` functions for
constructing and running with custom `LowLevelRunNodeArgs`.

Co-authored-by: Thomas Winant <thomas@well-typed.com>
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.

2 participants