Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
🛠 reorganize config files
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Oct 19, 2020
1 parent 49352a6 commit 5c82464
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 72 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-global
- run: VECTOR_PROD=true bash ops/test-integration.sh global
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-global
- run: bash ops/test-integration.sh global
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 global_auth
Expand All @@ -147,8 +148,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-node
- run: VECTOR_PROD=true bash ops/test-integration.sh node
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-node
- run: bash ops/test-integration.sh node
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 node_node
Expand All @@ -159,8 +161,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-router
- run: VECTOR_PROD=true bash ops/test-integration.sh router
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-router
- run: bash ops/test-integration.sh router
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 node_node
15 changes: 9 additions & 6 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-global
- run: VECTOR_PROD=true bash ops/test-integration.sh global
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-global
- run: bash ops/test-integration.sh global
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 global_auth
Expand All @@ -157,8 +158,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-node
- run: VECTOR_PROD=true bash ops/test-integration.sh node
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-node
- run: bash ops/test-integration.sh node
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 node_node
Expand All @@ -169,8 +171,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- run: make pull
- run: VECTOR_PROD=true make restart-router
- run: VECTOR_PROD=true bash ops/test-integration.sh router
- run: jq '.production = true' ops/config/global.default.json > global.config.json
- run: make restart-router
- run: bash ops/test-integration.sh router
- name: Print logs
if: failure()
run: docker service ls && docker service logs --tail 200 node_node
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Config & sensitive data
*.config.json

# Build Output
**/*.0x
**/.flags
Expand Down
5 changes: 5 additions & 0 deletions ops/config/global.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"adminToken": "cxt1234",
"domainName": "",
"production": false
}
25 changes: 25 additions & 0 deletions ops/config/node.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"adminToken": "cxt1234",
"chainAddresses": {
"1337": {
"channelFactoryAddress": "0xF12b5dd4EAD5F743C6BaA640B0216200e89B60Da",
"channelMastercopyAddress": "0x8CdaF0CD259887258Bc13a92C0a6dA92698644C0",
"transferRegistryAddress": "0x345cA3e014Aaf5dcA488057592ee47305D9B3e10",
"TestToken": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F"
},
"1338": {
"channelFactoryAddress": "0xF12b5dd4EAD5F743C6BaA640B0216200e89B60Da",
"channelMastercopyAddress": "0x8CdaF0CD259887258Bc13a92C0a6dA92698644C0",
"transferRegistryAddress": "0x345cA3e014Aaf5dcA488057592ee47305D9B3e10",
"TestToken": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F"
}
},
"chainProviders": {
"1337": "http://evm_1337:8545",
"1338": "http://evm_1338:8545"
},
"domainName": "",
"logLevel": "info",
"messagingUrl": "",
"production": false
}
53 changes: 53 additions & 0 deletions ops/config/router.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"allowedSwaps": [
{
"fromChainId": 1337,
"toChainId": 1338,
"fromAssetId": "0x0000000000000000000000000000000000000000",
"toAssetId": "0x0000000000000000000000000000000000000000",
"priceType": "hardcoded",
"hardcodedRate": "1"
},
{
"fromChainId": 1337,
"toChainId": 1338,
"fromAssetId": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F",
"toAssetId": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F",
"priceType": "hardcoded",
"hardcodedRate": "1"
}
],
"domainName": "",
"messagingUrl": "",
"production": false,
"rebalanceProfiles": [
{
"chainId": 1337,
"assetId": "0x0000000000000000000000000000000000000000",
"reclaimThreshold": "200000000000000000",
"target": "100000000000000000",
"collateralizeThreshold": "50000000000000000"
},
{
"chainId": 1338,
"assetId": "0x0000000000000000000000000000000000000000",
"reclaimThreshold": "200000000000000000",
"target": "100000000000000000",
"collateralizeThreshold": "50000000000000000"
},
{
"chainId": 1337,
"assetId": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F",
"reclaimThreshold": "2000000000000000000",
"target": "1000000000000000000",
"collateralizeThreshold": "500000000000000000"
},
{
"chainId": 1338,
"assetId": "0x8f0483125FCb9aaAEFA9209D8E9d7b9C8B9Fb90F",
"reclaimThreshold": "2000000000000000000",
"target": "1000000000000000000",
"collateralizeThreshold": "500000000000000000"
}
]
}
3 changes: 1 addition & 2 deletions ops/start-duet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
####################
# Misc Config

config="$(cat "$root/config-node.json")"
config="$(cat "$root/ops/config/node.default.json")"

version="latest"

Expand All @@ -33,7 +33,6 @@ common="networks:
# Global services / chain provider config

bash "$root/ops/start-global.sh"

chain_addresses="$(cat "$root/.chaindata/chain-addresses.json")"
config="$(echo "$config" '{"chainAddresses":'"$chain_addresses"'}' | jq -s '.[0] + .[1]')"

Expand Down
46 changes: 28 additions & 18 deletions ops/start-global.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,39 @@ fi
####################
# Load config

config="$(
cat "$root/config-node.json" "$root/config-router.json" "$root/config-prod.json" |\
jq -s '.[0] + .[1] + .[2]'
)"
if [[ ! -f "$root/${stack}.config.json" ]]
then cp "$root/ops/config/${stack}.default.json" "$root/${stack}.config.json"
fi

config=$(cat "$root/ops/config/$stack.default.json" "$root/$stack.config.json" | jq -s '.[0] + .[1]')

function getConfig {
value="$(echo "$config" | jq ".$1" | tr -d '"')"
value=$(echo "$config" | jq ".$1" | tr -d '"')
if [[ "$value" == "null" ]]
then echo ""
else echo "$value"
fi
}

admin_token="$(getConfig adminToken)"
domain_name="$(getConfig domainName)"
production="$(getConfig production)"
public_port="$(getConfig port)"

chain_providers="$(echo "$config" | jq '.chainProviders' | tr -d '\n\r ')"
default_providers="$(jq '.chainProviders' "$root/config-node.json" | tr -d '\n\r ')"
admin_token=$(getConfig adminToken)
domain_name=$(getConfig domainName)
production=$(getConfig production)
public_port=$(getConfig port)

if [[ "$VECTOR_PROD" = "true" ]]
then production="true"
# Should we spin up local evms or use external ones?
node_config=$root/node.config.json
if [[ -f "$node_config" ]]
then
given_providers=$(echo "$node_config" | jq '.chainProviders' | tr -d '\n\r ')
default_providers=$(jq '.chainProviders' "$root/ops/config/node.default.json" | tr -d '\n\r ')
if [[ "$default_providers" != "$given_providers" ]]
then use_local_evms="true";
else
echo "Node config contains custom ethproviders, using those instead of spinning up local evms"
echo "External ethproviders: $given_providers"
use_local_evms="false";
fi
else use_local_evms="true";
fi

########################################
Expand All @@ -50,8 +60,8 @@ fi
if [[ "$production" == "true" ]]
then
if [[ -n "$(git tag --points-at HEAD | grep "vector-" | head -n 1)" ]]
then version="$(grep -m 1 '"version":' package.json | cut -d '"' -f 4)"
else version="$(git rev-parse HEAD | head -c 8)"
then version=$(grep -m 1 '"version":' package.json | cut -d '"' -f 4)
else version=$(git rev-parse HEAD | head -c 8)
fi
else version="latest"
fi
Expand Down Expand Up @@ -130,7 +140,7 @@ fi
####################
# Eth Provider config

if [[ "$chain_providers" == "$default_providers" ]]
if [[ "$use_local_evms" == "true" ]]
then
mnemonic="candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"

Expand Down Expand Up @@ -292,7 +302,7 @@ do
fi
done

if [[ "$chain_providers" == "$default_providers" ]]
if [[ "$use_local_evms" == "true" ]]
then
chain_addresses_1="$chain_data_1/chain-addresses.json"
chain_addresses_2="$chain_data_2/chain-addresses.json"
Expand Down
46 changes: 26 additions & 20 deletions ops/start-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ fi
####################
# Load config

node_config="$(cat "$root/config-node.json")"
prod_config="$(cat "$root/config-prod.json")"
config="$(echo "$node_config" "$prod_config" | jq -s '.[0] + .[1]')"
if [[ ! -f "$root/${stack}.config.json" ]]
then cp "$root/ops/config/${stack}.default.json" "$root/${stack}.config.json"
fi

config=$(cat "$root/ops/config/$stack.default.json" "$root/$stack.config.json" | jq -s '.[0] + .[1]')

function getConfig {
value="$(echo "$config" | jq ".$1" | tr -d '"')"
Expand All @@ -30,20 +32,20 @@ function getConfig {
fi
}

admin_token="$(getConfig adminToken)"
messaging_url="$(getConfig messagingUrl)"
aws_access_id="$(getConfig awsAccessId)"
aws_access_key="$(getConfig awsAccessKey)"
domain_name="$(getConfig domainName)"
production="$(getConfig production)"
public_port="$(getConfig port)"
mnemonic="$(getConfig mnemonic)"

chain_providers="$(echo "$config" | jq '.chainProviders' | tr -d '\n\r ')"
default_providers="$(jq '.chainProviders' "$root/config-node.json" | tr -d '\n\r ')"

if [[ "$VECTOR_PROD" = "true" ]]
then production="true"
admin_token=$(getConfig adminToken)
messaging_url=$(getConfig messagingUrl)
aws_access_id=$(getConfig awsAccessId)
aws_access_key=$(getConfig awsAccessKey)
domain_name=$(getConfig domainName)
production=$(getConfig production)
public_port=$(getConfig port)
mnemonic=$(getConfig mnemonic)

chain_providers=$(echo "$config" | jq '.chainProviders' | tr -d '\n\r ')
default_providers=$(jq '.chainProviders' "$root/ops/config/node.default.json" | tr -d '\n\r ')
if [[ "$chain_providers" == "$default_providers" ]]
then use_local_evms=true
else use_local_evms=false
fi

####################
Expand Down Expand Up @@ -74,11 +76,15 @@ common="networks:

########################################
# Global services / chain provider config
# If no global service urls provided, spin up local ones & use those

if [[ -z "$messaging_url" || "$chain_providers" == "$default_providers" ]]
# If no messaging url or custom ethproviders are given, spin up a global stack
if [[ -z "$messaging_url" || "$use_local_evms" == "true" ]]
then bash "$root/ops/start-global.sh"
fi

# If no custom ethproviders are given, configure mnemonic/addresses from local evms
if [[ "$use_local_evms" == "true" ]]
then
bash "$root/ops/start-global.sh"
mnemonic_secret=""
eth_mnemonic="${mnemonic:-candy maple cake sugar pudding cream honey rich smooth crumble sweet treat}"
eth_mnemonic_file=""
Expand Down
Loading

0 comments on commit 5c82464

Please sign in to comment.