-
Notifications
You must be signed in to change notification settings - Fork 29
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
Drop old, envs; update from cardano-world. #534
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d79de1a
to
d74398c
Compare
Diff is ```diff Common subdirectories: cardano-world/nix/cardano/environments/aux-config and cardano-lib/aux-config diff -u cardano-world/nix/cardano/environments/default.nix cardano-lib/default.nix --- cardano-world/nix/cardano/environments/default.nix 2023-05-08 11:00:40 +++ cardano-lib/default.nix 2023-05-08 11:34:55 @@ -1,11 +1,36 @@ -{ - inputs, - cell, -}: let - inherit (inputs.nixpkgs) jq writeText runCommand lib; +{lib, writeText, runCommand, jq, environments}: +let + mkEdgeTopology = { + hostAddr ? "127.0.0.1" + , port ? 3001 + , edgeHost ? "127.0.0.1" + , edgeNodes ? [] + , edgePort ? if (edgeNodes != []) then 3001 else (if edgeHost == "127.0.0.1" then 7777 else 3001) + , valency ? 1 + }: + let + mkProducers = map (edgeHost': { addr = edgeHost'; port = edgePort; inherit valency; }) edgeNodes; + topology = { + Producers = if (edgeNodes != []) then mkProducers else [ + { + addr = edgeHost; + port = edgePort; + inherit valency; + } + ]; + }; + in builtins.toFile "topology.yaml" (builtins.toJSON topology); defaultLogConfig = import ./generic-log-config.nix; defaultDbSyncLogConfig = import ./db-sync-log-config.nix; + defaultExplorerLogConfig = import ./explorer-log-config.nix; + + mkExplorerConfig = name: nodeConfig: lib.filterAttrs (k: v: v != null) { + NetworkName = name; + inherit (nodeConfig) RequiresNetworkMagic; + NodeConfigFile = "${__toFile "config-${toString name}.json" (__toJSON nodeConfig)}"; + }; + mkDbSyncConfig = name: nodeConfig: (lib.filterAttrs (k: v: v != null) { NetworkName = name; @@ -13,6 +38,7 @@ NodeConfigFile = "${__toFile "config-${toString name}.json" (__toJSON nodeConfig)}"; }) // defaultDbSyncLogConfig; + mkSubmitApiConfig = name: nodeConfig: (lib.filterAttrs (k: v: v != null) { GenesisHash = nodeConfig.ByronGenesisHash; @@ -20,6 +46,10 @@ }) // defaultDbSyncLogConfig; + mkProxyTopology = relay: writeText "proxy-topology-file" '' + wallet: + relays: [[{ host: ${relay} }]] + ''; environments = { mainnet = rec { useByronWallet = true; @@ -43,9 +73,29 @@ consensusProtocol = networkConfig.Protocol; submitApiConfig = mkSubmitApiConfig "mainnet" nodeConfig; dbSyncConfig = mkDbSyncConfig "mainnet" nodeConfig; + explorerConfig = mkExplorerConfig "mainnet" nodeConfig; usePeersFromLedgerAfterSlot = 84916732; auxConfig = import ./aux-config/mainnet-aux.nix inputs; }; + # Network shutdown, but benchmarking configs reference it as a template + testnet = rec { + useByronWallet = true; + relays = "doesnotexist.iog.io"; + relaysNew = "doesnotexist.iog.io"; + explorerUrl = "https://doesnotexist.iog.io"; + smashUrl = "https://doesnotexist.iog.io"; + metadataUrl = "https://doesnotexist.iog.io"; + edgeNodes = []; + edgePort = 3001; + confKey = "testnet_full"; + private = true; + networkConfig = import ./testnet-config.nix; + nodeConfig = networkConfig // defaultLogConfig; + consensusProtocol = networkConfig.Protocol; + submitApiConfig = mkSubmitApiConfig "testnet" nodeConfig; + explorerConfig = mkExplorerConfig "testnet" nodeConfig; + usePeersFromLedgerAfterSlot = -1; + }; # used for daedalus/cardano-wallet for local development shelley_qa = rec { useByronWallet = false; @@ -64,6 +114,22 @@ dbSyncConfig = mkDbSyncConfig "shelley_qa" nodeConfig; usePeersFromLedgerAfterSlot = 23574838; }; + + p2p = rec { + useByronWallet = false; + private = false; + relaysNew = "relays.p2p.dev.cardano.org"; + explorerUrl = "https://explorer.p2p.dev.cardano.org"; + smashUrl = "https://smash.p2p.dev.cardano.org"; + metadataUrl = "https://metadata.cardano-testnet.iohkdev.io"; + networkConfig = import ./p2p-config.nix; + consensusProtocol = networkConfig.Protocol; + nodeConfig = defaultLogConfig // networkConfig; + edgePort = 3001; + explorerConfig = mkExplorerConfig "p2p" nodeConfig; + usePeersFromLedgerAfterSlot = 14680; + }; + preprod = rec { useByronWallet = false; private = false; @@ -128,5 +194,135 @@ usePeersFromLedgerAfterSlot = 32000; }; }; -in - environments + # TODO: add flag to disable with forEnvironments instead of hard-coded list? + forEnvironments = f: lib.mapAttrs + (name: env: f (env // { inherit name; })) + environments; + forEnvironmentsCustom = f: environments: lib.mapAttrs + (name: env: f (env // { inherit name; })) + environments; + eachEnv = lib.flip lib.pipe [ + (lib.forEach (builtins.attrNames environments)) + lib.listToAttrs + ]; + + cardanoConfig = ./.; + + protNames = { + RealPBFT = { n = "byron"; }; + TPraos = { n = "shelley"; }; + Cardano = { n = "byron"; shelley = "shelley"; alonzo = "alonzo"; conway = "conway"; }; + }; + + configHtml = environments: + '' + <!DOCTYPE html> + <html> + <head> + <title>Cardano Configurations</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.8.0/css/bulma.min.css"> + <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> + </head> + <body> + <section class="hero is-small is-primary"> + <div class="hero-body"> + <div class="container"> + <h1 class="title is-1"> + Cardano + </h1> + <h2 class="subtitle is-3"> + Configurations + </h2> + </div> + </div> + </section> + + <section class="section"> + <div class="container"> + <div class="table-container"> + <table class="table is-narrow is-fullwidth"> + <thead> + <tr> + <th>Cluster</th> + <th>Config</th> + </tr> + </thead> + <tbody> + ${toString (lib.mapAttrsToList (env: value: + let p = value.consensusProtocol; + in '' + <tr> + <td>${env}</td> + <td> + <div class="buttons has-addons"> + <a class="button is-primary" href="${env}-config.json">config</a> + <a class="button is-info" href="${env}-${protNames.${p}.n}-genesis.json">${protNames.${p}.n}Genesis</a> + ${lib.optionalString (p == "Cardano") '' + <a class="button is-info" href="${env}-${protNames.${p}.shelley}-genesis.json">${protNames.${p}.shelley}Genesis</a> + <a class="button is-info" href="${env}-${protNames.${p}.alonzo}-genesis.json">${protNames.${p}.alonzo}Genesis</a> + ''} + ${lib.optionalString (p == "Cardano" && value.nodeConfig ? ConwayGenesisFile) '' + <a class="button is-info" href="${env}-${protNames.${p}.conway}-genesis.json">${protNames.${p}.conway}Genesis</a> + ''} + <a class="button is-info" href="${env}-topology.json">topology</a> + </div> + </td> + </tr> + '' + ) environments) } + </tbody> + </table> + </div> + </div> + </section> + </body> + </html> + ''; + + # Any environments using the HFC protocol of "Cardano" need a second genesis file attribute of + # genesisFileHfc in order to generate the html table in mkConfigHtml + mkConfigHtml = environments: runCommand "cardano-html" { buildInputs = [ jq ]; } '' + mkdir -p $out/nix-support + cp ${writeText "config.html" (configHtml environments)} $out/index.html + ${ + toString (lib.mapAttrsToList (env: value: + let p = value.consensusProtocol; + in '' + ${if p != "Cardano" then '' + ${jq}/bin/jq . < ${__toFile "${env}-config.json" (__toJSON (value.nodeConfig // { + GenesisFile = "${env}-${protNames.${p}.n}-genesis.json"; + }))} > $out/${env}-config.json + '' else '' + ${jq}/bin/jq . < ${__toFile "${env}-config.json" (__toJSON (value.nodeConfig // { + ByronGenesisFile = "${env}-${protNames.${p}.n}-genesis.json"; + ShelleyGenesisFile = "${env}-${protNames.${p}.shelley}-genesis.json"; + AlonzoGenesisFile = "${env}-${protNames.${p}.alonzo}-genesis.json"; + ConwayGenesisFile = "${env}-${protNames.${p}.conway}-genesis.json"; + }))} > $out/${env}-config.json + ''} + ${lib.optionalString (p == "RealPBFT" || p == "Byron") '' + cp ${value.nodeConfig.GenesisFile} $out/${env}-${protNames.${p}.n}-genesis.json + ''} + ${lib.optionalString (p == "TPraos") '' + cp ${value.nodeConfig.GenesisFile} $out/${env}-${protNames.${p}.n}-genesis.json + ''} + ${lib.optionalString (p == "Cardano") '' + cp ${value.nodeConfig.ShelleyGenesisFile} $out/${env}-${protNames.${p}.shelley}-genesis.json + cp ${value.nodeConfig.ByronGenesisFile} $out/${env}-${protNames.${p}.n}-genesis.json + cp ${value.nodeConfig.AlonzoGenesisFile} $out/${env}-${protNames.${p}.alonzo}-genesis.json + ''} + ${lib.optionalString (p == "Cardano" && value.nodeConfig ? ConwayGenesisFile) '' + cp ${value.nodeConfig.ConwayGenesisFile} $out/${env}-${protNames.${p}.conway}-genesis.json + ''} + ${jq}/bin/jq . < ${mkEdgeTopology { edgeNodes = [ value.relaysNew ]; valency = 2; }} > $out/${env}-topology.json + '' + ) environments ) + } + echo "report cardano $out index.html" > $out/nix-support/hydra-build-products + ''; + +in { + inherit environments forEnvironments forEnvironmentsCustom eachEnv mkEdgeTopology mkProxyTopology cardanoConfig defaultLogConfig defaultExplorerLogConfig mkConfigHtml mkExplorerConfig; +} Only in cardano-lib: explorer-log-config.nix Common subdirectories: cardano-world/nix/cardano/environments/mainnet and cardano-lib/mainnet Only in cardano-lib: p2p Only in cardano-lib: p2p-config.nix Common subdirectories: cardano-world/nix/cardano/environments/preprod and cardano-lib/preprod Common subdirectories: cardano-world/nix/cardano/environments/preview and cardano-lib/preview Common subdirectories: cardano-world/nix/cardano/environments/private and cardano-lib/private Common subdirectories: cardano-world/nix/cardano/environments/shelley_qa and cardano-lib/shelley_qa Only in cardano-lib: testnet Only in cardano-lib: testnet-config.nix Common subdirectories: cardano-world/nix/cardano/environments/testnet-template and cardano-lib/testnet-template ```
This is currently referenced in cardano-db-sync#1403, and cardano-db-sync will need to be updated after this PR was merged. |
9 tasks
3e1b3ba
to
1686960
Compare
d1d0268
to
3b14e55
Compare
3b14e55
to
f8de31a
Compare
angerman
commented
May 13, 2023
angerman
commented
May 13, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I guess the formatting is due to nixfmt
?
LGT Everyone. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This now integrates the environments from cardano-world.
for
cardano-world@8.x-integration (fa98319)
gives us