From 5f0876ee1f4fabe868e29457c97a84aa9348aa18 Mon Sep 17 00:00:00 2001 From: Sam Jeston Date: Wed, 17 Jul 2019 14:28:32 +1000 Subject: [PATCH 1/2] Enable custom configuration when starting demo cluster --- .../cardano-wallet-test-genesis.yaml | 107 ++++++++++++++++++ nix/cardano-sl-config.nix | 1 + nix/launch/demo-cluster/default.nix | 8 +- nix/scripts.nix | 4 +- scripts/launch/demo-nix.sh | 15 ++- 5 files changed, 127 insertions(+), 8 deletions(-) create mode 100644 configurations/cardano-wallet-test-genesis.yaml diff --git a/configurations/cardano-wallet-test-genesis.yaml b/configurations/cardano-wallet-test-genesis.yaml new file mode 100644 index 00000000000..cacabe28d4e --- /dev/null +++ b/configurations/cardano-wallet-test-genesis.yaml @@ -0,0 +1,107 @@ +default: &default + core: &default_core + requiresNetworkMagic: RequiresMagic + dbSerializeVersion: 0 + + genesis: &default_core_genesis + spec: &default_core_genesis_spec + initializer: + testBalance: + poors: 1 + richmen: 4 + richmenShare: 0.90 + useHDAddresses: True + totalBalance: 1000000000000000000 + fakeAvvmBalance: + count: 0 + oneBalance: 1 + avvmBalanceFactor: 1 + useHeavyDlg: True + seed: 0 + blockVersionData: &default_core_genesis_spec_blockVersionData + scriptVersion: 0 + slotDuration: 10000 + maxBlockSize: 2000000 + maxHeaderSize: 2000000 + maxTxSize: 65536 # 64 Kb + maxProposalSize: 700 # 700 bytes + mpcThd: 0.01 # 1% of stake + heavyDelThd: 0.005 # 0.5% of stake + updateVoteThd: 0.001 # 0.1% of total stake + updateProposalThd: 0.1 # 10% of total stake + updateImplicit: 10 # slots + softforkRule: + initThd: 0.9 # 90% of total stake + minThd: 0.6 # 60% of total stake + thdDecrement: 0.05 # 5% of total stake + txFeePolicy: + txSizeLinear: + a: 155381 # absolute minimal fees per transaction + b: 43.946 # additional minimal fees per byte of transaction size + unlockStakeEpoch: 18446744073709551615 # last epoch (maxBound @Word64) + protocolConstants: &default_core_genesis_spec_protocolConstants + k: 2160 + protocolMagic: 1097911063 + vssMinTTL: 2 + vssMaxTTL: 6 + ftsSeed: "kmFzYSBvcGFzYSBza292b3JvZGEgR2d1cmRhIGJvcm9kYSBwcm92b2Rh" + heavyDelegation: {} + avvmDistr: {} + + txValidationRules: + attribResrictEpoch: 2 + addrAttribSize: 128 + txAttribSize: 128 + + ntp: &default_ntp + # NTP + responseTimeout: 30000000 # 30 sec + pollDelay: 1800000000 # 30 min + servers: + - "0.pool.ntp.org" + - "2.pool.ntp.org" + - "3.pool.ntp.org" + + update: &default_update + applicationName: cardano-sl + applicationVersion: 0 + lastKnownBlockVersion: + bvMajor: 0 + bvMinor: 0 + bvAlt: 0 + + ssc: &default_ssc + mpcSendInterval: 10 # must be less than (2 * k * slotDuration - networkDiameter) + mdNoCommitmentsEpochThreshold: 3 + noReportNoSecretsForEpoch1: False + + txp: &default_txp + memPoolLimitTx: 200 # mem pool will be limited to this many transactions + assetLockedSrcAddrs: [] + + dlg: &default_dlg + dlgCacheParam: 500 + messageCacheTimeout: 30 + + block: &default_block + networkDiameter: 3 + recoveryHeadersMessage: 20 # should be greater than k + streamWindow: 2048 + nonCriticalCQBootstrap: 0.95 + criticalCQBootstrap: 0.8888 + nonCriticalCQ: 0.8 + criticalCQ: 0.654321 + criticalForkThreshold: 2 + fixedTimeCQ: 10 + + node: &default_node + networkConnectionTimeout: 30000 # ms + conversationEstablishTimeout: 30000 + blockRetrievalQueueSize: 100 + pendingTxResubmissionPeriod: 60 # seconds + walletProductionApi: false + walletTxCreationDisabled: false + explorerExtendedApi: false + + wallet: &default_wallet + throttle: null \ No newline at end of file diff --git a/nix/cardano-sl-config.nix b/nix/cardano-sl-config.nix index c9c3e8c09f7..0386f8cb971 100644 --- a/nix/cardano-sl-config.nix +++ b/nix/cardano-sl-config.nix @@ -2,6 +2,7 @@ runCommand "cardano-sl-config" {} '' mkdir -p $out/lib + cp -R ${../configurations} $out/configurations cp -R ${../log-configs} $out/log-configs cp ${../lib}/configuration.yaml $out/lib cp ${../lib}/*genesis*.json $out/lib diff --git a/nix/launch/demo-cluster/default.nix b/nix/launch/demo-cluster/default.nix index a0330386929..bf4e354ea2a 100755 --- a/nix/launch/demo-cluster/default.nix +++ b/nix/launch/demo-cluster/default.nix @@ -20,6 +20,7 @@ with import ../../../lib.nix; , disableClientAuth ? false , walletListen ? "127.0.0.1:8090" , walletDocListen ? "127.0.0.1:8190" +, customConfigurationFile ? "false" }: let @@ -33,6 +34,7 @@ let assetLockFile = writeText "asset-lock-file" (intersperse "\n" assetLockAddresses); ifAssetLock = optionalString (assetLockAddresses != []); ifDisableClientAuth = optionalString disableClientAuth; + ifCustomConfiguration = optionalString (customConfigurationFile != "false"); prepareGenesis = callPackage ../../prepare-genesis { inherit numCoreNodes stateDir; configurationKey = "testnet_full"; @@ -47,6 +49,7 @@ in writeScript "demo-cluster" '' export DEMO_SYSTEM_START=$(($(date +%s) + 14)) ${ifAssetLock "export DEMO_ASSET_LOCK_FILE=${assetLockFile}"} ${ifDisableClientAuth "export DEMO_NO_CLIENT_AUTH=True"} + ${ifCustomConfiguration "export DEMO_CONFIGURATION_FILE=${cardanoConfig}/configurations/${customConfigurationFile}"} # Set to 0 (passing) by default. Tests using this cluster can set this variable # to force the `stop_cardano` function to exit with a different code. EXIT_STATUS=0 @@ -66,13 +69,14 @@ in writeScript "demo-cluster" '' trap "stop_cardano" INT TERM echo "Launching a demo cluster..." + echo "Configuration file: $DEMO_CONFIGURATION_FILE" cardano-sl-cluster-prepare-environment "DEMO_" --cores ${builtins.toString numCoreNodes} --relays ${builtins.toString numRelayNodes} --edges ${builtins.toString numEdgeNodes} cardano-sl-cluster-demo --cores ${builtins.toString numCoreNodes} --relays ${builtins.toString numRelayNodes} --edges 0 & pidCluster=$! ${ifWallet '' - cardano-node \ - --configuration-file ${cardanoConfig}/lib/configuration.yaml \ + cardano-node \ + --configuration-file $DEMO_CONFIGURATION_FILE \ --tlscert ${stateDir}/tls/edge/server.crt \ --tlskey ${stateDir}/tls/edge/server.key \ --tlsca ${stateDir}/tls/edge/ca.crt \ diff --git a/nix/scripts.nix b/nix/scripts.nix index 9e40e64cf92..29e91e766e8 100644 --- a/nix/scripts.nix +++ b/nix/scripts.nix @@ -37,8 +37,8 @@ in { }); inherit demoCluster; - demo-function = { disableClientAuth, numImportedWallets, runWallet }: demoCluster.override { - inherit disableClientAuth numImportedWallets runWallet; + demo-function = { disableClientAuth, numImportedWallets, runWallet, customConfigurationFile }: demoCluster.override { + inherit disableClientAuth numImportedWallets runWallet customConfigurationFile; }; dockerImages = let build = args: pkgs.callPackage ./docker.nix ({ diff --git a/scripts/launch/demo-nix.sh b/scripts/launch/demo-nix.sh index cadab875543..4983316bd50 100755 --- a/scripts/launch/demo-nix.sh +++ b/scripts/launch/demo-nix.sh @@ -7,6 +7,7 @@ display_help() { echo " -d run with client auth disabled" echo " -w enable wallet" echo " -i INT number of wallets to import (default: 0)" + echo " -c Use a custom config file (from nix/launch/demo-cluster/configurations)" echo echo "$0 is used to launch a demo cluster with limited parameters." @@ -18,19 +19,19 @@ display_help() { RUN_WALLET="false" NUM_IMPORTED_WALLETS=0 DISABLE_CLIENT_AUTH="false" -ARGS=() +CUSTOM_CONFIGURATION_FILE="false" -while getopts hdwi: option +while getopts hdwic: option do case "${option}" in d) DISABLE_CLIENT_AUTH="true";; w) RUN_WALLET="true";; i) NUM_IMPORTED_WALLETS="${OPTARG}"; RUN_WALLET="true";; + c) CUSTOM_CONFIGURATION_FILE="${OPTARG}";; h) display_help; exit 0;; *) display_help; exit 1 esac done -ARGS+=(--arg runWallet "${RUN_WALLET}" --arg numImportedWallets "${NUM_IMPORTED_WALLETS}") if ! [ -x "$(command -v nix-build)" ]; then echo 'Error: nix is not installed.' >&2 @@ -41,5 +42,11 @@ fi GITREV=$(git rev-parse HEAD) -nix-build -A demo-function --arg disableClientAuth "$DISABLE_CLIENT_AUTH" --arg numImportedWallets "$NUM_IMPORTED_WALLETS" --arg runWallet "$RUN_WALLET" -o "launch_$GITREV" +nix-build -A demo-function \ + --arg disableClientAuth "$DISABLE_CLIENT_AUTH" \ + --arg numImportedWallets "$NUM_IMPORTED_WALLETS" \ + --arg runWallet "$RUN_WALLET" \ + --argstr customConfigurationFile "$CUSTOM_CONFIGURATION_FILE" \ + -o "launch_$GITREV" \ + exec ./launch_"$GITREV" From ac29de3be04819e6339dea51079242204c50f9b5 Mon Sep 17 00:00:00 2001 From: Sam Jeston Date: Thu, 18 Jul 2019 09:11:47 +1000 Subject: [PATCH 2/2] Allow absolute path specification for custom demo config --- .../cardano-wallet-test-genesis.yaml | 107 ------------------ nix/cardano-sl-config.nix | 1 - nix/launch/demo-cluster/default.nix | 2 +- scripts/launch/demo-nix.sh | 2 +- 4 files changed, 2 insertions(+), 110 deletions(-) delete mode 100644 configurations/cardano-wallet-test-genesis.yaml diff --git a/configurations/cardano-wallet-test-genesis.yaml b/configurations/cardano-wallet-test-genesis.yaml deleted file mode 100644 index cacabe28d4e..00000000000 --- a/configurations/cardano-wallet-test-genesis.yaml +++ /dev/null @@ -1,107 +0,0 @@ -default: &default - core: &default_core - requiresNetworkMagic: RequiresMagic - dbSerializeVersion: 0 - - genesis: &default_core_genesis - spec: &default_core_genesis_spec - initializer: - testBalance: - poors: 1 - richmen: 4 - richmenShare: 0.90 - useHDAddresses: True - totalBalance: 1000000000000000000 - fakeAvvmBalance: - count: 0 - oneBalance: 1 - avvmBalanceFactor: 1 - useHeavyDlg: True - seed: 0 - blockVersionData: &default_core_genesis_spec_blockVersionData - scriptVersion: 0 - slotDuration: 10000 - maxBlockSize: 2000000 - maxHeaderSize: 2000000 - maxTxSize: 65536 # 64 Kb - maxProposalSize: 700 # 700 bytes - mpcThd: 0.01 # 1% of stake - heavyDelThd: 0.005 # 0.5% of stake - updateVoteThd: 0.001 # 0.1% of total stake - updateProposalThd: 0.1 # 10% of total stake - updateImplicit: 10 # slots - softforkRule: - initThd: 0.9 # 90% of total stake - minThd: 0.6 # 60% of total stake - thdDecrement: 0.05 # 5% of total stake - txFeePolicy: - txSizeLinear: - a: 155381 # absolute minimal fees per transaction - b: 43.946 # additional minimal fees per byte of transaction size - unlockStakeEpoch: 18446744073709551615 # last epoch (maxBound @Word64) - protocolConstants: &default_core_genesis_spec_protocolConstants - k: 2160 - protocolMagic: 1097911063 - vssMinTTL: 2 - vssMaxTTL: 6 - ftsSeed: "kmFzYSBvcGFzYSBza292b3JvZGEgR2d1cmRhIGJvcm9kYSBwcm92b2Rh" - heavyDelegation: {} - avvmDistr: {} - - txValidationRules: - attribResrictEpoch: 2 - addrAttribSize: 128 - txAttribSize: 128 - - ntp: &default_ntp - # NTP - responseTimeout: 30000000 # 30 sec - pollDelay: 1800000000 # 30 min - servers: - - "0.pool.ntp.org" - - "2.pool.ntp.org" - - "3.pool.ntp.org" - - update: &default_update - applicationName: cardano-sl - applicationVersion: 0 - lastKnownBlockVersion: - bvMajor: 0 - bvMinor: 0 - bvAlt: 0 - - ssc: &default_ssc - mpcSendInterval: 10 # must be less than (2 * k * slotDuration - networkDiameter) - mdNoCommitmentsEpochThreshold: 3 - noReportNoSecretsForEpoch1: False - - txp: &default_txp - memPoolLimitTx: 200 # mem pool will be limited to this many transactions - assetLockedSrcAddrs: [] - - dlg: &default_dlg - dlgCacheParam: 500 - messageCacheTimeout: 30 - - block: &default_block - networkDiameter: 3 - recoveryHeadersMessage: 20 # should be greater than k - streamWindow: 2048 - nonCriticalCQBootstrap: 0.95 - criticalCQBootstrap: 0.8888 - nonCriticalCQ: 0.8 - criticalCQ: 0.654321 - criticalForkThreshold: 2 - fixedTimeCQ: 10 - - node: &default_node - networkConnectionTimeout: 30000 # ms - conversationEstablishTimeout: 30000 - blockRetrievalQueueSize: 100 - pendingTxResubmissionPeriod: 60 # seconds - walletProductionApi: false - walletTxCreationDisabled: false - explorerExtendedApi: false - - wallet: &default_wallet - throttle: null \ No newline at end of file diff --git a/nix/cardano-sl-config.nix b/nix/cardano-sl-config.nix index 0386f8cb971..c9c3e8c09f7 100644 --- a/nix/cardano-sl-config.nix +++ b/nix/cardano-sl-config.nix @@ -2,7 +2,6 @@ runCommand "cardano-sl-config" {} '' mkdir -p $out/lib - cp -R ${../configurations} $out/configurations cp -R ${../log-configs} $out/log-configs cp ${../lib}/configuration.yaml $out/lib cp ${../lib}/*genesis*.json $out/lib diff --git a/nix/launch/demo-cluster/default.nix b/nix/launch/demo-cluster/default.nix index bf4e354ea2a..8106c168e56 100755 --- a/nix/launch/demo-cluster/default.nix +++ b/nix/launch/demo-cluster/default.nix @@ -49,7 +49,7 @@ in writeScript "demo-cluster" '' export DEMO_SYSTEM_START=$(($(date +%s) + 14)) ${ifAssetLock "export DEMO_ASSET_LOCK_FILE=${assetLockFile}"} ${ifDisableClientAuth "export DEMO_NO_CLIENT_AUTH=True"} - ${ifCustomConfiguration "export DEMO_CONFIGURATION_FILE=${cardanoConfig}/configurations/${customConfigurationFile}"} + ${ifCustomConfiguration "export DEMO_CONFIGURATION_FILE=${customConfigurationFile}"} # Set to 0 (passing) by default. Tests using this cluster can set this variable # to force the `stop_cardano` function to exit with a different code. EXIT_STATUS=0 diff --git a/scripts/launch/demo-nix.sh b/scripts/launch/demo-nix.sh index 4983316bd50..bc1e484d042 100755 --- a/scripts/launch/demo-nix.sh +++ b/scripts/launch/demo-nix.sh @@ -7,7 +7,7 @@ display_help() { echo " -d run with client auth disabled" echo " -w enable wallet" echo " -i INT number of wallets to import (default: 0)" - echo " -c Use a custom config file (from nix/launch/demo-cluster/configurations)" + echo " -c Absolute path to a custom config file" echo echo "$0 is used to launch a demo cluster with limited parameters."