storage-playground-config.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/bin/run
  13. TRANSACTOR_KEY=$(docker run --rm --pull=always docker.io/parity/subkey:2.0.1 inspect ${COLOSSUS_1_TRANSACTOR_URI} --output-type json | jq .ss58Address -r)
  14. # Send some funds to TRANSACTOR to cover the acceptPendingDataObjects fees
  15. export AUTO_CONFIRM=true
  16. FUNDS_SOURCE_KEY=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
  17. TRANSACTOR_INITIAL_BALANCE=100000
  18. yarn joystream-cli account:transferTokens --amount ${TRANSACTOR_INITIAL_BALANCE} --from ${FUNDS_SOURCE_KEY} --to ${TRANSACTOR_KEY}
  19. ${CLI} leader:update-bag-limit -l 10 --accountUri ${COLOSSUS_1_WORKER_URI}
  20. ${CLI} leader:update-voucher-limits -o 10000 -s 1000000000000 --accountUri ${COLOSSUS_1_WORKER_URI}
  21. BUCKET_ID=`${CLI} leader:create-bucket -i=${COLOSSUS_1_WORKER_ID} -a -n=10000 -s=1000000000000 --accountUri ${COLOSSUS_1_WORKER_URI}`
  22. ${CLI} operator:accept-invitation -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -t=${TRANSACTOR_KEY} --accountUri ${COLOSSUS_1_WORKER_URI}
  23. ${CLI} leader:update-dynamic-bag-policy -n 1 -t Channel --accountUri ${COLOSSUS_1_WORKER_URI}
  24. ${CLI} leader:update-data-fee -f 0 --accountUri ${COLOSSUS_1_WORKER_URI} # Optionally - set some data fee per megabyte
  25. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  26. # In production it would most likely be the reverse proxy endpoint. If not specified we
  27. # set it to the host machine address.
  28. COLOSSUS_1_NODE_URI=${COLOSSUS_1_NODE_URI:="http://${HOST_IP}:3333"}
  29. ${CLI} operator:set-metadata -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -e="${COLOSSUS_1_NODE_URI}" --accountUri ${COLOSSUS_1_WORKER_URI}
  30. echo "Colossus 1 BUCKET_ID=${BUCKET_ID}"
  31. ## Distributor 1
  32. export AUTO_CONFIRM=true
  33. export CONFIG_PATH=$(pwd)/distributor-node/config.yml
  34. export JOYSTREAM_DISTRIBUTOR__KEYS="[{\"suri\":\"${DISTRIBUTOR_1_ACCOUNT_URI}\"}]"
  35. CLI=distributor-node/bin/run
  36. ${CLI} leader:set-buckets-per-bag-limit -l 10
  37. FAMILY_ID=`${CLI} leader:create-bucket-family`
  38. BUCKET_INDEX=`${CLI} leader:create-bucket -f ${FAMILY_ID} -a yes`
  39. BUCKET_ID="${FAMILY_ID}:${BUCKET_INDEX}"
  40. ${CLI} leader:update-bucket-mode -B ${BUCKET_ID} --mode on
  41. ${CLI} leader:update-dynamic-bag-policy -t Channel -p ${FAMILY_ID}:5
  42. ${CLI} leader:invite-bucket-operator -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  43. ${CLI} operator:accept-invitation -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  44. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  45. # In production it would most likely be the reverse proxy endpoint. If not specified we
  46. # set it to the host machine address.
  47. DISTRIBUTOR_1_NODE_URI=${DISTRIBUTOR_1_NODE_URI:="http://${HOST_IP}:3334"}
  48. ${CLI} operator:set-metadata -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID} -e="${DISTRIBUTOR_1_NODE_URI}"
  49. echo "Distributor 1 BUCKET_ID=${BUCKET_ID}"