Skip to content

Commit

Permalink
consensus: make the protocol versions a low-level argument
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrBliss committed Nov 12, 2020
1 parent f188480 commit 8343f4a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions ouroboros-consensus/src/Ouroboros/Consensus/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ data RunNodeArgs m addrNTN addrNTC blk = RunNodeArgs {
-- | Protocol info
, rnProtocolInfo :: ProtocolInfo m blk

-- | node-to-node protocol versions to run.
, rnNodeToNodeVersions :: Map NodeToNodeVersion (BlockNodeToNodeVersion blk)

-- | node-to-client protocol versions to run.
, rnNodeToClientVersions :: Map NodeToClientVersion (BlockNodeToClientVersion blk)

-- | Hook called after the initialisation of the 'NodeKernel'
--
-- Called on the 'NodeKernel' after creating it, but before the network
Expand Down Expand Up @@ -195,6 +189,12 @@ data LowLevelRunNodeArgs m addrNTN addrNTC versionDataNTN versionDataNTC blk = L

, llrnVersionDataNTN :: versionDataNTN

-- | node-to-node protocol versions to run.
, llrnNodeToNodeVersions :: Map NodeToNodeVersion (BlockNodeToNodeVersion blk)

-- | node-to-client protocol versions to run.
, llrnNodeToClientVersions :: Map NodeToClientVersion (BlockNodeToClientVersion blk)

-- | Maximum clock skew
, llrnMaxClockSkew :: ClockSkew
}
Expand Down Expand Up @@ -354,21 +354,21 @@ runWith RunNodeArgs{..} LowLevelRunNodeArgs{..} =
version
llrnVersionDataNTN
(NTN.responder miniProtocolParams version $ ntnApps blockVersion)
| (version, blockVersion) <- Map.toList rnNodeToNodeVersions
| (version, blockVersion) <- Map.toList llrnNodeToNodeVersions
]
, daInitiatorApplication = combineVersions [
simpleSingletonVersions
version
llrnVersionDataNTN
(NTN.initiator miniProtocolParams version $ ntnApps blockVersion)
| (version, blockVersion) <- Map.toList rnNodeToNodeVersions
| (version, blockVersion) <- Map.toList llrnNodeToNodeVersions
]
, daLocalResponderApplication = combineVersions [
simpleSingletonVersions
version
llrnVersionDataNTC
(NTC.responder version $ ntcApps blockVersion)
| (version, blockVersion) <- Map.toList rnNodeToClientVersions
| (version, blockVersion) <- Map.toList llrnNodeToClientVersions
]
, daErrorPolicies = consensusErrorPolicy
}
Expand Down Expand Up @@ -618,8 +618,9 @@ data StdRunNodeArgs m blk = StdRunNodeArgs

-- | Conveniently packaged 'LowLevelRunNodeArgs' arguments from a standard
-- non-testing invocation.
stdLowLevelRunNodeArgsIO :: forall blk.
StdRunNodeArgs IO blk
stdLowLevelRunNodeArgsIO ::
forall blk. RunNode blk
=> StdRunNodeArgs IO blk
-> IO (LowLevelRunNodeArgs
IO
RemoteAddress
Expand Down Expand Up @@ -648,6 +649,10 @@ stdLowLevelRunNodeArgsIO StdRunNodeArgs{..} = do
stdVersionDataNTN
srnNetworkMagic
(daDiffusionMode srnDiffusionArguments)
, llrnNodeToNodeVersions =
supportedNodeToNodeVersions (Proxy @blk)
, llrnNodeToClientVersions =
supportedNodeToClientVersions (Proxy @blk)
, llrnWithCheckedDB =
stdWithCheckedDB srnDatabasePath srnNetworkMagic
, llrnMaxClockSkew =
Expand Down

0 comments on commit 8343f4a

Please sign in to comment.