diff --git a/CHANGELOG.md b/CHANGELOG.md index 839f0e599..5ab2099c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,8 @@ math: true - Leios: `leiosAnnouncementPeriodLength`, `leiosVotePeriodLength`, `leiosDiffusionPeriodLength`, `leiosCommitteeSize`, `leiosQuorumStakeThreshold`, `maxEndorserBlockReferencesSize`, `maxEndorserBlockTransactionsSize`, `maxExecutionUnitsPerEndorserBlock` and `maxReferenceScriptsSizePerEndorserBlock`. - Peras: `perasMinCandidateBlockAge` (in slots), `perasHealingFactor`, `perasCertificateBoost`, `perasTargetCommitteeSize`, `perasBootstrapRound` (`null` when not set) and `perasQuorumThresholdSafetyMargin`. +- Ogmios now reads the node configuration format of cardano-node 11.2.0 and later (its mainnet configuration and the files cardano-testnet writes), where the settings sit in sections under `Configuration` (such as `Configuration.Protocol.ShelleyGenesisFile`). Before, it exited at start-up because it found no genesis files. Configurations with all settings at the top level still work. + ### [6.14.0] - 2025-10-16 #### Added diff --git a/perSystem/project.nix b/perSystem/project.nix index d57a71086..b94006b50 100644 --- a/perSystem/project.nix +++ b/perSystem/project.nix @@ -58,10 +58,12 @@ # Test.Path.Util.getProjectRoot uses TH `makeRelativeToProject ""` # which bakes the compile-time absolute path # /build/ogmios-src-test-unit-root/server into the binary. Recreate - # that path at runtime with the golden fixtures and the - # cardano-configurations submodule content. + # that path at runtime with the golden fixtures, the node + # configuration fixtures and the cardano-configurations submodule + # content. mkdir -p /build/ogmios-src-test-unit-root/server/test cp -r ${self}/server/test/golden /build/ogmios-src-test-unit-root/server/test/golden + cp -r ${self}/server/test/node-config /build/ogmios-src-test-unit-root/server/test/node-config cp -r ${self}/server/config /build/ogmios-src-test-unit-root/server/config ''; } diff --git a/scripts/dijkstra-devnet-test.sh b/scripts/dijkstra-devnet-test.sh index 6d782cb73..f25dae431 100755 --- a/scripts/dijkstra-devnet-test.sh +++ b/scripts/dijkstra-devnet-test.sh @@ -122,10 +122,7 @@ wait_for 300 cli query tip || fail "the node does not answer" echo "Waiting for the Dijkstra era." wait_for 600 in_dijkstra || fail "the chain did not reach the Dijkstra era" -# Ogmios wants one flat node configuration. cardano-testnet writes it in sections. -jq '.Configuration | reduce to_entries[] as $e ({}; if ($e.value | type) == "object" then . + $e.value else . + {($e.key): $e.value} end)' \ - "$WORK/env/configuration.yaml" > "$WORK/env/node-config.json" -"$OGMIOS_BIN" --node-socket "$SOCKET" --node-config "$WORK/env/node-config.json" \ +"$OGMIOS_BIN" --node-socket "$SOCKET" --node-config "$WORK/env/configuration.yaml" \ --host 127.0.0.1 --port 1337 > "$WORK/ogmios.log" 2>&1 & PIDS+=($!) wait_for 120 ogmios_connected || fail "Ogmios did not connect to the node" diff --git a/server/src/Ogmios/App/Configuration.hs b/server/src/Ogmios/App/Configuration.hs index 4e6de4ebb..ab01e6b1a 100644 --- a/server/src/Ogmios/App/Configuration.hs +++ b/server/src/Ogmios/App/Configuration.hs @@ -19,6 +19,7 @@ module Ogmios.App.Configuration , Severity (..) -- * Genesis Configurations + , lookupNodeConfig , readByronGenesis , readShelleyGenesis , readAlonzoGenesis @@ -47,6 +48,9 @@ import Data.Aeson ( ToJSON , genericToEncoding ) +import Data.Aeson.Key + ( Key + ) import Data.Aeson.Lens ( _JSON' , _String @@ -114,10 +118,21 @@ mkSystemStart = where toPicoResolution = (*1000000000000) +-- | Look up a genesis file setting of the node configuration. Since +-- cardano-node 11.2.0, the setting sits in the @Protocol@ section under +-- @Configuration@. The node also accepts it loose under @Configuration@, or at +-- the top level as before. +lookupNodeConfig :: Key -> Json.Value -> Maybe Text +lookupNodeConfig k nodeConfig = asum + [ nodeConfig ^? key "Configuration" . key "Protocol" . key k . _String + , nodeConfig ^? key "Configuration" . key k . _String + , nodeConfig ^? key k . _String + ] + readByronGenesis :: MonadIO m => FilePath -> m (GenesisConfig ByronEra) readByronGenesis configFile = do nodeConfig <- Yaml.decodeFileThrow @_ @Json.Value configFile - case nodeConfig ^? key "ByronGenesisFile" . _String of + case lookupNodeConfig "ByronGenesisFile" nodeConfig of Nothing -> liftIO $ fail "Missing 'ByronGenesisFile' from node's configuration." Just (toString -> genesisFile) -> do @@ -131,7 +146,7 @@ readByronGenesis configFile = do readShelleyGenesis :: MonadIO m => FilePath -> m (GenesisConfig ShelleyEra) readShelleyGenesis configFile = do nodeConfig <- Yaml.decodeFileThrow @_ @Json.Value configFile - case nodeConfig ^? key "ShelleyGenesisFile" . _String of + case lookupNodeConfig "ShelleyGenesisFile" nodeConfig of Nothing -> liftIO $ fail "Missing 'ShelleyGenesisFile' from node's configuration." Just (toString -> genesisFile) -> do @@ -140,7 +155,7 @@ readShelleyGenesis configFile = do readAlonzoGenesis :: MonadIO m => FilePath -> m (GenesisConfig AlonzoEra) readAlonzoGenesis configFile = do nodeConfig <- Yaml.decodeFileThrow @_ @Json.Value configFile - case nodeConfig ^? key "AlonzoGenesisFile" . _String of + case lookupNodeConfig "AlonzoGenesisFile" nodeConfig of Nothing -> liftIO $ fail "Missing 'AlonzoGenesisFile' from node's configuration." Just (toString -> genesisFile) -> do @@ -218,7 +233,7 @@ readConwayGenesis configFile = do pure $ Left $ "Invalid (non-JSON or non-YAML) or missing node's configuration file: " <> formatParseException e Right nodeConfig -> - case nodeConfig ^? key "ConwayGenesisFile" . _String of + case lookupNodeConfig "ConwayGenesisFile" nodeConfig of Nothing -> pure $ Left "Missing 'ConwayGenesisFile' from node's configuration." Just (toString -> genesisFile) -> do diff --git a/server/src/Ogmios/Options.hs b/server/src/Ogmios/Options.hs index e08e86a42..65d08ba9e 100644 --- a/server/src/Ogmios/Options.hs +++ b/server/src/Ogmios/Options.hs @@ -82,6 +82,7 @@ import Ogmios.App.Configuration , SystemStart (..) , TraceConfiguration (..) , includeAllCbor + , lookupNodeConfig , omitOptionalCbor ) import Options.Applicative.Help.Pretty @@ -383,8 +384,8 @@ parseNetworkParameters :: FilePath -> IO NetworkParameters parseNetworkParameters configFile = runOrDie $ do config <- decodeYaml configFile let genesisFiles = (,) - <$> config ^? key "ByronGenesisFile" . _String - <*> config ^? key "ShelleyGenesisFile" . _String + <$> lookupNodeConfig "ByronGenesisFile" config + <*> lookupNodeConfig "ShelleyGenesisFile" config case genesisFiles of Nothing -> throwE "Missing 'ByronGenesisFile' and/or 'ShelleyGenesisFile' from Cardano's configuration?" diff --git a/server/test/node-config/cardano-testnet-11.2.0/alonzo-genesis.json b/server/test/node-config/cardano-testnet-11.2.0/alonzo-genesis.json new file mode 100644 index 000000000..a097f75f2 --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/alonzo-genesis.json @@ -0,0 +1,537 @@ +{ + "collateralPercentage": 150, + "costModels": { + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 57996947, + 18975, + 10 + ] + }, + "executionPrices": { + "priceMemory": 5.77e-2, + "priceSteps": 7.21e-5 + }, + "extraConfig": { + "costModels": { + "PlutusV1": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 57996947, + 18975, + 10 + ], + "PlutusV2": [ + 205665, + 812, + 1, + 1, + 1000, + 571, + 0, + 1, + 1000, + 24177, + 4, + 1, + 1000, + 32, + 117366, + 10475, + 4, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 23000, + 100, + 100, + 100, + 23000, + 100, + 19537, + 32, + 175354, + 32, + 46417, + 4, + 221973, + 511, + 0, + 1, + 89141, + 32, + 497525, + 14068, + 4, + 2, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1000, + 28662, + 4, + 2, + 245000, + 216773, + 62, + 1, + 1060367, + 12586, + 1, + 208512, + 421, + 1, + 187000, + 1000, + 52998, + 1, + 80436, + 32, + 43249, + 32, + 1000, + 32, + 80556, + 1, + 57667, + 4, + 1000, + 10, + 197145, + 156, + 1, + 197145, + 156, + 1, + 204924, + 473, + 1, + 208896, + 511, + 1, + 52467, + 32, + 64832, + 32, + 65493, + 32, + 22558, + 32, + 16563, + 32, + 76511, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 69522, + 11687, + 0, + 1, + 60091, + 32, + 196500, + 453240, + 220, + 0, + 1, + 1, + 196500, + 453240, + 220, + 0, + 1, + 1, + 1159724, + 392670, + 0, + 2, + 806990, + 30482, + 4, + 1927926, + 82523, + 4, + 265318, + 0, + 4, + 0, + 85931, + 32, + 205665, + 812, + 1, + 1, + 41182, + 32, + 212342, + 32, + 31220, + 32, + 32696, + 32, + 43357, + 32, + 32247, + 32, + 38314, + 32, + 35892428, + 10, + 9462713, + 1021, + 10, + 38887044, + 32947, + 10 + ] + } + }, + "lovelacePerUTxOWord": 34482, + "maxBlockExUnits": { + "memory": 62000000, + "steps": 20000000000 + }, + "maxCollateralInputs": 3, + "maxTxExUnits": { + "memory": 140000000, + "steps": 10000000000 + }, + "maxValueSize": 5000 +} \ No newline at end of file diff --git a/server/test/node-config/cardano-testnet-11.2.0/byron-genesis.json b/server/test/node-config/cardano-testnet-11.2.0/byron-genesis.json new file mode 100644 index 000000000..57fe531cb --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/byron-genesis.json @@ -0,0 +1,40 @@ +{ "bootStakeholders": + { "3ec9449ccb4e7d8a49c66b1ff072f845a379595dfa404ff6239ef2cc": 1 } +, "heavyDelegation": + { "3ec9449ccb4e7d8a49c66b1ff072f845a379595dfa404ff6239ef2cc": + { "omega": 0 + , "issuerPk": + "xtyO77uSXmt/yOUNFAlUXRAI8kOt1d58fqQjTqrBIySXoMdUSuce4mpekwEVYclv30Sa4vL8zogyhHs8wihdxg==" + , "delegatePk": + "rRWCV2kYYTdJMr4Ivl8P3MloJlrkTStNEjD2DXVbeBsCjmjQoCvfTtTFzm6Qsf73kEOC7Qi9m3xqwS4zHtmXBw==" + , "cert": + "d879efd01d447bb3378f88120335a161314386ab687e020ee5f0c73088dbc36ef1264e7b3ccc5e91c988cc26325dba7fab09008c5f55a7d8d8e19950abf8950e" + } } +, "startTime": 1795464068 +, "nonAvvmBalances": + { "2657WMsDfac7FskugSxa5CpNvTm7vx9ZNF7D3Z22QC28dAtgxJKQBTGtLCk2hw9XN": + "3000000000" } +, "blockVersionData": + { "scriptVersion": 0 + , "slotDuration": "1000" + , "maxBlockSize": "2000000" + , "maxHeaderSize": "2000000" + , "maxTxSize": "4096" + , "maxProposalSize": "700" + , "mpcThd": "20000000000000" + , "heavyDelThd": "300000000000" + , "updateVoteThd": "1000000000000" + , "updateProposalThd": "100000000000000" + , "updateImplicit": "10000" + , "softforkRule": + { "initThd": "900000000000000" + , "minThd": "600000000000000" + , "thdDecrement": "50000000000000" + } + , "txFeePolicy": + { "summand": "155381000000000" , "multiplier": "43946000000" } + , "unlockStakeEpoch": "18446744073709551615" + } +, "protocolConsts": { "k": 5 , "protocolMagic": 42 } +, "avvmDistr": {} +} \ No newline at end of file diff --git a/server/test/node-config/cardano-testnet-11.2.0/configuration.yaml b/server/test/node-config/cardano-testnet-11.2.0/configuration.yaml new file mode 100644 index 000000000..a562d05af --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/configuration.yaml @@ -0,0 +1,36 @@ +{ + "$schema": "https://raw.githubusercontent.com/IntersectMBO/cardano-config/v2/schemas/config.schema.json", + "Configuration": { + "LocalConnections": { + "SocketPath": "db/node.socket" + }, + "Network": { + "ExperimentalProtocolsEnabled": true, + "MaxConcurrencyBulkSync": 1, + "MaxConcurrencyDeadline": 2, + "PeerSharing": false + }, + "Protocol": { + "AlonzoGenesisFile": "alonzo-genesis.json", + "AlonzoGenesisHash": "d9cb5f26ffb1f9d9cd16bb2921bb959ac405ded4dd338f11b21032378531a5bc", + "ByronGenesisFile": "byron-genesis.json", + "ByronGenesisHash": "cd43a5d909360cfb86a41ca65f295768f7b7d4bcea234ac173a8c73b7ae83913", + "ConwayGenesisFile": "conway-genesis.json", + "ConwayGenesisHash": "0e8dce2f240da02f87b91a4530099d39f43b6c62143a62f8443e9198fbd7f2a8", + "RequiresNetworkMagic": "RequiresMagic", + "ShelleyGenesisFile": "shelley-genesis.json", + "ShelleyGenesisHash": "98becd045e44470691d7fdf7e3dd911fd0821372342c44a1bdb49777b949d3d7" + }, + "Testing": { + "DijkstraGenesisFile": "dijkstra-genesis.json", + "DijkstraGenesisHash": "3537930d1515a8a0a648dae633e485812eff10a7cf9a6a2c3391952789e13b3a", + "TestAllegraHardForkAtEpoch": 0, + "TestAlonzoHardForkAtEpoch": 0, + "TestBabbageHardForkAtEpoch": 0, + "TestConwayHardForkAtEpoch": 0, + "TestMaryHardForkAtEpoch": 0, + "TestShelleyHardForkAtEpoch": 0 + } + }, + "Version": 2 +} diff --git a/server/test/node-config/cardano-testnet-11.2.0/conway-genesis.json b/server/test/node-config/cardano-testnet-11.2.0/conway-genesis.json new file mode 100644 index 000000000..0315b212e --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/conway-genesis.json @@ -0,0 +1,325 @@ +{ + "committee": { + "members": {}, + "threshold": 0 + }, + "committeeMaxTermLength": 200, + "committeeMinSize": 0, + "constitution": { + "anchor": { + "dataHash": "0000000000000000000000000000000000000000000000000000000000000000", + "url": "" + } + }, + "dRepActivity": 100, + "dRepDeposit": 1000000, + "dRepVotingThresholds": { + "committeeNoConfidence": 0, + "committeeNormal": 0.5, + "hardForkInitiation": 0.5, + "motionNoConfidence": 0, + "ppEconomicGroup": 0.5, + "ppGovGroup": 0.5, + "ppNetworkGroup": 0.5, + "ppTechnicalGroup": 0.5, + "treasuryWithdrawal": 0.5, + "updateToConstitution": 0 + }, + "extraConfig": { + "delegs": { + "data": { + "keyHash-46a11eeb32e4bc3c46c534e3ad14ccf2a758cbfc0947a521e318def6": { + "dRep": "drep-keyHash-1cd413696f25b267fc5ff113b6e216ff4e42e8fe469fcf7100ecee26", + "kind": "DelegVote" + }, + "keyHash-46a4556ce99a70c3186965eac0a9316d749d65a38f4287ffbe10a8fc": { + "dRep": "drep-keyHash-23b28c71771990ae5785712e0ccbb66e2cc5b6a341878e4d1f77c240", + "kind": "DelegVote" + }, + "keyHash-976dba00286c92f881993e0a74a4efb12d09160d643f24ea01cf544b": { + "dRep": "drep-keyHash-8f17cf13d765a9fd761950e26336885ede2798d76713f447bbccf1f0", + "kind": "DelegVote" + } + } + }, + "initialDReps": { + "data": { + "keyHash-1cd413696f25b267fc5ff113b6e216ff4e42e8fe469fcf7100ecee26": { + "deposit": 1000000, + "expiry": 1000 + }, + "keyHash-23b28c71771990ae5785712e0ccbb66e2cc5b6a341878e4d1f77c240": { + "deposit": 1000000, + "expiry": 1000 + }, + "keyHash-8f17cf13d765a9fd761950e26336885ede2798d76713f447bbccf1f0": { + "deposit": 1000000, + "expiry": 1000 + } + } + } + }, + "govActionDeposit": 1000000, + "govActionLifetime": 1, + "minFeeRefScriptCostPerByte": 15, + "plutusV3CostModel": [ + 100788, + 420, + 1, + 1, + 1000, + 173, + 0, + 1, + 1000, + 59957, + 4, + 1, + 11183, + 32, + 201305, + 8356, + 4, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 100, + 100, + 16000, + 100, + 94375, + 32, + 132994, + 32, + 61462, + 4, + 72010, + 178, + 0, + 1, + 22151, + 32, + 91189, + 769, + 4, + 2, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 1, + 1000, + 42921, + 4, + 2, + 30623, + 28755, + 75, + 1, + 898148, + 27279, + 1, + 51775, + 558, + 1, + 39184, + 1000, + 60594, + 1, + 141895, + 32, + 83150, + 32, + 15299, + 32, + 76049, + 1, + 13169, + 4, + 22100, + 10, + 28999, + 74, + 1, + 28999, + 74, + 1, + 43285, + 552, + 1, + 44749, + 541, + 1, + 33852, + 32, + 68246, + 32, + 72362, + 32, + 7243, + 32, + 7391, + 32, + 11546, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 90434, + 519, + 0, + 1, + 74433, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 1, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 955506, + 213312, + 0, + 2, + 270652, + 22588, + 4, + 1457325, + 64566, + 4, + 20467, + 1, + 4, + 0, + 141992, + 32, + 100788, + 420, + 1, + 1, + 81663, + 32, + 59498, + 32, + 20142, + 32, + 24588, + 32, + 20744, + 32, + 25933, + 32, + 24623, + 32, + 43053543, + 10, + 53384111, + 14333, + 10, + 43574283, + 26308, + 10, + 16000, + 100, + 16000, + 100, + 962335, + 18, + 2780678, + 6, + 442008, + 1, + 52538055, + 3756, + 18, + 267929, + 18, + 76433006, + 8868, + 18, + 52948122, + 18, + 1995836, + 36, + 3227919, + 12, + 901022, + 1, + 166917843, + 4307, + 36, + 284546, + 36, + 158221314, + 26549, + 36, + 74698472, + 36, + 333849714, + 1, + 254006273, + 72, + 2174038, + 72, + 2261318, + 64571, + 4, + 207616, + 8310, + 4, + 1293828, + 28716, + 63, + 0, + 1, + 1006041, + 43623, + 251, + 0, + 1 + ], + "poolVotingThresholds": { + "committeeNoConfidence": 0.5, + "committeeNormal": 0.5, + "hardForkInitiation": 0.5, + "motionNoConfidence": 0.5, + "ppSecurityGroup": 0.5 + } +} \ No newline at end of file diff --git a/server/test/node-config/cardano-testnet-11.2.0/dijkstra-genesis.json b/server/test/node-config/cardano-testnet-11.2.0/dijkstra-genesis.json new file mode 100644 index 000000000..7c4efac99 --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/dijkstra-genesis.json @@ -0,0 +1,281 @@ +{ + "leiosAnnouncementPeriodLength": 1000, + "leiosCommitteeSize": 900, + "leiosDiffusionPeriodLength": 7000, + "leiosQuorumStakeThreshold": 0.75, + "leiosVotePeriodLength": 4000, + "maxEndorserBlockExecutionUnits": { + "memory": 7000000000, + "steps": 2000000000000 + }, + "maxEndorserBlockReferencesSize": 524288, + "maxEndorserBlockTxsSize": 12582912, + "maxPledgeLeverage": null, + "maxRefScriptSizePerBlock": 1048576, + "maxRefScriptSizePerEndorserBlock": 12582912, + "maxRefScriptSizePerTx": 204800, + "minPoolMargin": 1.5e-2, + "perasBootstrapRound": 0, + "perasCertBoost": 15, + "perasHealingFactor": 0.5, + "perasMinCandidateBlockAge": 90, + "perasQuorumThresholdSafetyMargin": 5.0e-2, + "perasTargetCommitteeSize": 800, + "plutusV4CostModel": [ + 100788, + 420, + 1, + 1, + 1000, + 173, + 0, + 1, + 1000, + 59957, + 4, + 1, + 11183, + 32, + 201305, + 8356, + 4, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 16000, + 100, + 100, + 100, + 16000, + 100, + 94375, + 32, + 132994, + 32, + 61462, + 4, + 72010, + 178, + 0, + 1, + 22151, + 32, + 91189, + 769, + 4, + 2, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 1, + 1000, + 42921, + 4, + 2, + 30623, + 28755, + 75, + 1, + 898148, + 27279, + 1, + 51775, + 558, + 1, + 39184, + 1000, + 60594, + 1, + 141895, + 32, + 83150, + 32, + 15299, + 32, + 76049, + 1, + 13169, + 4, + 22100, + 10, + 28999, + 74, + 1, + 28999, + 74, + 1, + 43285, + 552, + 1, + 44749, + 541, + 1, + 33852, + 32, + 68246, + 32, + 72362, + 32, + 7243, + 32, + 7391, + 32, + 11546, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 90434, + 519, + 0, + 1, + 74433, + 32, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 1, + 85848, + 123203, + 7305, + -900, + 1716, + 960, + 57, + 85848, + 0, + 1, + 955506, + 213312, + 0, + 2, + 270652, + 22588, + 4, + 1457325, + 64566, + 4, + 20467, + 1, + 4, + 0, + 141992, + 32, + 100788, + 420, + 1, + 1, + 81663, + 32, + 59498, + 32, + 20142, + 32, + 24588, + 32, + 20744, + 32, + 25933, + 32, + 24623, + 32, + 43053543, + 10, + 53384111, + 14333, + 10, + 43574283, + 26308, + 10, + 16000, + 100, + 16000, + 100, + 962335, + 18, + 2780678, + 6, + 442008, + 1, + 52538055, + 3756, + 18, + 267929, + 18, + 76433006, + 8868, + 18, + 52948122, + 18, + 1995836, + 36, + 3227919, + 12, + 901022, + 1, + 166917843, + 4307, + 36, + 284546, + 36, + 158221314, + 26549, + 36, + 74698472, + 36, + 333849714, + 1, + 254006273, + 72, + 2174038, + 72, + 2261318, + 64571, + 4, + 207616, + 8310, + 4, + 1293828, + 28716, + 63, + 0, + 1, + 1006041, + 43623, + 251, + 0, + 1 + ], + "refInputsCostPerDatumByte": 0, + "refInputsCostPerMultiAssetPolicy": 0, + "refScriptCostMultiplier": 1.2, + "refScriptCostStride": 25600 +} \ No newline at end of file diff --git a/server/test/node-config/cardano-testnet-11.2.0/shelley-genesis.json b/server/test/node-config/cardano-testnet-11.2.0/shelley-genesis.json new file mode 100644 index 000000000..4f0fd35f9 --- /dev/null +++ b/server/test/node-config/cardano-testnet-11.2.0/shelley-genesis.json @@ -0,0 +1,96 @@ +{ + "activeSlotsCoeff": 5.0e-2, + "epochLength": 500, + "extraConfig": { + "initialFunds": { + "data": { + "001eb2d2c6975cef3ae0d8d356bc6e4e6816af624fc42e3034b8866f82976dba00286c92f881993e0a74a4efb12d09160d643f24ea01cf544b": 15000003000000, + "00ca2113a1e74cb1ad0ecb3e997f34ede30529de8efe60b6cdf1333b6446a4556ce99a70c3186965eac0a9316d749d65a38f4287ffbe10a8fc": 15000003000000, + "00ed726cd89a6a2485c49976856ae854c5ca005563529223203f75230846a11eeb32e4bc3c46c534e3ad14ccf2a758cbfc0947a521e318def6": 15000003000000, + "60026e7e4299752ccec4ee61cefb38794fbb9fdd3253d1777a4272b2a5": 15000003000000, + "6013e2215b8f4a5ac30899062615c8443982d6a0630b7597f49f081759": 15000003000000, + "60ab5508c819de99c8953c3001283c71bcfe3f3674d23c2be077eaf982": 15000003000000 + } + }, + "stakeCredentials": { + "data": { + "46a11eeb32e4bc3c46c534e3ad14ccf2a758cbfc0947a521e318def6": "d12e7f0158e96fac48f4458e2242ca45c333a4a781ebc43d1d869e93", + "46a4556ce99a70c3186965eac0a9316d749d65a38f4287ffbe10a8fc": "d12e7f0158e96fac48f4458e2242ca45c333a4a781ebc43d1d869e93", + "976dba00286c92f881993e0a74a4efb12d09160d643f24ea01cf544b": "d12e7f0158e96fac48f4458e2242ca45c333a4a781ebc43d1d869e93" + } + }, + "stakePools": { + "data": { + "d12e7f0158e96fac48f4458e2242ca45c333a4a781ebc43d1d869e93": { + "accountAddress": { + "credential": { + "keyHash": "03c21291a3f67fe4be5c24dc14676a9401d4bce306c0b72259fd3c61" + }, + "network": "Testnet" + }, + "blsKey": null, + "cost": 0, + "margin": 0, + "metadata": null, + "owners": [], + "pledge": 0, + "poolId": "d12e7f0158e96fac48f4458e2242ca45c333a4a781ebc43d1d869e93", + "relays": [], + "vrf": "32e19a0f850d30362603de5f91641dc8b35baf46f58babb7c880424634e54352" + } + } + } + }, + "genDelegs": { + "1051ed1bf97a301856694db9ab88768cb5c9e525d1457886f407e34e": { + "delegate": "0ca4e76377807926074a140ede70c9fa114f85b9d5e6f2a08d77c79a", + "vrf": "49c01b5217cd4c74d1e1684e762592be7f1c4ca0c6f58addc171fcff1bded36c" + }, + "d23194d191df27344861f02e51a144197d82c0f8a8419e1beadad4a9": { + "delegate": "2ba8ed5523e3e9ced5bb1dc9a271f1bac46452b10c9e7bc6bf18d962", + "vrf": "cad3675f7b6c8021b2006cc4e3ab07ba03b733bbb7af6994253578f3c9c9a72a" + }, + "e56762efae7f224c0f82ab016bae1ffb974a03634fc5d787a3e5ed6a": { + "delegate": "5095bd3f60f5b8459ccb90faa938e0b02e91373c13fe3e6681028acd", + "vrf": "cefca6225463230c81ed602380745ce7544567740d04c12775035ae13794edd7" + } + }, + "initialFunds": {}, + "maxKESEvolutions": 60, + "maxLovelaceSupply": 100000020000000, + "networkId": "Testnet", + "networkMagic": 42, + "protocolParams": { + "a0": 0, + "decentralisationParam": 1, + "eMax": 18, + "extraEntropy": { + "tag": "NeutralNonce" + }, + "keyDeposit": 400000, + "maxBlockBodySize": 65536, + "maxBlockHeaderSize": 1100, + "maxTxSize": 16384, + "minFeeA": 1, + "minFeeB": 0, + "minPoolCost": 0, + "minUTxOValue": 0, + "nOpt": 100, + "poolDeposit": 0, + "protocolVersion": { + "major": 10, + "minor": 0 + }, + "rho": 0.1, + "tau": 0.1 + }, + "securityParam": 5, + "slotLength": 0.1, + "slotsPerKESPeriod": 129600, + "staking": { + "pools": {}, + "stake": {} + }, + "systemStart": "2026-11-23T20:01:08Z", + "updateQuorum": 2 +} \ No newline at end of file diff --git a/server/test/unit/Ogmios/OptionsSpec.hs b/server/test/unit/Ogmios/OptionsSpec.hs index e3d158e4b..a7a702ec8 100644 --- a/server/test/unit/Ogmios/OptionsSpec.hs +++ b/server/test/unit/Ogmios/OptionsSpec.hs @@ -14,6 +14,9 @@ module Ogmios.OptionsSpec import Ogmios.Prelude +import Data.Aeson + ( (.=) + ) import Data.List ( isInfixOf ) @@ -24,7 +27,12 @@ import Ogmios.App.Configuration , NetworkMagic (..) , NetworkParameters (..) , includeAllCbor + , lookupNodeConfig , mkSystemStart + , readAlonzoGenesis + , readByronGenesis + , readConwayGenesis + , readShelleyGenesis ) import Ogmios.Control.MonadLog ( Severity (..) @@ -55,6 +63,8 @@ import Test.Path.Util ( getProjectRoot ) +import qualified Data.Aeson as Json + spec :: Spec spec = parallel $ do context "parseOptions(Pure)" $ do @@ -114,6 +124,58 @@ spec = parallel $ do networkMagic params `shouldBe` NetworkMagic 1 systemStart params `shouldBe` mkSystemStart 1654041600 slotsPerEpoch params `shouldBe` EpochSlots 21600 + + specify "cardano-testnet 11.2.0 (settings in sections)" $ do + params <- parseNetworkParameters sectionedConfigFile + networkMagic params `shouldBe` NetworkMagic 42 + systemStart params `shouldBe` mkSystemStart 1795464068 + slotsPerEpoch params `shouldBe` EpochSlots 50 + + context "lookupNodeConfig" $ do + let lookupShelley = lookupNodeConfig "ShelleyGenesisFile" + let configuration = ("Configuration" .=) . Json.object + let protocol = ("Protocol" .=) . Json.object + let shelley = ("ShelleyGenesisFile" .=) . Json.String + + specify "at the top level" $ + lookupShelley (Json.object [shelley "top"]) + `shouldBe` Just "top" + + specify "in the Protocol section" $ + lookupShelley (Json.object [configuration [protocol [shelley "protocol"]]]) + `shouldBe` Just "protocol" + + specify "loose under Configuration" $ + lookupShelley (Json.object [configuration [shelley "loose"]]) + `shouldBe` Just "loose" + + specify "next to Configuration" $ + lookupShelley (Json.object [configuration [], shelley "top"]) + `shouldBe` Just "top" + + specify "the Protocol section wins" $ + lookupShelley (Json.object + [ configuration + [ "Network" .= Json.object [shelley "network"] + , protocol [shelley "protocol"] + , shelley "loose" + ] + , shelley "top" + ]) + `shouldBe` Just "protocol" + + specify "not in other sections" $ + lookupShelley (Json.object [configuration ["Network" .= Json.object [shelley "network"]]]) + `shouldBe` Nothing + + context "genesis configurations" $ do + forM_ [ ("mainnet (flat settings)", getConfigFile "mainnet") + , ("cardano-testnet 11.2.0 (settings in sections)", sectionedConfigFile) + ] $ \(name, configFile) -> specify name $ do + void $ readByronGenesis configFile + void $ readShelleyGenesis configFile + void $ readAlonzoGenesis configFile + readConwayGenesis configFile >>= (`shouldSatisfy` isRight) where matrix = [ ( [], shouldFail ) @@ -298,6 +360,10 @@ isLeftWith predicate = \case Left e -> predicate e Right{} -> False +sectionedConfigFile :: FilePath +sectionedConfigFile = + $(getProjectRoot) <> "/test/node-config/cardano-testnet-11.2.0/configuration.yaml" + getConfigFile :: String -> FilePath getConfigFile network = $(getProjectRoot) <> "/config/network/" <> network <> "/cardano-node/config.json"