Skip to content

Commit

Permalink
Use correct version of hydra-node for script publishing (#1625)
Browse files Browse the repository at this point in the history
This fixes the network tests by using the repo-version of hydra-node
(i.e. the same one as the docker images that are run eventually, via the
docker-compose-netem.yaml file.)
  • Loading branch information
ch1bo authored Sep 12, 2024
2 parents 6c30e32 + 67ef048 commit 65f75a5
Showing 4 changed files with 51 additions and 75 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/network-test.yaml
Original file line number Diff line number Diff line change
@@ -67,7 +67,20 @@ jobs:
sleep 5
# :tear: socket permissions.
sudo chown runner:docker devnet/node.socket
./export-tx-id-and-pparams.sh
HYDRA_SCRIPTS_TX_ID=$(nix run .#hydra-node -- publish-scripts \
--testnet-magic 42 \
--node-socket devnet/node.socket \
--cardano-signing-key devnet/credentials/faucet.sk)
echo $HYDRA_SCRIPTS_TX_ID >> .env
nix run .#cardano-cli query protocol-parameters \
--socket-path devnet/node.socket \
--out-file /dev/stdout \
| jq ".txFeeFixed = 0 | .txFeePerByte = 0 | .executionUnitPrices.priceMemory = 0 | .executionUnitPrices.priceSteps = 0" \
> devnet/protocol-parameters.json
# Specify two docker compose yamls; the second one overrides the
# images to use the netem ones specifically
docker compose -f docker-compose.yaml -f docker-compose-netem.yaml up -d hydra-node-{1,2,3}
71 changes: 0 additions & 71 deletions demo/export-tx-id-and-pparams.sh

This file was deleted.

38 changes: 36 additions & 2 deletions demo/seed-devnet.sh
Original file line number Diff line number Diff line change
@@ -43,6 +43,18 @@ function ccli_() {
fi
}

# Invoke hydra-node in a container or via provided executable
function hnode() {
if [[ -n ${HYDRA_NODE_CMD} ]]; then
${HYDRA_NODE_CMD} ${@}
else
docker run --rm -it \
--pull always \
-v ${SCRIPT_DIR}/devnet:/devnet \
ghcr.io/cardano-scaling/hydra-node:0.18.1 -- ${@}
fi
}

# Retrieve some lovelace from faucet
function seedFaucet() {
ACTOR=${1}
@@ -77,6 +89,26 @@ function seedFaucet() {
echo >&2 "Done"
}

function publishReferenceScripts() {
echo >&2 "Publishing reference scripts..."
hnode publish-scripts \
--testnet-magic ${NETWORK_ID} \
--node-socket ${DEVNET_DIR}/node.socket \
--cardano-signing-key devnet/credentials/faucet.sk
}

function queryPParams() {
echo >&2 "Query Protocol parameters"
if [[ -x ${CCLI_CMD} ]]; then
ccli query protocol-parameters --socket-path ${DEVNET_DIR}/node.socket --out-file /dev/stdout \
| jq ".txFeeFixed = 0 | .txFeePerByte = 0 | .executionUnitPrices.priceMemory = 0 | .executionUnitPrices.priceSteps = 0" > devnet/protocol-parameters.json
else
docker exec demo-cardano-node-1 cardano-cli query protocol-parameters --testnet-magic ${NETWORK_ID} --socket-path ${DEVNET_DIR}/node.socket --out-file /dev/stdout \
| jq ".txFeeFixed = 0 | .txFeePerByte = 0 | .executionUnitPrices.priceMemory = 0 | .executionUnitPrices.priceSteps = 0" > devnet/protocol-parameters.json
fi
echo >&2 "Saved in protocol-parameters.json"
}

echo >&2 "Fueling up hydra nodes of alice, bob and carol..."
seedFaucet "alice" 30000000 # 30 Ada to the node
seedFaucet "bob" 30000000 # 30 Ada to the node
@@ -85,5 +117,7 @@ echo >&2 "Distributing funds to alice, bob and carol..."
seedFaucet "alice-funds" 100000000 # 100 Ada to commit
seedFaucet "bob-funds" 50000000 # 50 Ada to commit
seedFaucet "carol-funds" 25000000 # 25 Ada to commit

./export-tx-id-and-pparams.sh
queryPParams
echo "HYDRA_SCRIPTS_TX_ID=$(publishReferenceScripts)" > .env
echo >&2 "Environment variable stored in '.env'"
echo >&2 -e "\n\t$(cat .env)\n"
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@
x.components."${y}") [ "benchmarks" "exes" "sublibs" "tests" ]);
in
{
legacyPackages = hsPkgs;
legacyPackages = pkgs // hsPkgs;

packages =
hydraPackages //

0 comments on commit 65f75a5

Please sign in to comment.