diff --git a/benchmarks/shelley3pools/benchmark-generic.sh b/benchmarks/shelley3pools/benchmark-generic.sh new file mode 100755 index 00000000..731b1706 --- /dev/null +++ b/benchmarks/shelley3pools/benchmark-generic.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +# preparation +BASEDIR=$(realpath $(dirname "$0")) +. "${BASEDIR}"/../../scripts/common.sh + +##prebuild 'cardano-tx-generator' || exit 1 +#prebuild 'cardano-rt-view' || exit 1 +prebuild 'cardano-node' || exit 1 +prebuild 'cardano-cli' || exit 1 + +export CLICMD="run cardano-cli" + +TMUX_ENV_PASSTHROUGH=( + "export era=shelley; export DBDIR=${DBDIR}; export SOCKETDIR=${SOCKETDIR};" + "export SCRIPTS_LIB_SH_MODE=${SCRIPTS_LIB_SH_MODE};" + "export __COMMON_SRCROOT=${__COMMON_SRCROOT};" + "export DEFAULT_DEBUG=${DEFAULT_DEBUG};" + "export DEFAULT_VERBOSE=${DEFAULT_VERBOSE};" + "export DEFAULT_TRACE=${DEFAULT_TRACE};" + "$(nix_cache_passthrough)" +) + + +# 0 cleanup +rm -rf ./db/* ./logs/* +mkdir -p logs/sockets + +# 1 prepare genesis +./prepare_genesis.sh + +# 2 run rt-view +tmux select-window -t :0 +tmux new-window -n RTview \ + "${TMUX_ENV_PASSTHROUGH[*]} ./run-rt-view.sh; $SHELL" +sleep 1 + +# 3 run pools +tmux select-window -t :0 +tmux new-window -n Nodes \ + "${TMUX_ENV_PASSTHROUGH[*]} ./run-Npools.sh; $SHELL" +sleep 2 + +# 4 run tx-gen +tmux select-window -t :0 +tmux new-window -n TxGen \ + "sleep 7; ${TMUX_ENV_PASSTHROUGH[*]} ./run-tx-generator.sh; $SHELL" +sleep 30 + +# 5 send delegation transactions +tmux select-window -t :0 +tmux new-window -n Delegation \ + "sleep 5; ${TMUX_ENV_PASSTHROUGH[*]} ./submit_delegation_tx.sh; $SHELL" + +tmux select-window -t Nodes +sleep 1 +$SHELL diff --git a/benchmarks/shelley3pools/configuration-generator.sh b/benchmarks/shelley3pools/configuration-generator.sh new file mode 100755 index 00000000..985c90fb --- /dev/null +++ b/benchmarks/shelley3pools/configuration-generator.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +. ./configuration/parameters + +NNODES=${NNODES:-3} + +for i in $(seq 1 ${NNODES}) +do + cp ./configuration/configuration-template.yaml ./configuration/configuration-node-${i}.yaml + sed -i "s//${i}/g" ./configuration/configuration-node-${i}.yaml +done diff --git a/benchmarks/shelley3pools/configuration/configuration-template.yaml b/benchmarks/shelley3pools/configuration/configuration-template.yaml new file mode 100644 index 00000000..92952e66 --- /dev/null +++ b/benchmarks/shelley3pools/configuration/configuration-template.yaml @@ -0,0 +1,279 @@ +########################################################## +############### Mainnet ######### +############### Cardano Byron Node Configuration ######### +########################################################## + + +##### Locations ##### + +GenesisFile: genesis/genesis.json + +##### Core protocol parameters ##### + +# This is the instance of the Ouroboros family that we are running. +# The node also supports various test and mock instances. +# "RealPBFT" is the real (ie not mock) (permissive) OBFT protocol, which +# is what we use on mainnet in Byron era. +Protocol: TPraos + +# The mainnet does not include the network magic into addresses. Testnets do. +RequiresNetworkMagic: RequiresMagic + + +##### Update system parameters ##### + +# This protocol version number gets used by by block producing nodes as part +# part of the system for agreeing on and synchronising protocol updates. +LastKnownBlockVersion-Major: 0 +LastKnownBlockVersion-Minor: 2 +LastKnownBlockVersion-Alt: 0 + +# In the Byron era some software versions are also published on the chain. +# We do this only for Byron compatibility now. +ApplicationName: cardano-sl +ApplicationVersion: 1 + + +##### Logging configuration ##### + +# The node can run in either the SimpleView or LiveView. The SimpleView just +# uses standard output, optionally with log output. The LiveView is a text +# console on Linux and Mac OSX with a live view of various node metrics. +# When LiveView is used logging output to 'stdout' is automatically disabled. +#ViewMode: SimpleView +ViewMode: LiveView + +# Enble or disable logging overall +TurnOnLogging: True + +# Enable the collection of various OS metrics such as memory and CPU use. +# These metrics are traced in the context name: 'cardano.node-metrics' and can +# be directed to the logs or monitoring backends. +TurnOnLogMetrics: True + +# Global logging severity filter. Messages must have at least this severity to +# pass. Typical values would be Warning, Notice, Info or Debug. +minSeverity: Debug + +# Log items can be rendered with more or less verbose detail. +# Verbosity ranges from MinimalVerbosity, NormalVerbosity to MaximalVerbosity +TracingVerbosity: MaximalVerbosity + +# The system supports a number of backends for logging and monitoring. +# This setting lists the the backends that will be available to use in the +# configuration below. The logging backend is called Katip. +setupBackends: + - KatipBK +# - TraceForwarderBK + +# This specifies the default backends that trace output is sent to if it +# is not specifically configured to be sent to other backends. +defaultBackends: + - KatipBK +# - TraceForwarderBK + +# EKG is a simple metrics monitoring system. Uncomment the following to enable +# this backend and listen on the given local port and point your web browser to +# http://localhost:12788/ +hasEKG: 12788 + +# The Prometheus monitoring system exports EKG metrics. Uncomment the following +# to listen on the given port. Output is provided on +# http://localhost:12798/metrics +hasPrometheus: + - "127.0.0.1" + - 12798 + +# To enable the 'TraceForwarder' backend, uncomment the following setting. Log +# items are then forwarded based on an entry in 'mapBackends' to a separate +# process running a 'TraceAcceptor'. +# Example using UNIX pipes: +#traceForwardTo: +# tag: RemotePipe +# contents: "logs/sockets/pool1" +# +# Example using Windows named pipes: +# traceForwardTo: +# tag: RemotePipe +# contents: "\\\\.\\pipe\\acceptor" +# +# Example using network socket: +# traceForwardTo: +# tag: RemoteSocket +# contents: +# - "127.0.0.1" +# - "2997" + +# For the Katip logging backend we must set up outputs (called scribes) +# The available types of scribe are: +# FileSK for files +# StdoutSK/StderrSK for stdout/stderr +# JournalSK for systemd's journal system +# DevNullSK ignores all output +# The scribe output format can be ScText or ScJson. Log rotation settings can +# be specified in the defaults below or overidden on a per-scribe basis here. +setupScribes: + - scKind: FileSK + scName: "logs/node.json" + scFormat: ScJson + - scKind: FileSK + scName: "logs/node.log" + scFormat: ScText + +# For the Katip logging backend this specifies the default scribes that trace +# output is sent to if it is not configured to be sent to other scribes. +defaultScribes: + - - FileSK + - "logs/node.json" + - - FileSK + - "logs/node.log" + +# The default file rotation settings for katip scribes, unless overridden +# in the setupScribes above for specific scribes. +rotation: + rpLogLimitBytes: 15000000 + rpKeepFilesNum: 100 + rpMaxAgeHours: 24 + + +##### Coarse grained logging control ##### + +# Trace output from whole subsystems can be enabled/disabled using the following +# settings. This provides fairly coarse grained control, but it is relatively +# efficient at filtering out unwanted trace output. + +# Trace BlockFetch client. +TraceBlockFetchClient: False + +# Trace BlockFetch decisions made by the BlockFetch client. +# needed to display "peers" and their block height in LiveView +TraceBlockFetchDecisions: True + +# Trace BlockFetch protocol messages. +TraceBlockFetchProtocol: False + +# Serialised Trace BlockFetch protocol messages. +TraceBlockFetchProtocolSerialised: False + +# Trace BlockFetch server. +TraceBlockFetchServer: False + +# Verbose tracer of ChainDB +TraceChainDb: True + +# Trace ChainSync client. +TraceChainSyncClient: False + +# Trace ChainSync server (blocks). +TraceChainSyncBlockServer: False + +# Trace ChainSync server (headers) +TraceChainSyncHeaderServer: False + +# Trace ChainSync protocol messages. +TraceChainSyncProtocol: False + +# Trace DNS Resolver messages. +TraceDNSResolver: True + +# Trace DNS Subscription messages. +TraceDNSSubscription: True + +# Trace error policy resolution. +TraceErrorPolicy: True + +# Trace local error policy resolution. +TraceLocalErrorPolicy: True + +# Trace block forging. +TraceForge: True + +# Trace Handshake protocol messages. +TraceHandshake: False + +# Trace IP Subscription messages. +TraceIpSubscription: True + +# Trace local ChainSync protocol messages. +TraceLocalChainSyncProtocol: False + +# Trace local Handshake protocol messages. +TraceLocalHandshake: False + +# Trace local TxSubmission protocol messages. +TraceLocalTxSubmissionProtocol: False + +# Trace local TxSubmission server. +TraceLocalTxSubmissionServer: False + +# Trace mempool. +TraceMempool: True + +# Trace Mux Events +TraceMux: False + +# Trace TxSubmission server (inbound transactions). +TraceTxInbound: False + +# Trace TxSubmission client (outbound transactions). +TraceTxOutbound: False + +# Trace TxSubmission protocol messages. +TraceTxSubmissionProtocol: False + + +##### Fine grained logging control ##### + +# It is also possible to have more fine grained control over filtering of +# trace output, and to match and route trace output to particular backends. +# This is less efficient than the coarse trace filters above but provides +# much more precise control. + +options: + + # This routes metrics matching specific names to particular backends. + # This overrides the 'defaultBackends' listed above. And note that it is + # an override and not an extension so anything matched here will not + # go to the default backend, only to the explicitly listed backends. + mapBackends: + cardano.node.BlockFetchDecision.peers: + - TraceForwarderBK + - EKGViewBK + - kind: UserDefinedBK + name: LiveViewBackend + cardano.node.ChainDB.metrics: + - TraceForwarderBK + - EKGViewBK + - kind: UserDefinedBK + name: LiveViewBackend + cardano.node.metrics: + - TraceForwarderBK + - EKGViewBK + - kind: UserDefinedBK + name: LiveViewBackend + cardano.node.Forge.metrics: + - TraceForwarderBK + - EKGViewBK + cardano.node.release: + - TraceForwarderBK + - KatipBK + cardano.node.version: + - TraceForwarderBK + - KatipBK + cardano.node.commit: + - TraceForwarderBK + - KatipBK + + # redirects traced values to a specific scribe which is identified by its + # type and its name, separated by "::": + mapScribes: + cardano.node-metrics: + - "FileSK::logs/node.json" + + # apply a filter on message severity on messages in a specific named context. + # this filter is applied additionally to the global 'minSeverity' and thus + # needs to be at least as high. + mapSeverity: + cardano.node.ChainDB: Info + cardano.node.DnsSubscription: Info + diff --git a/benchmarks/shelley3pools/configuration/topology-node-1.json b/benchmarks/shelley3pools/configuration/topology-node-1.json index 5cc1d732..58fa0069 100644 --- a/benchmarks/shelley3pools/configuration/topology-node-1.json +++ b/benchmarks/shelley3pools/configuration/topology-node-1.json @@ -1,5 +1,10 @@ { "Producers": [ + { + "addr": "127.0.0.1", + "port": 3003, + "valency": 1 + }, { "addr": "127.0.0.1", "port": 3002, diff --git a/benchmarks/shelley3pools/configuration/topology-node-2.json b/benchmarks/shelley3pools/configuration/topology-node-2.json index 6cbb761d..8c5d826c 100644 --- a/benchmarks/shelley3pools/configuration/topology-node-2.json +++ b/benchmarks/shelley3pools/configuration/topology-node-2.json @@ -1,5 +1,10 @@ { "Producers": [ + { + "addr": "127.0.0.1", + "port": 3003, + "valency": 1 + }, { "addr": "127.0.0.1", "port": 3002, diff --git a/benchmarks/shelley3pools/configuration/topology-node-3.json b/benchmarks/shelley3pools/configuration/topology-node-3.json index 9337a3e6..df1a9e38 100644 --- a/benchmarks/shelley3pools/configuration/topology-node-3.json +++ b/benchmarks/shelley3pools/configuration/topology-node-3.json @@ -1,5 +1,10 @@ { "Producers": [ + { + "addr": "127.0.0.1", + "port": 3003, + "valency": 1 + }, { "addr": "127.0.0.1", "port": 3000, diff --git a/benchmarks/shelley3pools/configuration/topology-node-4.json b/benchmarks/shelley3pools/configuration/topology-node-4.json new file mode 100644 index 00000000..7a85bc6a --- /dev/null +++ b/benchmarks/shelley3pools/configuration/topology-node-4.json @@ -0,0 +1,20 @@ +{ + "Producers": [ + { + "addr": "127.0.0.1", + "port": 3000, + "valency": 1 + }, + { + "addr": "127.0.0.1", + "port": 3001, + "valency": 1 + }, + { + "addr": "127.0.0.1", + "port": 3002, + "valency": 1 + } + ] +} + diff --git a/benchmarks/shelley3pools/create-addresses-generic.sh b/benchmarks/shelley3pools/create-addresses-generic.sh new file mode 100755 index 00000000..3f9f5974 --- /dev/null +++ b/benchmarks/shelley3pools/create-addresses-generic.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +. configuration/parameters + +ID=$1 + +NUM_OF_ADDRESSES=${NUM_OF_ADDRESSES:-3} +CLICMD="../../bin/cardano-cli" + +WORKDIR=./tmp + +for i in $(seq 1 $NUM_OF_ADDRESSES) +do + ${CLICMD} shelley address key-gen \ + --verification-key-file ${WORKDIR}/Test_${ID}/addresses/payment_$i.vkey \ + --signing-key-file $WORKDIR/Test_${ID}/addresses/payment_$i.skey + + ${CLICMD} shelley address build \ + --verification-key-file $WORKDIR/Test_${ID}/addresses/payment_$i.vkey \ + --testnet-magic ${MAGIC} > $WORKDIR/Test_${ID}/addresses/address_$i +done diff --git a/benchmarks/shelley3pools/fund-addresses-generic.sh b/benchmarks/shelley3pools/fund-addresses-generic.sh new file mode 100755 index 00000000..835db4ba --- /dev/null +++ b/benchmarks/shelley3pools/fund-addresses-generic.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +# set -x + +echo "Importing and initialising variables..." + +. ./configuration/parameters +CLICMD="../../bin/cardano-cli" + +ID=$1 +UTXO_ID=$2 +SOCKET_ID=$3 + +export CARDANO_NODE_SOCKET_PATH="./logs/sockets/${SOCKET_ID}" +NUM_OF_ADDRESSES=${NUM_OF_ADDRESSES:-3} +WORKDIR=./tmp + +# Initial set-up +if [ -d ${WORKDIR} ]; then rm -rf ./${WORKDIR}; fi +mkdir -p ./${WORKDIR}/Test_${ID}/txs +mkdir -p ./${WORKDIR}/Test_${ID}/addresses + +echo "Creating Payer ${ID}s account..." + +# Fund address from Genesis +## Get the initial UTxO TxIn +${CLICMD} shelley genesis initial-txin \ + --verification-key-file configuration/genesis/utxo-keys/utxo${UTXO_ID}.vkey \ + --testnet-magic ${MAGIC} > ${WORKDIR}/Test_${ID}/genesis_utxo${ID} + +## Set-up the Payer +### Create the keys and addresses for Payer +${CLICMD} shelley address key-gen \ + --verification-key-file ${WORKDIR}/Test_${ID}/payer${ID}.vkey \ + --signing-key-file ${WORKDIR}/Test_${ID}/payer${ID}.skey + +${CLICMD} shelley address build \ + --testnet-magic ${MAGIC} \ + --payment-verification-key-file ${WORKDIR}/Test_${ID}/payer${ID}.vkey > ${WORKDIR}/Test_${ID}/payer${ID}.addr + +echo "Funding Payer ${ID}s account..." + +### Build, Sign, Submit a Genesis UTxO to the Payer +${CLICMD} shelley transaction build-raw \ + --tx-in `cat ${WORKDIR}/Test_${ID}/genesis_utxo${ID}`#0 \ + --tx-out `cat ${WORKDIR}/Test_${ID}/payer${ID}.addr`+$(( ${SUPPLY} / ${NNODES} )) \ + --ttl 10000 \ + --fee 0 \ + --tx-body-file ${WORKDIR}/Test_${ID}/txs/genesis_to_funding${ID}.txbody + +${CLICMD} shelley transaction sign \ + --tx-body-file ${WORKDIR}/Test_${ID}/txs/genesis_to_funding${ID}.txbody \ + --signing-key-file configuration/genesis/utxo-keys/utxo${UTXO_ID}.skey \ + --testnet-magic ${MAGIC} \ + --tx-file ${WORKDIR}/Test_${ID}/txs/genesis_to_funding${ID}.tx + +${CLICMD} shelley transaction submit \ + --tx-file ${WORKDIR}/Test_${ID}/txs/genesis_to_funding${ID}.tx \ + --testnet-magic ${MAGIC} + +echo "Waiting for the UTxO to appear on-chain... (this will take ~15 seconds)" + +sleep 15 + +# Get the initial UTxO +${CLICMD} shelley query utxo \ + --address `cat ${WORKDIR}/Test_${ID}/payer${ID}.addr` \ + --testnet-magic ${MAGIC} | grep 0 | cut -f1 -d ' ' | sed 's/$/#0/g' > ${WORKDIR}/Test_${ID}/payer_utxo_0 + +echo "Creating ${NUM_OF_ADDRESSES} addresses..." + +# Create n target addresses +time ./create-addresses-generic.sh ${ID} +echo "" + +# Set-up variables for calculating change +let "payer_ada = ${SUPPLY} / ${utxo_keys}" +STD_TX=${txvalue} +STD_FEE=${txfee} + +echo "Submitting ${NUM_OF_ADDRESSES} transactions..." + +time for i in $(seq 1 ${NUM_OF_ADDRESSES}) +do + # Calculate change + let "payer_ada-=${STD_TX}" + let "payer_ada-=${STD_FEE}" + + # Build n transactions + ${CLICMD} shelley transaction build-raw \ + --tx-in `cat ${WORKDIR}/Test_${ID}/payer_utxo_$((${i} - 1))` \ + --tx-out `cat ${WORKDIR}/Test_${ID}/addresses/address_${i}`+${STD_TX} \ + --tx-out `cat ${WORKDIR}/Test_${ID}/payer${ID}.addr`+${payer_ada} \ + --ttl 10000000 \ + --fee ${STD_FEE} \ + --out-file ${WORKDIR}/Test_${ID}/txs/tx_${i}.raw + + # Sign n transactions + ${CLICMD} shelley transaction sign \ + --tx-body-file ${WORKDIR}/Test_${ID}/txs/tx_${i}.raw \ + --signing-key-file ${WORKDIR}/Test_${ID}/payer${ID}.skey \ + --testnet-magic ${MAGIC} \ + --out-file ${WORKDIR}/Test_${ID}/txs/tx_${i}.signed + + # Get the UTxO of the transaction for the input of the subsequent transaction + ${CLICMD} shelley transaction txid --tx-body-file ${WORKDIR}/Test_${ID}/txs/tx_${i}.raw | sed 's/$/#1/g'> ${WORKDIR}/Test_${ID}/payer_utxo_${i} + # Submit n transactions + ${CLICMD} shelley transaction submit \ + --tx-file ${WORKDIR}/Test_${ID}/txs/tx_${i}.signed \ + --testnet-magic ${MAGIC} + + if ! ((${i} % 100)); then + echo "Generated ${i} transactions." + fi +done + +echo "" +echo "Finished!" diff --git a/benchmarks/shelley3pools/manual-tx-generator.sh b/benchmarks/shelley3pools/manual-tx-generator.sh new file mode 100755 index 00000000..c83021e5 --- /dev/null +++ b/benchmarks/shelley3pools/manual-tx-generator.sh @@ -0,0 +1,11 @@ +set -x + +NUM_OF_GENERATORS=$1 +SOCKET_ID=1 + +for i in $(seq 1 ${NUM_OF_GENERATORS}) +do + let "utxo_id = ${i} + 2" + ./fund-addresses-generic.sh ${i} ${utxo_id} ${SOCKET_ID} & +done +wait \ No newline at end of file diff --git a/benchmarks/shelley3pools/prepare_genesis-generic.sh b/benchmarks/shelley3pools/prepare_genesis-generic.sh new file mode 100755 index 00000000..0de0ac2c --- /dev/null +++ b/benchmarks/shelley3pools/prepare_genesis-generic.sh @@ -0,0 +1,182 @@ +#!/usr/bin/env bash + +# for debugging +# set -x + +BASEDIR=$(realpath $(dirname "$0")) +. ${BASEDIR}/../../scripts/common.sh +. ${BASEDIR}/configuration/parameters + +cd ${BASEDIR} + +if [ -n "${GENESISDIR}" -a -d ${GENESISDIR} ]; then + rm -rf ${GENESISDIR} +fi +mkdir -p ${GENESISDIR} + +CLICMD=${CLICMD:-"stack --nix exec cardano-cli --"} + +# === genesis === +${CLICMD} shelley genesis create \ + --genesis-dir ${GENESISDIR} \ + --gen-genesis-keys ${genesis_keys} \ + --gen-utxo-keys ${utxo_keys} \ + --testnet-magic ${MAGIC} \ + --supply ${SUPPLY} + +## set parameters in template +sed -i ${GENESISDIR}/genesis.spec.json \ + -e 's/"slotLength": .*,/"slotLength": 0.2,/' \ + -e 's/"activeSlotsCoeff": .*,/"activeSlotsCoeff": 0.1,/' \ + -e 's/"securityParam": .*,/"securityParam": 10,/' \ + -e 's/"securityParam": [0-9]\+/"securityParam": 10/' \ + -e 's/"epochLength": .*,/"epochLength": 1500,/' \ + -e 's/"decentralisationParam": .*,/"decentralisationParam": 0.5,/' + +## update genesis from template +${CLICMD} shelley genesis create --genesis-dir ${GENESISDIR} --testnet-magic ${MAGIC} --supply ${SUPPLY} + +## set variables +for N in $(seq -s ' ' 1 $NNODES); do Pools[$N]=1; done +for N in ${STAKEPOOLS}; do Pools[$N]=2; done + +## create KES, VRF, certs per node +for N in $(seq 1 $NNODES); do + mkdir -p ${GENESISDIR}/node${N}/cold + + ${CLICMD} shelley node key-gen-KES \ + --verification-key-file ${GENESISDIR}/node${N}/kes.vkey \ + --signing-key-file ${GENESISDIR}/node${N}/kes.skey + + #### cold keys (do not copy to production system) + if [ ${Pools[$N]} -eq 2 ]; then ## Stakepool node + ${CLICMD} shelley node key-gen-VRF \ + --verification-key-file ${GENESISDIR}/node${N}/vrf.vkey \ + --signing-key-file ${GENESISDIR}/node${N}/vrf.skey + ${CLICMD} shelley node key-gen \ + --cold-verification-key-file ${GENESISDIR}/node${N}/cold/operator.vkey \ + --cold-signing-key-file ${GENESISDIR}/node${N}/cold/operator.skey \ + --operational-certificate-issue-counter-file ${GENESISDIR}/node${N}/cold/operator.counter + else ## BFT node + ln -s ../../delegate-keys/delegate${N}.skey ${GENESISDIR}/node${N}/cold/operator.skey + ln -s ../../delegate-keys/delegate${N}.vkey ${GENESISDIR}/node${N}/cold/operator.vkey + ln -s ../../delegate-keys/delegate${N}.counter ${GENESISDIR}/node${N}/cold/operator.counter + ln -s ../delegate-keys/delegate${N}.vrf.skey ${GENESISDIR}/node${N}/vrf.skey + ln -s ../delegate-keys/delegate${N}.vrf.vkey ${GENESISDIR}/node${N}/vrf.vkey + fi + + # certificate (adapt kes-period for later certs) + ${CLICMD} shelley node issue-op-cert \ + --hot-kes-verification-key-file ${GENESISDIR}/node${N}/kes.vkey \ + --cold-signing-key-file ${GENESISDIR}/node${N}/cold/operator.skey \ + --operational-certificate-issue-counter ${GENESISDIR}/node${N}/cold/operator.counter \ + --kes-period 0 \ + --out-file ${GENESISDIR}/node${N}/node.cert +done + +# === delegation === + +## prepare addresses +mkdir -p ${GENESISDIR}/addresses + +USER_ADDRS=$(for N in $STAKEPOOLS; do echo -n "user${N} "; done) +POOL_ADDRS=$(for N in $STAKEPOOLS; do echo -n "pool-owner${N} "; done) + +ADDRS="${USER_ADDRS} ${POOL_ADDRS}" +for ADDR in ${ADDRS}; do + + echo -n "$ADDR " + ### Payment address keys + ${CLICMD} shelley address key-gen \ + --verification-key-file ${GENESISDIR}/addresses/${ADDR}.vkey \ + --signing-key-file ${GENESISDIR}/addresses/${ADDR}.skey + + ### Stake address keys + ${CLICMD} shelley stake-address key-gen \ + --verification-key-file ${GENESISDIR}/addresses/${ADDR}-stake.vkey \ + --signing-key-file ${GENESISDIR}/addresses/${ADDR}-stake.skey + + ### Payment addresses + ${CLICMD} shelley address build \ + --payment-verification-key-file ${GENESISDIR}/addresses/${ADDR}.vkey \ + --stake-verification-key-file ${GENESISDIR}/addresses/${ADDR}-stake.vkey \ + --testnet-magic ${MAGIC} \ + --out-file ${GENESISDIR}/addresses/${ADDR}.addr + + ### Stake addresses + ${CLICMD} shelley stake-address build \ + --stake-verification-key-file ${GENESISDIR}/addresses/${ADDR}-stake.vkey \ + --testnet-magic ${MAGIC} \ + --out-file ${GENESISDIR}/addresses/${ADDR}-stake.addr + + ### Stake addresses registration certs + ${CLICMD} shelley stake-address registration-certificate \ + --stake-verification-key-file ${GENESISDIR}/addresses/${ADDR}-stake.vkey \ + --out-file ${GENESISDIR}/addresses/${ADDR}-stake.reg.cert + +done +echo + +## create delegation certs + +for N in ${STAKEPOOLS}; do + echo -n "user ${N} -> pool ${N} " + ### Stake address delegation certs + ${CLICMD} shelley stake-address delegation-certificate \ + --stake-verification-key-file ${GENESISDIR}/addresses/user${N}-stake.vkey \ + --cold-verification-key-file ${GENESISDIR}/node${N}/cold/operator.vkey \ + --out-file ${GENESISDIR}/addresses/user${N}-stake.deleg.cert + + ln -s ../addresses/pool-owner${N}-stake.vkey ${GENESISDIR}/node${N}/owner.vkey + ln -s ../addresses/pool-owner${N}-stake.skey ${GENESISDIR}/node${N}/owner.skey + +done +echo + +## make stake pool registration cert + +for NODE in ${STAKEPOOLS}; do + echo -n "pool ${NODE} " + ${CLICMD} shelley stake-pool registration-certificate \ + --testnet-magic ${MAGIC} \ + --pool-pledge 0 --pool-cost 0 --pool-margin 0 \ + --cold-verification-key-file ${GENESISDIR}/node${NODE}/cold/operator.vkey \ + --vrf-verification-key-file ${GENESISDIR}/node${NODE}/vrf.vkey \ + --reward-account-verification-key-file ${GENESISDIR}/node${NODE}/owner.vkey \ + --pool-owner-stake-verification-key-file ${GENESISDIR}/node${NODE}/owner.vkey \ + --out-file ${GENESISDIR}/node${NODE}/registration.cert +done +echo + +## prepare delegation transaction + +STAKE=$((SUPPLY / NNODES)) +for N in ${STAKEPOOLS}; do + + echo "move funds to user ${N}, delegate to pool ${N}" + ### build tx + ${CLICMD} shelley transaction build-raw \ + --ttl 1000 \ + --fee 0 \ + --tx-in $(${CLICMD} shelley genesis initial-txin \ + --testnet-magic ${MAGIC} \ + --verification-key-file ${GENESISDIR}/utxo-keys/utxo${N}.vkey) \ + --tx-out $(cat ${GENESISDIR}/addresses/user${N}.addr)+${STAKE} \ + --certificate-file ${GENESISDIR}/addresses/pool-owner${N}-stake.reg.cert \ + --certificate-file ${GENESISDIR}/node${N}/registration.cert \ + --certificate-file ${GENESISDIR}/addresses/user${N}-stake.reg.cert \ + --certificate-file ${GENESISDIR}/addresses/user${N}-stake.deleg.cert \ + --out-file ${GENESISDIR}/node${N}/tx-delegate${N}.txbody + + ### sign tx + ${CLICMD} shelley transaction sign \ + --signing-key-file ${GENESISDIR}/utxo-keys/utxo${N}.skey \ + --signing-key-file ${GENESISDIR}/addresses/user${N}-stake.skey \ + --signing-key-file ${GENESISDIR}/node${N}/owner.skey \ + --signing-key-file ${GENESISDIR}/node${N}/cold/operator.skey \ + --testnet-magic ${MAGIC} \ + --tx-body-file ${GENESISDIR}/node${N}/tx-delegate${N}.txbody \ + --out-file ${GENESISDIR}/node${N}/tx-delegate${N}.tx + +done +echo diff --git a/benchmarks/shelley3pools/run-Npools.sh b/benchmarks/shelley3pools/run-Npools.sh new file mode 100755 index 00000000..58f9b7df --- /dev/null +++ b/benchmarks/shelley3pools/run-Npools.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +. ./configuration/parameters +NODECMD="../../bin/cardano-node" + +# the host address and interface the node listens: +HOSTADDR=127.0.0.1 + +# the nodes will listen on ports starting with: +PORTBASE=3000 + +GENESISDIR=configuration/genesis + +# redirect stderr if LiveView active +REDIRSTDERR="2>/dev/null" +REDIRSTDERR= + +TMUX_ENV_PASSTHROUGH=( + "export SCRIPTS_LIB_SH_MODE=${SCRIPTS_LIB_SH_MODE};" + "export __COMMON_SRCROOT=${__COMMON_SRCROOT};" + "export DEFAULT_DEBUG=${DEFAULT_DEBUG};" + "export DEFAULT_VERBOSE=${DEFAULT_VERBOSE};" + "export DEFAULT_TRACE=${DEFAULT_TRACE}" + "$(nix_cache_passthrough)" +) +tmux split-window -v +tmux split-window -h +tmux select-pane -t 0 +tmux split-window -h + +for N in $(seq 1 ${NNODES}) +do tmux select-pane -t $((N - 1)) + tmux send-keys \ + "${TMUX_ENV_PASSTHROUGH[*]} + + cd '${BASEDIR}'; + . ${__COMMON_SRCROOT}/scripts/lib.sh; + . ${__COMMON_SRCROOT}/scripts/lib-cli.sh; + . ${__COMMON_SRCROOT}/scripts/lib-node.sh; + + ${NODECMD} run \ + --topology configuration/topology-node-${N}.json \ + --database-path db/${N} \ + --socket-path logs/sockets/${N} \ + --host-addr ${HOSTADDR} --port $((PORTBASE + N - 1)) \ + --config configuration/configuration-node-${N}.yaml \ + --shelley-kes-key ${GENESISDIR}/node${N}/kes.skey \ + --shelley-vrf-key ${GENESISDIR}/node${N}/vrf.skey \ + --shelley-operational-certificate ${GENESISDIR}/node${N}/node.cert \ + " ${REDIRSTDERR} \ + C-m +done +tmux select-pane -t 0 diff --git a/benchmarks/shelley3pools/setup-benchmarking.sh b/benchmarks/shelley3pools/setup-benchmarking.sh new file mode 100755 index 00000000..4a073640 --- /dev/null +++ b/benchmarks/shelley3pools/setup-benchmarking.sh @@ -0,0 +1,14 @@ +# Create topology files for NNODES +./topology-generator.sh +wait + +# Create configuration files for NNODES +./configuration-generator.sh +wait + +# Create Genesis based on parameters +./prepare_genesis-generic.sh +wait + +# Run the nodes +./start-generic.sh diff --git a/benchmarks/shelley3pools/start-generic.sh b/benchmarks/shelley3pools/start-generic.sh new file mode 100755 index 00000000..5d0fae10 --- /dev/null +++ b/benchmarks/shelley3pools/start-generic.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +# this benchmark runs in 'tmux' which provides several windows and panes +# to arrange the nodes and the transaction generator. + +# add to your ~/.tmux.conf: +# set-window-option -g mouse on +# set -g default-terminal "tmux-256color" + +tmux new-s -E -s Shelley3Pools -n Main "./benchmark-generic.sh $*; $SHELL" + diff --git a/benchmarks/shelley3pools/topology-generator.sh b/benchmarks/shelley3pools/topology-generator.sh new file mode 100755 index 00000000..39214dc0 --- /dev/null +++ b/benchmarks/shelley3pools/topology-generator.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +: <<'END_COMMENT' +Example 3-node topology file: + +{ + "Producers": [ + { + "addr": "127.0.0.1", + "port": 3000, + "valency": 1 + }, + { + "addr": "127.0.0.1", + "port": 3001, + "valency": 1 + }, + { + "addr": "127.0.0.1", + "port": 3003, + "valency": 1 + } + ] +} +END_COMMENT + +. ./configuration/parameters + +NNODES=${NNODES:-3} + +for current_port in $(seq 3000 $(( 3000 + NNODES - 1 ))) +do + echo $(echo ' +{ + "Producers": [' + + i="0" + while [ $i -le $(( NNODES - 1 )) ] + do + port=$(( 3000 + $i )) + + if [ $port -ne $current_port ]; then + + echo " + { + \"addr\": \"127.0.0.1\", + \"port\": ${port}, + \"valency\": 1 + }," + fi + + i=$(($i+1)) + done + + echo ' + ] +} +') | sed -zr 's/,([^,]*$)/\1/' > ./configuration/topology-node-$((current_port-3000+1)).json +done