From cba978ee7574aefa5de65f1314434ee2608e3138 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 19:30:09 +0300 Subject: [PATCH 1/6] test genesis: regenerate --- configuration/1c1cf/GENHASH | 1 + .../{c0c75 => 1c1cf}/delegate-keys.000.key | 0 .../{c0c75 => 1c1cf}/delegate-keys.001.key | Bin .../{c0c75 => 1c1cf}/delegate-keys.002.key | Bin .../{c0c75 => 1c1cf}/delegate-keys.003.key | 0 .../{c0c75 => 1c1cf}/delegate-keys.004.key | 0 .../{c0c75 => 1c1cf}/delegate-keys.005.key | 0 .../{c0c75 => 1c1cf}/delegate-keys.006.key | 0 .../{c0c75 => 1c1cf}/delegation-cert.000.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.001.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.002.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.003.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.004.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.005.json | 0 .../{c0c75 => 1c1cf}/delegation-cert.006.json | 0 configuration/{c0c75 => 1c1cf}/genesis.json | 2 +- configuration/c0c75/GENHASH | 1 - configuration/log-config-0.yaml | 2 +- configuration/log-config-1.yaml | 2 +- configuration/log-config-2.yaml | 2 +- scripts/issue-genesis-utxo-expenditure.sh | 2 +- scripts/lib-node.sh | 2 +- 22 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 configuration/1c1cf/GENHASH rename configuration/{c0c75 => 1c1cf}/delegate-keys.000.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.001.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.002.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.003.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.004.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.005.key (100%) rename configuration/{c0c75 => 1c1cf}/delegate-keys.006.key (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.000.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.001.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.002.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.003.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.004.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.005.json (100%) rename configuration/{c0c75 => 1c1cf}/delegation-cert.006.json (100%) rename configuration/{c0c75 => 1c1cf}/genesis.json (99%) delete mode 100644 configuration/c0c75/GENHASH diff --git a/configuration/1c1cf/GENHASH b/configuration/1c1cf/GENHASH new file mode 100644 index 00000000000..0922782ff71 --- /dev/null +++ b/configuration/1c1cf/GENHASH @@ -0,0 +1 @@ +1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e diff --git a/configuration/c0c75/delegate-keys.000.key b/configuration/1c1cf/delegate-keys.000.key similarity index 100% rename from configuration/c0c75/delegate-keys.000.key rename to configuration/1c1cf/delegate-keys.000.key diff --git a/configuration/c0c75/delegate-keys.001.key b/configuration/1c1cf/delegate-keys.001.key similarity index 100% rename from configuration/c0c75/delegate-keys.001.key rename to configuration/1c1cf/delegate-keys.001.key diff --git a/configuration/c0c75/delegate-keys.002.key b/configuration/1c1cf/delegate-keys.002.key similarity index 100% rename from configuration/c0c75/delegate-keys.002.key rename to configuration/1c1cf/delegate-keys.002.key diff --git a/configuration/c0c75/delegate-keys.003.key b/configuration/1c1cf/delegate-keys.003.key similarity index 100% rename from configuration/c0c75/delegate-keys.003.key rename to configuration/1c1cf/delegate-keys.003.key diff --git a/configuration/c0c75/delegate-keys.004.key b/configuration/1c1cf/delegate-keys.004.key similarity index 100% rename from configuration/c0c75/delegate-keys.004.key rename to configuration/1c1cf/delegate-keys.004.key diff --git a/configuration/c0c75/delegate-keys.005.key b/configuration/1c1cf/delegate-keys.005.key similarity index 100% rename from configuration/c0c75/delegate-keys.005.key rename to configuration/1c1cf/delegate-keys.005.key diff --git a/configuration/c0c75/delegate-keys.006.key b/configuration/1c1cf/delegate-keys.006.key similarity index 100% rename from configuration/c0c75/delegate-keys.006.key rename to configuration/1c1cf/delegate-keys.006.key diff --git a/configuration/c0c75/delegation-cert.000.json b/configuration/1c1cf/delegation-cert.000.json similarity index 100% rename from configuration/c0c75/delegation-cert.000.json rename to configuration/1c1cf/delegation-cert.000.json diff --git a/configuration/c0c75/delegation-cert.001.json b/configuration/1c1cf/delegation-cert.001.json similarity index 100% rename from configuration/c0c75/delegation-cert.001.json rename to configuration/1c1cf/delegation-cert.001.json diff --git a/configuration/c0c75/delegation-cert.002.json b/configuration/1c1cf/delegation-cert.002.json similarity index 100% rename from configuration/c0c75/delegation-cert.002.json rename to configuration/1c1cf/delegation-cert.002.json diff --git a/configuration/c0c75/delegation-cert.003.json b/configuration/1c1cf/delegation-cert.003.json similarity index 100% rename from configuration/c0c75/delegation-cert.003.json rename to configuration/1c1cf/delegation-cert.003.json diff --git a/configuration/c0c75/delegation-cert.004.json b/configuration/1c1cf/delegation-cert.004.json similarity index 100% rename from configuration/c0c75/delegation-cert.004.json rename to configuration/1c1cf/delegation-cert.004.json diff --git a/configuration/c0c75/delegation-cert.005.json b/configuration/1c1cf/delegation-cert.005.json similarity index 100% rename from configuration/c0c75/delegation-cert.005.json rename to configuration/1c1cf/delegation-cert.005.json diff --git a/configuration/c0c75/delegation-cert.006.json b/configuration/1c1cf/delegation-cert.006.json similarity index 100% rename from configuration/c0c75/delegation-cert.006.json rename to configuration/1c1cf/delegation-cert.006.json diff --git a/configuration/c0c75/genesis.json b/configuration/1c1cf/genesis.json similarity index 99% rename from configuration/c0c75/genesis.json rename to configuration/1c1cf/genesis.json index d6d59ef6b0f..c3b78d9a10f 100644 --- a/configuration/c0c75/genesis.json +++ b/configuration/1c1cf/genesis.json @@ -72,7 +72,7 @@ "33337aeeaddce8232018ab9397bbe7301fe7a533fc57c91005ea3dc42df2a9ca3e439d6f3b69b551d5642035efbe77fe1af102530448e7cf677571b1bafef903" } } -, "startTime": 1572966898 +, "startTime": 1574267256 , "nonAvvmBalances": { "2cWKMJemoBah9iKNcAX92Hd7fcvKf43YnTQRWWVhGaKzXjMj1bZJBzNDRZRkBHKmF3pcW": "5250000000000" diff --git a/configuration/c0c75/GENHASH b/configuration/c0c75/GENHASH deleted file mode 100644 index 70baf25914e..00000000000 --- a/configuration/c0c75/GENHASH +++ /dev/null @@ -1 +0,0 @@ -c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e diff --git a/configuration/log-config-0.yaml b/configuration/log-config-0.yaml index b395db1ae36..e6edd82aaff 100644 --- a/configuration/log-config-0.yaml +++ b/configuration/log-config-0.yaml @@ -93,7 +93,7 @@ options: NodeId: 0 Protocol: RealPBFT -GenesisHash: c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e +GenesisHash: 1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: 0.7 diff --git a/configuration/log-config-1.yaml b/configuration/log-config-1.yaml index a6d86b9d254..e2d3bc7b607 100644 --- a/configuration/log-config-1.yaml +++ b/configuration/log-config-1.yaml @@ -95,7 +95,7 @@ options: NodeId: 1 Protocol: RealPBFT -GenesisHash: c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e +GenesisHash: 1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: 0.7 diff --git a/configuration/log-config-2.yaml b/configuration/log-config-2.yaml index 92a1f9730f8..1c1f74ff495 100644 --- a/configuration/log-config-2.yaml +++ b/configuration/log-config-2.yaml @@ -99,7 +99,7 @@ options: NodeId: 2 Protocol: RealPBFT -GenesisHash: c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e +GenesisHash: 1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e NumCoreNodes: 1 RequiresNetworkMagic: RequiresMagic PBftSignatureThreshold: 0.7 diff --git a/scripts/issue-genesis-utxo-expenditure.sh b/scripts/issue-genesis-utxo-expenditure.sh index ad7be321690..1222d6b00d7 100755 --- a/scripts/issue-genesis-utxo-expenditure.sh +++ b/scripts/issue-genesis-utxo-expenditure.sh @@ -2,7 +2,7 @@ RUNNER=${RUNNER:-cabal new-run -v0 --} -genesis_hash="c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e" +genesis_hash="1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e" genesis_file="${genesis_root}/genesis.json" from_addr="2cWKMJemoBain3UWCzSY5wZvcf8uQ2MAaSy8hedrwpqsbYCm4QnBgPn3cEH7KF3X7DKoZ" diff --git a/scripts/lib-node.sh b/scripts/lib-node.sh index bf3d87b7ec0..84abb23edc3 100644 --- a/scripts/lib-node.sh +++ b/scripts/lib-node.sh @@ -1,6 +1,6 @@ set -x -genesis_hash="c0c757817d86660accdc45b9d18c1274d51d6427b92995944d014e0ff056cb3e" +genesis_hash="1c1cf538d599170f4ed8a4cf8fcb3ef2e530e30a6de15e74b4088c002797972e" genesis="$(echo ${genesis_hash} | cut -c-5 | xargs echo -n)" genesis_root="configuration/${genesis}" From 7d517e24e7908fb0c95abb776e4540ed6adcbe5a Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 19:17:39 +0300 Subject: [PATCH 2/6] globally: eliminate `NetworkTopology` and `TopologyInfo` --- cardano-config/src/Cardano/Config/Partial.hs | 4 +- cardano-config/src/Cardano/Config/Presets.hs | 9 +-- cardano-config/src/Cardano/Config/Topology.hs | 57 +++---------------- cardano-config/src/Cardano/Config/Types.hs | 4 +- cardano-node/src/Cardano/CLI/Run.hs | 8 +-- cardano-node/src/Cardano/CLI/Tx.hs | 15 +++-- cardano-node/src/Cardano/CLI/Tx/Generation.hs | 50 +++++++--------- cardano-node/src/Cardano/CLI/Tx/Submission.hs | 26 +-------- cardano-node/src/Cardano/Common/Parsers.hs | 16 +----- cardano-node/src/Cardano/Node/Run.hs | 24 ++------ 10 files changed, 59 insertions(+), 154 deletions(-) diff --git a/cardano-config/src/Cardano/Config/Partial.hs b/cardano-config/src/Cardano/Config/Partial.hs index a0289c562f2..c71d8302bd5 100644 --- a/cardano-config/src/Cardano/Config/Partial.hs +++ b/cardano-config/src/Cardano/Config/Partial.hs @@ -42,7 +42,7 @@ data PartialCardanoConfiguration = PartialCardanoConfiguration , pccDBPath :: !(Last FilePath) , pccSocketDir :: !(Last FilePath) , pccApplicationLockFile :: !(Last FilePath) - , pccTopologyInfo :: !(Last TopologyInfo) + , pccNodeSetup :: !(Last FilePath) , pccNodeAddress :: !(Last NodeAddress) , pccProtocol :: !(Last Protocol) , pccViewMode :: !(Last ViewMode) @@ -233,7 +233,7 @@ mkCardanoConfiguration PartialCardanoConfiguration{..} = do ccApplicationLockFile <- mkComplete "ccApplicationLockFile" pccApplicationLockFile - ccTopologyInfo <- mkComplete "ccTopologyInfo" pccTopologyInfo + ccNodeSetup <- mkComplete "ccNodeSetup" pccNodeSetup ccNodeAddress <- mkComplete "ccNodeAddress" pccNodeAddress ccProtocol <- mkComplete "ccProtocol" pccProtocol ccViewMode <- mkComplete "ccViewMode" pccViewMode diff --git a/cardano-config/src/Cardano/Config/Presets.hs b/cardano-config/src/Cardano/Config/Presets.hs index 67a4a5180fe..530a5cccc4e 100644 --- a/cardano-config/src/Cardano/Config/Presets.hs +++ b/cardano-config/src/Cardano/Config/Presets.hs @@ -7,8 +7,6 @@ module Cardano.Config.Presets import Cardano.Prelude -import Ouroboros.Consensus.NodeId - import Cardano.Config.Defaults (traceOptionsDefault) import Cardano.Config.Partial ( NodeProtocol (..) , PartialBlock (..) @@ -25,8 +23,7 @@ import Cardano.Config.Partial ( NodeProtocol (..) , PartialWallet (..) , RequireNetworkMagic (..) ) -import Cardano.Config.Topology (NodeAddress(..), NodeHostAddress(..), - TopologyInfo(..)) +import Cardano.Config.Topology (NodeAddress(..), NodeHostAddress(..)) import Cardano.Config.Types (Protocol(..), ViewMode(..)) -------------------------------------------------------------------------------- @@ -40,7 +37,7 @@ mainnetConfiguration = , pccLogConfig = pure "./configuration/log-configuration.yaml" , pccDBPath = pure "./db/" , pccApplicationLockFile = pure "" - , pccTopologyInfo = pure $ TopologyInfo (RelayId 0) "./configuration/simple-topology.json" + , pccNodeSetup = pure $ "./configuration/simple-topology-0.json" , pccNodeAddress = pure $ NodeAddress (NodeHostAddress Nothing) 7000 , pccProtocol = pure ByronLegacy , pccViewMode = pure LiveView @@ -158,7 +155,7 @@ devConfiguration = , pccLogConfig = pure "./log-config.yaml" , pccSocketDir = pure "./socket/" , pccApplicationLockFile = pure "" - , pccTopologyInfo = pure $ TopologyInfo (RelayId 0) "./configuration/simple-topology.json" + , pccNodeSetup = pure $ "./configuration/simple-topology-0.json" , pccNodeAddress = pure $ NodeAddress (NodeHostAddress Nothing) 7000 , pccProtocol = pure ByronLegacy , pccViewMode = pure LiveView diff --git a/cardano-config/src/Cardano/Config/Topology.hs b/cardano-config/src/Cardano/Config/Topology.hs index a7d66adefae..f954d20e8c2 100644 --- a/cardano-config/src/Cardano/Config/Topology.hs +++ b/cardano-config/src/Cardano/Config/Topology.hs @@ -6,17 +6,13 @@ {-# OPTIONS_GHC -Wno-all-missed-specialisations #-} module Cardano.Config.Topology - ( TopologyError(..) - , TopologyInfo(..) - , NetworkTopology(..) - , NodeAddress(..) + ( NodeAddress(..) , NodeHostAddress(..) , NodeSetup(..) , RemoteAddress(..) - , createNodeAddress , nodeAddressInfo , nodeAddressToSockAddr - , readTopologyFile + , readNodeSetup , remoteAddressToNodeAddress ) where @@ -39,15 +35,6 @@ import Ouroboros.Consensus.NodeId (NodeId(..)) import Ouroboros.Consensus.Util.Condense (Condense (..)) -newtype TopologyError = NodeIdNotFoundInToplogyFile FilePath deriving Show - --- | A data structure bundling together a node identifier and the path to --- the topology file. -data TopologyInfo = TopologyInfo - { node :: NodeId - , topologyFile :: FilePath - } deriving (Eq, Show) - -- | IPv4 address with a port number. data NodeAddress = NodeAddress { naHostAddress :: !NodeHostAddress @@ -108,7 +95,7 @@ data RemoteAddress = RemoteAddress -- | Parse 'raAddress' field as an IP address; if it parses and the valency is -- non zero return corresponding NodeAddress. -- -remoteAddressToNodeAddress:: RemoteAddress-> Maybe NodeAddress +remoteAddressToNodeAddress :: RemoteAddress -> Maybe NodeAddress remoteAddressToNodeAddress (RemoteAddress addrStr port val) = case readMaybe addrStr of Nothing -> Nothing @@ -116,7 +103,6 @@ remoteAddressToNodeAddress (RemoteAddress addrStr port val) = then Just $ NodeAddress (NodeHostAddress $ Just addr) port else Nothing - instance Condense RemoteAddress where condense (RemoteAddress addr port val) = addr ++ ":" ++ show port ++ " (" ++ show val ++ ")" @@ -129,47 +115,22 @@ instance FromJSON RemoteAddress where <*> (v .: "valency") data NodeSetup = NodeSetup - { nodeId :: !Int - , nodeAddress :: !NodeAddress + { nodeAddress :: !NodeAddress , producers :: ![RemoteAddress] - } deriving Show + } deriving (Show) instance FromJSON NodeId where parseJSON v = CoreId <$> parseJSON v deriveFromJSON defaultOptions ''NodeSetup -data NetworkTopology = NetworkTopology [NodeSetup] - deriving Show - -deriveFromJSON defaultOptions ''NetworkTopology - --- | Creates a 'NodeAddress' if it exists in a given 'NetworkTopology'. -createNodeAddress - :: NodeId - -> NetworkTopology - -> FilePath - -> Either TopologyError NodeAddress -createNodeAddress _nodeId (NetworkTopology nodeSetups) fp = - case maybeNode of - Nothing -> Left $ NodeIdNotFoundInToplogyFile fp - Just (NodeSetup _ anAddress _) -> Right anAddress - where - idInt :: Int - idInt = case _nodeId of - CoreId i -> i - RelayId i -> i - -- Search 'NetworkTopology' for a given 'NodeId' - maybeNode :: Maybe NodeSetup - maybeNode = find (\(NodeSetup nId _ _) -> idInt == nId) nodeSetups - -readTopologyFile :: FilePath -> IO (Either String NetworkTopology) -readTopologyFile topo = do - eBs <- Exception.try $ BS.readFile topo +readNodeSetup :: FilePath -> IO (Either String NodeSetup) +readNodeSetup f = do + eBs <- Exception.try $ BS.readFile f case eBs of Left e -> pure . Left $ handler e Right bs -> pure . eitherDecode $ toS bs where handler :: IOException -> String - handler e = "Cardano.Node.Configuration.Topology.readTopologyFile: " + handler e = "Cardano.Node.Configuration.Topology.readNodeSetup: " ++ displayException e diff --git a/cardano-config/src/Cardano/Config/Types.hs b/cardano-config/src/Cardano/Config/Types.hs index 2a3035e09e6..c8727394f70 100644 --- a/cardano-config/src/Cardano/Config/Types.hs +++ b/cardano-config/src/Cardano/Config/Types.hs @@ -102,8 +102,8 @@ data CardanoConfiguration = CardanoConfiguration -- instance at a time. , ccTraceOptions :: !TraceOptions -- ^ Tracer options - , ccTopologyInfo :: !TopologyInfo - -- ^ The network topology. + , ccNodeSetup :: !FilePath + -- ^ Location of the node's network setup file. , ccNodeAddress :: !NodeAddress -- ^ The node ip address and port number. , ccProtocol :: !Protocol diff --git a/cardano-node/src/Cardano/CLI/Run.hs b/cardano-node/src/Cardano/CLI/Run.hs index 4bd62d872c2..b3aaa859d0c 100644 --- a/cardano-node/src/Cardano/CLI/Run.hs +++ b/cardano-node/src/Cardano/CLI/Run.hs @@ -64,6 +64,7 @@ import qualified Cardano.Crypto.Signing as Crypto import qualified Test.Cardano.Chain.Genesis.Dummy as Dummy +import Ouroboros.Consensus.NodeId (NodeId(..)) import qualified Ouroboros.Consensus.Protocol as Consensus import Cardano.CLI.Delegation @@ -86,7 +87,6 @@ import Cardano.Config.Types (CardanoConfiguration(..), ConfigYamlFileP SigningKeyFile(..), TopologyFile(..), parseNodeConfiguration) import Cardano.Config.Logging (LoggingLayer (..)) -import Cardano.Config.Topology (TopologyInfo(..)) -- | Sub-commands of 'cardano-cli'. data ClientCommand @@ -230,9 +230,8 @@ runCommand _ _(CheckDelegation magic cert issuerVF delegateVF) = do runCommand _ _(SubmitTx fp nCli) = do nc <- liftIO . parseNodeConfiguration . unConfigPath $ configFp nCli - let topologyFp = unTopology . topFile $ mscFp nCli tx <- liftIO $ readByronTx fp - liftIO $ nodeSubmitTx (TopologyInfo (ncNodeId nc) topologyFp) nc nCli tx + liftIO $ nodeSubmitTx (ncNodeId nc) nc nCli tx runCommand _ _(SpendGenesisUTxO (NewTxFile ctTx) ctKey genRichAddr outs nCli) = do nc <- liftIO . parseNodeConfiguration . unConfigPath $ configFp nCli @@ -265,7 +264,8 @@ runCommand _ loggingLayer loggingLayer nCli protocol - (TopologyInfo (ncNodeId nc) topologyFp) + topologyFp + (CoreId 0) targetNodeIds numOfTxs numOfInsPerTx diff --git a/cardano-node/src/Cardano/CLI/Tx.hs b/cardano-node/src/Cardano/CLI/Tx.hs index c951f35336d..7000b93a8f5 100644 --- a/cardano-node/src/Cardano/CLI/Tx.hs +++ b/cardano-node/src/Cardano/CLI/Tx.hs @@ -44,14 +44,16 @@ import qualified Cardano.Crypto.Signing as Crypto import qualified Ouroboros.Consensus.Ledger.Byron as Byron import Ouroboros.Consensus.Ledger.Byron (GenTx(..), ByronBlock) -import qualified Ouroboros.Consensus.Protocol as Consensus +import Ouroboros.Consensus.Node.ProtocolInfo ( ProtocolInfo(..) + , protocolInfo) import Ouroboros.Consensus.Node.Run (RunNode) +import Ouroboros.Consensus.NodeId (NodeId(..)) +import qualified Ouroboros.Consensus.Protocol as Consensus import Cardano.CLI.Ops import Cardano.CLI.Tx.Submission import Cardano.Config.Protocol import Cardano.Config.Types (NodeCLI, NodeConfiguration(..)) -import Cardano.Config.Topology import Cardano.Common.Orphans () @@ -223,17 +225,18 @@ issueUTxOExpenditure ins outs nc nCli key = do throwIO $ InvariantViolation $ "Invariant violation: a non-ByronTx GenTx out of 'txSpendUTxOByronPBFT': " <> show x --- | Submit a transaction to a node specified by topology info. +-- | Submit a transaction to a node specified by node setup, +-- using the local submission protocol. nodeSubmitTx - :: TopologyInfo + :: NodeId -> NodeConfiguration -> NodeCLI -> GenTx ByronBlock -> IO () -nodeSubmitTx topology nc nCli gentx = +nodeSubmitTx targetNodeId nc nCli gentx = withRealPBFT nc nCli $ \p@Consensus.ProtocolRealPBFT{} -> do case gentx of ByronTx txid _ -> putStrLn $ sformat ("TxId: "%Crypto.hashHexF) txid _ -> pure () - handleTxSubmission nCli p topology gentx stdoutTracer + submitTx nCli (pInfoConfig (protocolInfo p)) targetNodeId gentx stdoutTracer diff --git a/cardano-node/src/Cardano/CLI/Tx/Generation.hs b/cardano-node/src/Cardano/CLI/Tx/Generation.hs index af0fcede0ca..427bb573a70 100644 --- a/cardano-node/src/Cardano/CLI/Tx/Generation.hs +++ b/cardano-node/src/Cardano/CLI/Tx/Generation.hs @@ -32,7 +32,6 @@ import Control.Monad (forM, forM_, mapM, when) import qualified Control.Monad.Class.MonadSTM as MSTM import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, - hoistEither, left, newExceptT, right) import Data.Bifunctor (bimap) @@ -43,7 +42,7 @@ import qualified Data.IP as IP import Data.List ((!!), last) import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NE -import Data.Maybe (Maybe (..), fromMaybe, listToMaybe, mapMaybe) +import Data.Maybe (Maybe (..), catMaybes, fromMaybe, listToMaybe, mapMaybe) import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Set (Set) @@ -67,13 +66,12 @@ import qualified Cardano.Chain.MempoolPayload as CC.Mempool import qualified Cardano.Chain.UTxO as CC.UTxO import Cardano.Config.Logging (LoggingLayer (..), Trace) import Cardano.Config.Types (NodeCLI(..)) +import Cardano.Config.Topology (NodeSetup(..)) import qualified Cardano.Crypto as Crypto import Cardano.Config.Topology (NodeAddress (..), NodeHostAddress(..), - TopologyError(..), - TopologyInfo (..), - createNodeAddress, - readTopologyFile) + readNodeSetup, + remoteAddressToNodeAddress) import Cardano.CLI.Tx (txSpendGenesisUTxOByronPBFT) import Cardano.CLI.Tx.BenchmarkingTxSubmission (ROEnv (..), TraceBenchTxSubmit (..), @@ -140,7 +138,6 @@ newtype TxAdditionalSize = data TxGenError = CurrentlyCannotSendTxToRelayNode FilePath -- ^ Relay nodes cannot currently be transaction recipients. | InsufficientFundsForRecipientTx - | TargetNodeAddressError TopologyError -- ^ Error occurred while creating the target node address. | TopologyFileReadError String | NeedMinimumOneTargetNodeId [TargetNodeId] @@ -160,7 +157,8 @@ genesisBenchmarkRunner :: LoggingLayer -> NodeCLI -> Consensus.Protocol ByronBlock - -> TopologyInfo + -> FilePath + -> NodeId -> [TargetNodeId] -> NumberOfTxs -> NumberOfInputsPerTx @@ -173,7 +171,8 @@ genesisBenchmarkRunner genesisBenchmarkRunner loggingLayer nCli protocol@(Consensus.ProtocolRealPBFT genesisConfig _ _ _ _) - topologyInfo + nodeSetupFile + preparationPhaseNodeId targetNodeIds numOfTxs@(NumberOfTxs rawNumOfTxs) numOfInsPerTx @@ -196,14 +195,9 @@ genesisBenchmarkRunner loggingLayer liftIO . traceWith benchTracer . TraceBenchTxSubDebug $ "******* Tx generator, protocol info and topology are ready *******" - -- We have to extract host and port of the nodes we want to talk with - -- (based on values of `--target-node-id` CLI argument) from the topology file. - topology <- firstExceptT TopologyFileReadError . newExceptT $ - readTopologyFile (topologyFile topologyInfo) - targetNodeAddresses <- forM targetNodeIds $ \(TargetNodeId targetNodeId) -> do - let eitherNodeAddress = createNodeAddress (CoreId targetNodeId) topology (topologyFile topologyInfo) - targetNodeAddress <- firstExceptT TargetNodeAddressError . hoistEither $ eitherNodeAddress - return targetNodeAddress + -- Extract hosts/ports of the nodes we'd like to converse with. + nodeSetup <- firstExceptT TopologyFileReadError . newExceptT $ readNodeSetup nodeSetupFile + let targetNodeAddresses = catMaybes $ remoteAddressToNodeAddress <$> producers nodeSetup liftIO . traceWith benchTracer . TraceBenchTxSubDebug $ "******* Tx generator, target node's address is ready *******" @@ -236,7 +230,7 @@ genesisBenchmarkRunner loggingLayer nCli genesisConfig pInfoConfig - topologyInfo + preparationPhaseNodeId genesisUtxo genesisAddress sourceAddress @@ -255,7 +249,7 @@ genesisBenchmarkRunner loggingLayer pInfoConfig sourceKey recipientAddress - topologyInfo + preparationPhaseNodeId targetNodeAddresses numOfTxs numOfInsPerTx @@ -430,7 +424,7 @@ prepareInitialFunds -> NodeCLI -> CC.Genesis.Config -> NodeConfig ByronConsensusProtocol - -> TopologyInfo + -> NodeId -> Map Int ((CC.UTxO.TxIn, CC.UTxO.TxOut), Crypto.SigningKey) -> CC.Common.Address -> CC.Common.Address @@ -440,7 +434,7 @@ prepareInitialFunds llTracer nCli genesisConfig pInfoConfig - topologyInfo + targetNodeId genesisUtxo genesisAddress targetAddress @@ -459,7 +453,7 @@ prepareInitialFunds llTracer genesisAddress (NE.fromList [outForBig]) - submitTx nCli pInfoConfig (node topologyInfo) genesisTx llTracer + submitTx nCli pInfoConfig targetNodeId genesisTx llTracer -- Done, the first transaction 'initGenTx' is submitted, now 'sourceAddress' has a lot of money. let txIn = CC.UTxO.TxInUtxo (getTxIdFromGenTx genesisTx) 0 @@ -686,7 +680,7 @@ runBenchmark -> NodeConfig ByronConsensusProtocol -> Crypto.SigningKey -> CC.Common.Address - -> TopologyInfo + -> NodeId -> [NodeAddress] -> NumberOfTxs -> NumberOfInputsPerTx @@ -703,7 +697,7 @@ runBenchmark benchTracer pInfoConfig sourceKey recipientAddress - topologyInfo + preparationPhaseNodeId targetNodeAddresses numOfTxs numOfInsPerTx @@ -719,7 +713,7 @@ runBenchmark benchTracer pInfoConfig sourceKey txFee - topologyInfo + preparationPhaseNodeId numOfTxs numOfInsPerTx @@ -807,7 +801,7 @@ createMoreFundCoins -> NodeConfig ByronConsensusProtocol -> Crypto.SigningKey -> FeePerTx - -> TopologyInfo + -> NodeId -> NumberOfTxs -> NumberOfInputsPerTx -> ExceptT TxGenError IO () @@ -816,7 +810,7 @@ createMoreFundCoins llTracer pInfoConfig sourceKey (FeePerTx txFee) - topologyInfo + preparationPhaseNodeId (NumberOfTxs numOfTxs) (NumberOfInputsPerTx numOfInsPerTx) = do let feePerTx = assumeBound . CC.Common.mkLovelace $ txFee @@ -854,7 +848,7 @@ createMoreFundCoins llTracer txOut [] liftIO $ forM_ splittingTxs $ \(tx, txDetailsList) -> do - submitTx nCli pInfoConfig (node topologyInfo) tx llTracer + submitTx nCli pInfoConfig preparationPhaseNodeId tx llTracer -- Update available fundValueStatus to reuse the numSplittingTxOuts TxOuts. forM_ txDetailsList addToAvailableFunds where diff --git a/cardano-node/src/Cardano/CLI/Tx/Submission.hs b/cardano-node/src/Cardano/CLI/Tx/Submission.hs index 5f3c4383156..e2375269ef3 100644 --- a/cardano-node/src/Cardano/CLI/Tx/Submission.hs +++ b/cardano-node/src/Cardano/CLI/Tx/Submission.hs @@ -8,8 +8,7 @@ {-# OPTIONS_GHC -Wno-all-missed-specialisations #-} module Cardano.CLI.Tx.Submission ( - handleTxSubmission - , submitTx + submitTx ) where import Cardano.Prelude hiding (ByteString, option, threadDelay) import Prelude (String) @@ -24,12 +23,9 @@ import Control.Tracer (Tracer, nullTracer, traceWith) import Ouroboros.Consensus.Block (BlockProtocol) import Ouroboros.Consensus.Mempool (ApplyTxErr, GenTx) -import Ouroboros.Consensus.Node.ProtocolInfo ( ProtocolInfo(..) - , protocolInfo) import Ouroboros.Consensus.Node.Run (RunNode) import qualified Ouroboros.Consensus.Node.Run as Node import Ouroboros.Consensus.NodeId (NodeId(..)) -import qualified Ouroboros.Consensus.Protocol as Consensus import Ouroboros.Consensus.Protocol hiding (Protocol) import Network.TypedProtocol.Driver (runPeer) @@ -47,7 +43,6 @@ import Ouroboros.Network.Protocol.Handshake.Version ( Versions , simpleSingletonVersions) import qualified Ouroboros.Network.NodeToClient as NodeToClient -import Cardano.Config.Topology import Cardano.Common.LocalSocket import Cardano.Config.Types (MiscellaneousFilepaths(..), NodeCLI(..), SocketFile(..)) @@ -59,25 +54,6 @@ import Cardano.Config.Types (MiscellaneousFilepaths(..), Main logic -------------------------------------------------------------------------------} --- | For a given protocol and configuration, submit the given GenTx to the node --- specified by topology info, while using tracer for logging. -handleTxSubmission :: forall blk. - ( RunNode blk - , Show (ApplyTxErr blk) - ) - => NodeCLI - -> Consensus.Protocol blk - -> TopologyInfo - -> GenTx blk - -> Tracer IO String - -> IO () -handleTxSubmission nCli ptcl tinfo tx tracer = do - let pinfo :: ProtocolInfo blk - pinfo = protocolInfo ptcl - - submitTx nCli (pInfoConfig pinfo) (node tinfo) tx tracer - - submitTx :: ( RunNode blk , Show (ApplyTxErr blk) ) diff --git a/cardano-node/src/Cardano/Common/Parsers.hs b/cardano-node/src/Cardano/Common/Parsers.hs index 6ce3f468e14..c39fa947fdb 100644 --- a/cardano-node/src/Cardano/Common/Parsers.hs +++ b/cardano-node/src/Cardano/Common/Parsers.hs @@ -19,7 +19,6 @@ module Cardano.Common.Parsers , parseProtocolMockPBFT , parseProtocolPraos , parseProtocolRealPBFT - , parseTopologyInfo , parseTraceOptions ) where @@ -34,7 +33,7 @@ import qualified Options.Applicative as Opt import Cardano.BM.Data.Tracer (TracingVerbosity (..)) import Cardano.Config.Logging (LoggingCLIArguments(..)) -import Ouroboros.Consensus.NodeId (NodeId(..), CoreNodeId(..)) +import Ouroboros.Consensus.NodeId (CoreNodeId(..)) import Ouroboros.Consensus.NodeNetwork (ProtocolTracers'(..)) import qualified Ouroboros.Consensus.Node.Tracers as Consensus @@ -111,14 +110,6 @@ parseCoreNodeId = <> help "The ID of the core node to which this client is connected." ) -parseNodeId :: String -> Parser NodeId -parseNodeId desc = - option (fmap CoreId auto) ( - long "node-id" - <> metavar "NODE-ID" - <> help desc - ) - parseNodeAddress :: Parser NodeAddress parseNodeAddress = NodeAddress <$> parseHostAddr <*> parsePort @@ -196,10 +187,6 @@ parseProtocolRealPBFT = "real-pbft" "Permissive BFT consensus with a real ledger" - -parseTopologyInfo :: String -> Parser TopologyInfo -parseTopologyInfo desc = TopologyInfo <$> parseNodeId desc <*> parseTopologyFile - parseTopologyFile :: Parser FilePath parseTopologyFile = strOption ( @@ -207,6 +194,7 @@ parseTopologyFile = <> metavar "FILEPATH" <> help "The path to a file describing the topology." ) + parseLogOutputFile :: Parser FilePath parseLogOutputFile = strOption diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index c4730e9137b..106e6e59fea 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -28,7 +28,6 @@ import Control.Tracer import qualified Data.ByteString.Char8 as BSC import Data.Either (partitionEithers) import Data.Functor.Contravariant (contramap) -import qualified Data.List as List import Data.Proxy (Proxy (..)) import Data.Semigroup ((<>)) import Data.Text (Text, breakOn, pack, take) @@ -56,7 +55,6 @@ import Ouroboros.Consensus.Node (NodeKernel (getChainDB), RunNode (nodeNetworkMagic, nodeStartTime)) import qualified Ouroboros.Consensus.Node as Node (run) import Ouroboros.Consensus.Node.ProtocolInfo -import Ouroboros.Consensus.NodeId import qualified Ouroboros.Consensus.Protocol as Consensus import Ouroboros.Consensus.Util.Condense import Ouroboros.Consensus.Util.Orphans () @@ -147,8 +145,8 @@ handleSimpleNode :: forall blk. RunNode blk -> NodeConfiguration -> IO () handleSimpleNode p trace nodeTracers nCli nc = do - NetworkTopology nodeSetups <- - either error id <$> readTopologyFile (unTopology . topFile $ mscFp nCli) + nodeSetup <- + either error id <$> readNodeSetup (unTopology . topFile $ mscFp nCli) let pInfo@ProtocolInfo{ pInfoConfig = cfg } = protocolInfo p @@ -156,18 +154,11 @@ handleSimpleNode p trace nodeTracers nCli nc = do traceWith tracer $ "System started at " <> show (nodeStartTime (Proxy @blk) cfg) - let producers' = case List.lookup nid $ - map (\ns -> (nodeId ns, producers ns)) nodeSetups of - Just ps -> ps - Nothing -> error $ "handleSimpleNode: own address " - <> show (nodeAddr nCli) - <> ", Node Id " - <> show nid - <> " not found in topology" + let producers' = producers nodeSetup traceWith tracer $ unlines [ "**************************************" - , "I am Node " <> show (nodeAddr nCli) <> " Id: " <> show nid + , "I am Node " <> show (nodeAddr nCli) , "My producers are " <> show producers' , "**************************************" ] @@ -227,7 +218,7 @@ handleSimpleNode p trace nodeTracers nCli nc = do (consensusTracers nodeTracers) (withTip varTip $ chainDBTracer nodeTracers) runNetworkArgs - (dbPath <> "-" <> show nid) + dbPath pInfo id -- No ChainDbArgs customisation id -- No NodeParams customisation @@ -237,8 +228,3 @@ handleSimpleNode p trace nodeTracers nCli nc = do let chainDB = getChainDB nodeKernel onEachChange registry id Nothing (ChainDB.getTipPoint chainDB) $ \tip -> atomically $ writeTVar varTip tip - where - nid :: Int - nid = case ncNodeId nc of - CoreId n -> n - RelayId _ -> error "Non-core nodes currently not supported" From 07653bfc1e09040b088b8f211cedb6e4f1db6b1c Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 19:18:16 +0300 Subject: [PATCH 3/6] scripts & configuration: update to the topology trimming --- benchmarking/trace-acceptor.sh | 2 +- configuration/simple-topology-0.json | 15 +++++++ configuration/simple-topology-1.json | 15 +++++++ configuration/simple-topology-2.json | 15 +++++++ configuration/simple-topology.json | 50 ----------------------- scripts/chairman.sh | 2 +- scripts/generator.sh | 2 +- scripts/issue-genesis-utxo-expenditure.sh | 2 +- scripts/issue-utxo-expenditure.sh | 2 +- scripts/lib-node.sh | 8 ++-- scripts/shelley-testnet-dns.sh | 2 +- scripts/start-node.sh | 2 +- scripts/submit-tx.sh | 2 +- scripts/trace-acceptor.sh | 2 +- 14 files changed, 59 insertions(+), 62 deletions(-) create mode 100644 configuration/simple-topology-0.json create mode 100644 configuration/simple-topology-1.json create mode 100644 configuration/simple-topology-2.json delete mode 100644 configuration/simple-topology.json diff --git a/benchmarking/trace-acceptor.sh b/benchmarking/trace-acceptor.sh index 279b6bc5d43..d0107ff2488 100755 --- a/benchmarking/trace-acceptor.sh +++ b/benchmarking/trace-acceptor.sh @@ -10,7 +10,7 @@ CMD="cabal new-run exe:trace-acceptor -- " set -x ${CMD} \ --config ${BASEDIR}/launch_mainnet.d/log-config-acceptor.yaml \ - --topology "./configuration/simple-topology.json" \ + --topology "./configuration/simple-topology-0.json" \ --database-path "./db/" \ --genesis-file "configuration/mainnet-genesis.json" \ --socket-dir "./socket" \ diff --git a/configuration/simple-topology-0.json b/configuration/simple-topology-0.json new file mode 100644 index 00000000000..15e0ac7a8d4 --- /dev/null +++ b/configuration/simple-topology-0.json @@ -0,0 +1,15 @@ +{ "nodeAddress": + { "addr": "127.0.0.1" + , "port": 3000 + } +, "producers": + [ { "addr": "127.0.0.1" + , "port": 3001 + , "valency": 1 + } + , { "addr": "127.0.0.1" + , "port": 3002 + , "valency": 1 + } + ] +} diff --git a/configuration/simple-topology-1.json b/configuration/simple-topology-1.json new file mode 100644 index 00000000000..6951f8c8a71 --- /dev/null +++ b/configuration/simple-topology-1.json @@ -0,0 +1,15 @@ +{ "nodeAddress": + { "addr": "127.0.0.1" + , "port": 3001 + } +, "producers": + [ { "addr": "127.0.0.1" + , "port": 3000 + , "valency": 1 + } + , { "addr": "127.0.0.1" + , "port": 3002 + , "valency": 1 + } + ] +} diff --git a/configuration/simple-topology-2.json b/configuration/simple-topology-2.json new file mode 100644 index 00000000000..000f1d260e8 --- /dev/null +++ b/configuration/simple-topology-2.json @@ -0,0 +1,15 @@ +{ "nodeAddress": + { "addr": "127.0.0.1" + , "port": 3002 + } +, "producers": + [ { "addr": "127.0.0.1" + , "port": 3000 + , "valency": 1 + } + , { "addr": "127.0.0.1" + , "port": 3001 + , "valency": 1 + } + ] +} diff --git a/configuration/simple-topology.json b/configuration/simple-topology.json deleted file mode 100644 index fd4c74aaf9f..00000000000 --- a/configuration/simple-topology.json +++ /dev/null @@ -1,50 +0,0 @@ -[ - { "nodeId": 0 - , "nodeAddress": - { "addr": "127.0.0.1" - , "port": 3000 - } - , "producers": - [ { "addr": "127.0.0.1" - , "port": 3001 - , "valency": 1 - } - , { "addr": "127.0.0.1" - , "port": 3002 - , "valency": 1 - } - ] - }, - { "nodeId": 1 - , "nodeAddress": - { "addr": "127.0.0.1" - , "port": 3001 - } - , "producers": - [ { "addr": "127.0.0.1" - , "port": 3000 - , "valency": 1 - } - , { "addr": "127.0.0.1" - , "port": 3002 - , "valency": 1 - } - ] - }, - { "nodeId": 2 - , "nodeAddress": - { "addr": "127.0.0.1" - , "port": 3002 - } - , "producers": - [ { "addr": "127.0.0.1" - , "port": 3000 - , "valency": 1 - } - , { "addr": "127.0.0.1" - , "port": 3001 - , "valency": 1 - } - ] - } -] diff --git a/scripts/chairman.sh b/scripts/chairman.sh index 9274f4182b0..ff6f72d837c 100755 --- a/scripts/chairman.sh +++ b/scripts/chairman.sh @@ -25,7 +25,7 @@ exec cabal new-run exe:chairman -- \ --pbft-signature-threshold 0.7 \ --require-network-magic \ --database-path "db" \ - --topology configuration/simple-topology.json \ + --topology configuration/simple-topology-0.json \ --database-path ./db/ \ --genesis-file ${genesis_file} \ --socket-dir "./socket/" \ diff --git a/scripts/generator.sh b/scripts/generator.sh index 6b8f90993ee..230b0bc589c 100755 --- a/scripts/generator.sh +++ b/scripts/generator.sh @@ -10,7 +10,7 @@ NETARGS=( --genesis-file "${genesis_file}" --genesis-hash "${genesis_hash}" generate-txs - --topology "configuration/simple-topology.json" + --topology "configuration/simple-topology-0.json" --genesis-file "${genesis_file}" --database-path "./db/" --socket-dir "./socket/" diff --git a/scripts/issue-genesis-utxo-expenditure.sh b/scripts/issue-genesis-utxo-expenditure.sh index 1222d6b00d7..e1060219e2b 100755 --- a/scripts/issue-genesis-utxo-expenditure.sh +++ b/scripts/issue-genesis-utxo-expenditure.sh @@ -33,7 +33,7 @@ args=" --real-pbft --wallet-key ${from_key} --rich-addr-from \"${from_addr}\" --txout (\"${addr}\",${lovelace}) - --topology configuration/simple-topology.json + --topology configuration/simple-topology-0.json --genesis-file \"${genesis_file}\" --database-path ./db/ --socket-dir ./socket/ diff --git a/scripts/issue-utxo-expenditure.sh b/scripts/issue-utxo-expenditure.sh index fb21b73cde1..619a355d9f8 100755 --- a/scripts/issue-utxo-expenditure.sh +++ b/scripts/issue-utxo-expenditure.sh @@ -38,7 +38,7 @@ args=" --real-pbft --wallet-key ${from_key} --txin (\"${txid}\",${outindex}) --txout (\"${addr}\",${lovelace}) - --topology configuration/simple-topology.json + --topology configuration/simple-topology-0.json --genesis-file \"${genesis_file}\" --database-path ./db/ --socket-dir ./socket/ diff --git a/scripts/lib-node.sh b/scripts/lib-node.sh index 84abb23edc3..c74e5b869e9 100644 --- a/scripts/lib-node.sh +++ b/scripts/lib-node.sh @@ -18,8 +18,6 @@ function dlgcert () { printf -- "--delegation-certificate ${genesis_root}/delegation-cert.%03d.json " "$1" } function commonargs() { - printf -- "--topology configuration/simple-topology.json " - printf -- "--database-path ./db/ " printf -- "--genesis-file ${genesis_file} " printf -- "--socket-dir ./socket/ " } @@ -29,7 +27,9 @@ function acceptorargs() { nodecfg acceptor dlgkey 0 dlgcert 0 - printf -- "--port 1234" + printf -- "--port 1234 " + printf -- "--topology configuration/simple-topology-0.json " + printf -- "--database-path ./db/ " } function nodeargs () { @@ -39,5 +39,7 @@ function nodeargs () { dlgkey $1 dlgcert $1 printf -- "${extra} " + printf -- "--database-path ./db/db-$1/ " printf -- "--port 300$1 " + printf -- "--topology configuration/simple-topology-$1.json " } diff --git a/scripts/shelley-testnet-dns.sh b/scripts/shelley-testnet-dns.sh index 4ef3c49a582..8772676203b 100755 --- a/scripts/shelley-testnet-dns.sh +++ b/scripts/shelley-testnet-dns.sh @@ -23,7 +23,7 @@ ALGO="--real-pbft" NOW=`date "+%Y-%m-%d 00:00:00"` -NETARGS="--slot-duration 2 --topology configuration/simple-topology-dns.json ${ALGO}" +NETARGS="--slot-duration 2 ${ALGO}" #SCR="./scripts/start-node.sh" #CMD="stack exec --nix cardano-node --" CMD="cabal new-run exe:cardano-node --" diff --git a/scripts/start-node.sh b/scripts/start-node.sh index 9fd679344f6..548df3a86c0 100755 --- a/scripts/start-node.sh +++ b/scripts/start-node.sh @@ -6,5 +6,5 @@ set -x cabal new-run exe:cardano-node -- \ --slot-duration 2 \ --log-config configuration/log-configuration.yaml \ - --topology configuration/simple-topology.json \ + --topology configuration/simple-topology-0.json \ $@ diff --git a/scripts/submit-tx.sh b/scripts/submit-tx.sh index 3d2c8bbee49..370620516f1 100755 --- a/scripts/submit-tx.sh +++ b/scripts/submit-tx.sh @@ -21,7 +21,7 @@ NETARGS=( --genesis-file "${genesis_file}" --genesis-hash "${genesis_hash}" submit-tx - --topology "configuration/simple-topology.json" + --topology "configuration/simple-topology-0.json" --genesis-file "${genesis_file}" --database-path "./db/" --socket-dir "./socket/" diff --git a/scripts/trace-acceptor.sh b/scripts/trace-acceptor.sh index cd8cd81ee12..4e5edb77189 100755 --- a/scripts/trace-acceptor.sh +++ b/scripts/trace-acceptor.sh @@ -6,7 +6,7 @@ CMD="cabal new-run exe:trace-acceptor -- " #TODO: Confirm if db path is necessary for trace acceptor set -x ${CMD} \ - --topology "./configuration/simple-topology.json" \ + --topology "./configuration/simple-topology-0.json" \ --database-path "./db/" \ --genesis-file "configuration/mainnet-genesis.json" \ --socket-dir "./socket" \ From cf5f1800571bc942ea65535cb33f764e36375802 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 19:29:40 +0300 Subject: [PATCH 4/6] scripts/genesis.sh: make more robust in face of unexpected log output --- scripts/genesis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/genesis.sh b/scripts/genesis.sh index 219953b6d23..9ce07398ef9 100755 --- a/scripts/genesis.sh +++ b/scripts/genesis.sh @@ -51,7 +51,7 @@ RUNNER=${RUNNER:-cabal new-run -v0 --} ${RUNNER} cardano-cli "${common[@]}" genesis "${args[@]}" "$@" # move new genesis to configuration -GENHASH=`${RUNNER} cardano-cli "${common[@]}" print-genesis-hash --genesis-json "${tmpdir}/genesis.json" | tail -1` +GENHASH=`${RUNNER} cardano-cli "${common[@]}" print-genesis-hash --genesis-json "${tmpdir}/genesis.json" | egrep '^[0-9a-f]{64}$'` TARGETDIR="${CONFIGDIR}/${GENHASH:0:5}" mkdir -vp "${TARGETDIR}" cp -iav ${tmpdir}/genesis.json ${TARGETDIR}/ From a2c9b2e91d374ecb52a46b0ee1734a8ede2ffef1 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 19:30:35 +0300 Subject: [PATCH 5/6] git: more ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 35b44f769ef..d3d85675f08 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ stack.yaml.lock /genesis.* /logs +/db /db-[0-9] launch_* state-* From e701a1ffe115cfbc42c1a8c5d47b969008b2b760 Mon Sep 17 00:00:00 2001 From: Kosyrev Serge Date: Wed, 20 Nov 2019 23:25:00 +0300 Subject: [PATCH 6/6] Nix definitions: update to the topology trimming --- nix/nixos/cardano-cluster-service.nix | 20 +++++++++++--------- nix/nixos/cardano-node-service.nix | 4 ++-- nix/nixos/chairman-as-a-service.nix | 1 - 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/nix/nixos/cardano-cluster-service.nix b/nix/nixos/cardano-cluster-service.nix index 27c0f7f81cc..4ed01707b58 100644 --- a/nix/nixos/cardano-cluster-service.nix +++ b/nix/nixos/cardano-cluster-service.nix @@ -10,10 +10,11 @@ let node-ids = range 0 (cfg.node-count - 1); cardano-node = ncfg.package; - # mkFullyConnectedLocalClusterTopology - # :: Address String -> Port String -> Int -> Int -> Topology FilePath - mkFullyConnectedLocalClusterTopology = + # mkFullyConnectedLocalNodeSetup + # :: Address String -> Port String -> Port String -> Int -> Int -> Topology FilePath + mkFullyConnectedLocalNodeSetup = { hostAddr + , port , portBase , node-count , valency ? 1 @@ -22,12 +23,11 @@ let addr = hostAddr; ports = map (x: portBase + x) (range 0 (node-count - 1)); mkPeer = port: { inherit addr port valency; }; - mkNodeTopo = nodeId: port: { - inherit nodeId; + mkNodeTopo = port: { nodeAddress = { inherit addr port; }; producers = map mkPeer (remove port ports); }; - in toFile "topology.yaml" (toJSON (imap0 mkNodeTopo ports)); + in toFile "topology.yaml" (toJSON (mkNodeTopo port)); ## Note how some values are literal strings, and some integral. ## This is an important detail. @@ -122,11 +122,12 @@ let delegationCertificate = ''$(printf "%s/delegation-cert.%03d.json" $(dirname $2) $1)''; nodeId = "$1"; port = "$((${toString portBase} + $1))"; - topology = mkFullyConnectedLocalClusterTopology + mkNetworkConfig = port: mkFullyConnectedLocalNodeSetup { inherit (cfg) node-count; inherit (ncfg) hostAddr; - inherit portBase; + inherit port portBase; }; + network-configs = map mkNetworkConfig (range portBase (portBase + cfg.node-count - 1)); in { options = with types; { @@ -154,7 +155,8 @@ in { enable = true; instanced = true; genesisHash = genesisHashValue; - inherit topology genesisFile signingKey delegationCertificate nodeId port; + inherit genesisFile signingKey delegationCertificate nodeId port; + topology = ''$(choice "$1" ${concatStringsSep " " network-configs})''; }; services.chairman.genesisHash = genesisHashValue; systemd.services."cardano-node@" = { diff --git a/nix/nixos/cardano-node-service.nix b/nix/nixos/cardano-node-service.nix index 77d8b4aa1e7..ab7e58da2b0 100644 --- a/nix/nixos/cardano-node-service.nix +++ b/nix/nixos/cardano-node-service.nix @@ -22,12 +22,12 @@ let # "--node-id ${toString cfg.nodeId}" "--host-addr ${cfg.hostAddr}" "--port ${toString cfg.port}" - "${lib.optionalString (cfg.pbftThreshold != null) "--pbft-signature-threshold ${cfg.pbftThreshold}"}" "${lib.optionalString (cfg.signingKey != null) "--signing-key ${cfg.signingKey}"}" "${lib.optionalString (cfg.delegationCertificate != null) "--delegation-certificate ${cfg.delegationCertificate}"}" "${cfg.extraArgs}" ]; in '' + choice() { i=$1; shift; eval "echo \''${$((i + 1))}"; } echo "Starting ${exec}: '' + concatStringsSep "\"\n echo \"" cmd + ''" echo "..or, once again, in a signle line:" echo "'' + concatStringsSep " " cmd + ''" @@ -188,7 +188,7 @@ in { }; topology = mkOption { - type = types.path; + type = types.string; default = mkEdgeTopology { inherit (cfg) hostAddr nodeId port; edgeHost = envConfig.edgeHost or "127.0.0.1"; diff --git a/nix/nixos/chairman-as-a-service.nix b/nix/nixos/chairman-as-a-service.nix index f952f4a7a38..1ca2af8f45c 100644 --- a/nix/nixos/chairman-as-a-service.nix +++ b/nix/nixos/chairman-as-a-service.nix @@ -22,7 +22,6 @@ let exec = "chairman"; cmd = builtins.filter (x: x != "") [ "${ncfg.package}/bin/chairman" - "--${ncfg.consensusProtocol}" (nodeIdArgs) "--timeout ${toString cfg.timeout}" "--database-path ${cfg.stateDir}/${cfg.dbPrefix}"