storage-playground-config.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. ${CLI} leader:update-bag-limit -l 10 --accountUri ${COLOSSUS_1_WORKER_URI}
  15. ${CLI} leader:update-voucher-limits -o 10000 -s 1000000000000 --accountUri ${COLOSSUS_1_WORKER_URI}
  16. BUCKET_ID=`${CLI} leader:create-bucket -i=${COLOSSUS_1_WORKER_ID} -a -n=10000 -s=1000000000000 --accountUri ${COLOSSUS_1_WORKER_URI}`
  17. ${CLI} operator:accept-invitation -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -t=${TRANSACTOR_KEY} --accountUri ${COLOSSUS_1_WORKER_URI}
  18. ${CLI} leader:update-dynamic-bag-policy -n 1 -t Channel --accountUri ${COLOSSUS_1_WORKER_URI}
  19. ${CLI} leader:update-data-fee -f 0 --accountUri ${COLOSSUS_1_WORKER_URI} # Optionally - set some data fee per megabyte
  20. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  21. # In production it would most likely be the reverse proxy endpoint. If not specified we
  22. # set it to the host machine address.
  23. COLOSSUS_1_NODE_URI=${COLOSSUS_1_NODE_URI:="http://${HOST_IP}:3333"}
  24. ${CLI} operator:set-metadata -w=${COLOSSUS_1_WORKER_ID} -i=${BUCKET_ID} -e="${COLOSSUS_1_NODE_URI}" --accountUri ${COLOSSUS_1_WORKER_URI}
  25. echo "Colossus 1 BUCKET_ID=${BUCKET_ID}"
  26. ## Distributor 1
  27. export AUTO_CONFIRM=true
  28. export CONFIG_PATH=$(pwd)/distributor-node/config.yml
  29. export JOYSTREAM_DISTRIBUTOR__KEYS="[{\"suri\":\"${DISTRIBUTOR_1_ACCOUNT_URI}\"}]"
  30. CLI=distributor-node/bin/run
  31. ${CLI} leader:set-buckets-per-bag-limit -l 10
  32. FAMILY_ID=`${CLI} leader:create-bucket-family`
  33. BUCKET_INDEX=`${CLI} leader:create-bucket -f ${FAMILY_ID} -a yes`
  34. BUCKET_ID="${FAMILY_ID}:${BUCKET_INDEX}"
  35. ${CLI} leader:update-bucket-mode -B ${BUCKET_ID} --mode on
  36. ${CLI} leader:update-dynamic-bag-policy -t Channel -p ${FAMILY_ID}:5
  37. ${CLI} leader:invite-bucket-operator -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  38. ${CLI} operator:accept-invitation -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID}
  39. # The node uri should be an accessible endpoint from within a container as well as the host machine.
  40. # In production it would most likely be the reverse proxy endpoint. If not specified we
  41. # set it to the host machine address.
  42. DISTRIBUTOR_1_NODE_URI=${DISTRIBUTOR_1_NODE_URI:="http://${HOST_IP}:3334"}
  43. ${CLI} operator:set-metadata -B ${BUCKET_ID} -w ${DISTRIBUTOR_1_WORKER_ID} -e="${DISTRIBUTOR_1_NODE_URI}"
  44. echo "Distributor 1 BUCKET_ID=${BUCKET_ID}"