storage-playground-config.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. # Basic script to be run to configure dev chain storage infrastructure.
  6. # Assumes one storage lead and distributor lead are already hired
  7. # and their identity information are stored in .env
  8. # Load the worker ids and SURIs as local variables only
  9. . .env
  10. HOST_IP=$(tests/network-tests/get-host-ip.sh)
  11. ## Colossus 1
  12. CLI=storage-node-v2/bin/run
  13. ${CLI} leader:update-bag-limit -l 10 --accountUri ${COLOSSUS_1_ACCOUNT_URI}
  14. ${CLI} leader:update-voucher-limits -o 10000 -s 1000000000000 --accountUri ${COLOSSUS_1_ACCOUNT_URI}
  15. BUCKET_ID=`${CLI} leader:create-bucket -i=${COLOSSUS_1_WORKER_ID} -a -n=10000 -s=1000000000000 --accountUri ${COLOSSUS_1_ACCOUNT_URI}`
  16. ${CLI} operator:accept-invitation -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} --accountUri ${COLOSSUS_1_ACCOUNT_URI}
  17. ${CLI} leader:update-dynamic-bag-policy -n 1 -t Channel --accountUri ${COLOSSUS_1_ACCOUNT_URI}
  18. ${CLI} leader:update-data-fee -f 10 --accountUri ${COLOSSUS_1_ACCOUNT_URI} # Optionally - set some data fee per megabyte
  19. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  20. # In production it would most likely be the reverse proxy endpoint. If not specified we
  21. # set it to the host machine address.
  22. COLOSSUS_1_NODE_URI=${COLOSSUS_1_NODE_URI:="http://${HOST_IP}:3333"}
  23. ${CLI} operator:set-metadata -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -e="${COLOSSUS_1_NODE_URI}" --accountUri ${COLOSSUS_1_ACCOUNT_URI}
  24. echo "Colossus 1 BUCKET_ID=${BUCKET_ID}"
  25. ## Distributor 1
  26. export AUTO_CONFIRM=true
  27. export CONFIG_PATH=$(pwd)/distributor-node/config.yml
  28. export JOYSTREAM_DISTRIBUTOR__KEYS="[{\"suri\":\"${DISTRIBUTOR_1_ACCOUNT_URI}\"}]"
  29. CLI=distributor-node/bin/run
  30. ${CLI} leader:set-buckets-per-bag-limit -l 10
  31. FAMILY_ID=`${CLI} leader:create-bucket-family`
  32. BUCKET_INDEX=`${CLI} leader:create-bucket -f ${FAMILY_ID} -a yes`
  33. BUCKET_ID="${FAMILY_ID}:${BUCKET_INDEX}"
  34. ${CLI} leader:update-bucket-mode -B ${BUCKET_ID} --mode on
  35. ${CLI} leader:update-dynamic-bag-policy -t Channel -p ${FAMILY_ID}:5
  36. ${CLI} leader:invite-bucket-operator -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  37. ${CLI} operator:accept-invitation -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  38. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  39. # In production it would most likely be the reverse proxy endpoint. If not specified we
  40. # set it to the host machine address.
  41. DISTRIBUTOR_1_NODE_URI=${DISTRIBUTOR_1_NODE_URI:="http://${HOST_IP}:3334"}
  42. ${CLI} operator:set-metadata -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID} -e="${DISTRIBUTOR_1_NODE_URI}"
  43. echo "Distributor 1 BUCKET_ID=${BUCKET_ID}"