Skip to content

Commit

Permalink
Start deposit-monitor during upgrade-test.
Browse files Browse the repository at this point in the history
This change is supported by moving the start code for
the deposit-monitor to its own file.
  • Loading branch information
MxmUrw committed Nov 13, 2024
1 parent d17e621 commit 92fd496
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 33 deletions.
29 changes: 17 additions & 12 deletions bouncer/shared/upgrade_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { compileBinaries } from './utils/compile_binaries';
import { submitRuntimeUpgradeWithRestrictions } from './submit_runtime_upgrade';
import { execWithLog } from './utils/exec_with_log';
import { submitGovernanceExtrinsic } from './cf_governance';
import { setupLpAccount } from './setup_lp_account';

async function readPackageTomlVersion(projectRoot: string): Promise<string> {
const data = await fs.readFile(path.join(projectRoot, '/state-chain/runtime/Cargo.toml'), 'utf8');
Expand Down Expand Up @@ -339,17 +338,23 @@ export async function upgradeNetworkPrebuilt(
);
}

// Temp: until localnet/bouncer initialises to a version where the LP_API is funded already.
if (cleanOldVersion.startsWith('1.6')) {
console.log('Setting up LP account and adding liquidity for the LP-API.');
// Liquidity is provided as part of the LP-API test setup.
await setupLpAccount('//LP_API');
// Write LP_API key to keys/ so that the LP-API can use it - when upgrading the old version, which the upgrade-test is
// started from doesn't yet have this key.
await fs.writeFile(
`${localnetInitPath}/keys/LP_API`,
'8e1866e65039304e4142f09452a8305acd28d0ae0b833cd268b21a57d68782c1',
);
// Temp: until localnet/bouncer initialises to a version where the deposit-monitor is started already.
if (cleanOldVersion.startsWith('1.7')) {
console.log('Starting up deposit-monitor.');

execWithLog(`${localnetInitPath}/scripts/start-broker-api.sh`, 'start-broker-api', {
DEPOSIT_MONITOR_CONTAINER: 'deposit-monitor',
DOCKER_COMPOSE_CMD: 'docker-compose',
additional_docker_compose_up_args: '--quiet-pull',
});

try {
const pid = execSync(`lsof -t -i:6060`);
console.log(`New deposit-monitor PID: ${pid.toString()}`);
} catch (e) {
console.error(`Error starting deposit-monitor: ${e}`);
throw e;
}
}

if (cleanOldVersion === nodeVersion) {
Expand Down
27 changes: 6 additions & 21 deletions localnet/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export GENESIS_NODES=("bashful" "doc" "dopey")
export REQUIRED_BINARIES="engine-runner chainflip-node chainflip-broker-api chainflip-lp-api"
export INIT_CONTAINERS="eth-init solana-init"
export CORE_CONTAINERS="bitcoin geth polkadot redis"
export CF_CONTAINERS="deposit-monitor"
export DEPOSIT_MONITOR_CONTAINER="deposit-monitor"
export ARB_CONTAINERS="sequencer staker-unsafe poster"
export SOLANA_BASE_PATH="/tmp/solana"
export CHAINFLIP_BASE_PATH="/tmp/chainflip"
Expand Down Expand Up @@ -173,26 +173,11 @@ build-localnet() {
echo "🤑 Starting LP API ..."
KEYS_DIR=$KEYS_DIR ./$LOCALNET_INIT_DIR/scripts/start-lp-api.sh $BINARY_ROOT_PATH

echo "🔬 Starting Deposit Monitor API ..."
# On some machines (e.g. MacOS), 172.17.0.1 is not accessible from inside the container, so we need to use host.docker.internal
if [[ $CI == true ]]; then
export CFDM_BROKER_API_URL='ws://172.17.0.1:10997'
else
export CFDM_BROKER_API_URL='ws://host.docker.internal:10997'
fi
$DOCKER_COMPOSE_CMD -f localnet/docker-compose.yml -p "chainflip-localnet" up $CF_CONTAINERS $additional_docker_compose_up_args -d >>$DEBUG_OUTPUT_DESTINATION 2>&1
while true; do
echo "🩺 Checking deposit-monitor's health ..."
REPLY=$(check_endpoint_health 'http://localhost:6060/health')
starting=$(echo $REPLY | jq .starting)
all_healthy=$(echo $REPLY | jq .all_processors)
if test "$starting" == "false" && test "$all_healthy" == "true" ; then
echo "💚 deposit-monitor is running!"
break
fi
sleep 1
done

echo "🔬 Starting Deposit Monitor ..."
DOCKER_COMPOSE_CMD=$DOCKER_COMPOSE_CMD \
DEPOSIT_MONITOR_CONTAINER=$DEPOSIT_MONITOR_CONTAINER \
additional_docker_compose_up_args=$additional_docker_compose_up_args \
./$LOCALNET_INIT_DIR/scripts/start-deposit-monitor.sh

if [[ $START_TRACKER == "y" ]]; then
echo "👁 Starting Ingress-Egress-tracker ..."
Expand Down
23 changes: 23 additions & 0 deletions localnet/init/scripts/start-deposit-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

source ./localnet/helper.sh

# On some machines (e.g. MacOS), 172.17.0.1 is not accessible from inside the container, so we need to use host.docker.internal
if [[ $CI == true ]]; then
export CFDM_BROKER_API_URL='ws://172.17.0.1:10997'
else
export CFDM_BROKER_API_URL='ws://host.docker.internal:10997'
fi
$DOCKER_COMPOSE_CMD -f localnet/docker-compose.yml -p "chainflip-localnet" up $DEPOSIT_MONITOR_CONTAINER $additional_docker_compose_up_args -d >>$DEBUG_OUTPUT_DESTINATION 2>&1
while true; do
echo "🩺 Checking deposit-monitor's health ..."
REPLY=$(check_endpoint_health 'http://localhost:6060/health')
starting=$(echo $REPLY | jq .starting)
all_healthy=$(echo $REPLY | jq .all_processors)
if test "$starting" == "false" && test "$all_healthy" == "true" ; then
echo "💚 deposit-monitor is running!"
break
fi
sleep 1
done

0 comments on commit 92fd496

Please sign in to comment.