@@ -53,6 +53,7 @@ die() {
5353}
5454
5555compose () {
56+ ensure_compose_versions
5657 docker compose -p " ${COMPOSE_PROJECT} " \
5758 --env-file " ${COMPOSE_ENV} " \
5859 -f " ${COMPOSE_FILE} " \
@@ -62,13 +63,44 @@ compose() {
6263compose_with_override () {
6364 local file=" $1 "
6465 shift
66+ ensure_compose_versions
6567 docker compose -p " ${COMPOSE_PROJECT} " \
6668 --env-file " ${COMPOSE_ENV} " \
6769 -f " ${COMPOSE_FILE} " \
6870 -f " ${file} " \
6971 " $@ "
7072}
7173
74+ infer_container_version () {
75+ local container=" $1 "
76+ local fallback=" $2 "
77+ local image
78+ image=" $( docker inspect --format ' {{.Config.Image}}' " ${container} " 2> /dev/null || true) "
79+ if [[ -n " ${image} " && " ${image} " == * :* ]]; then
80+ printf " %s" " ${image##*: } "
81+ return 0
82+ fi
83+ printf " %s" " ${fallback} "
84+ }
85+
86+ ensure_compose_versions () {
87+ : " ${COPROCESSOR_HOST_LISTENER_VERSION:= $(infer_container_version coprocessor-host-listener v0.11.0-1)} "
88+ : " ${COPROCESSOR_GW_LISTENER_VERSION:= $(infer_container_version coprocessor-gw-listener v0.11.0-1)} "
89+ : " ${COPROCESSOR_TFHE_WORKER_VERSION:= $(infer_container_version coprocessor-tfhe-worker v0.11.0-1)} "
90+ : " ${COPROCESSOR_SNS_WORKER_VERSION:= $(infer_container_version coprocessor-sns-worker v0.11.0-1)} "
91+ : " ${COPROCESSOR_TX_SENDER_VERSION:= $(infer_container_version coprocessor-transaction-sender v0.11.0-1)} "
92+ : " ${COPROCESSOR_ZKPROOF_WORKER_VERSION:= $(infer_container_version coprocessor-zkproof-worker v0.11.0-1)} "
93+ : " ${COPROCESSOR_DB_MIGRATION_VERSION:= $(infer_container_version coprocessor-db-migration v0.11.0-1)} "
94+
95+ export COPROCESSOR_HOST_LISTENER_VERSION
96+ export COPROCESSOR_GW_LISTENER_VERSION
97+ export COPROCESSOR_TFHE_WORKER_VERSION
98+ export COPROCESSOR_SNS_WORKER_VERSION
99+ export COPROCESSOR_TX_SENDER_VERSION
100+ export COPROCESSOR_ZKPROOF_WORKER_VERSION
101+ export COPROCESSOR_DB_MIGRATION_VERSION
102+ }
103+
72104db_query () {
73105 local sql=" $1 "
74106 docker exec -i coprocessor-and-kms-db \
@@ -99,7 +131,16 @@ wait_for_bootstrap() {
99131
100132 has_activate_key=" $( docker logs --since=20m coprocessor-gw-listener 2>&1 | rg -c " ActivateKey event successful" || true) "
101133 has_fetched_keyset=" $( docker logs --since=20m coprocessor-sns-worker 2>&1 | rg -c " Fetched keyset" || true) "
102- has_key_material=" $( db_query " SELECT COALESCE(bool_and(COALESCE(octet_length(lo_get(sns_pk)), 0) > 0), false) FROM tenants;" ) "
134+ has_key_material=" $( db_query "
135+ SELECT COALESCE(bool_and(key_bytes > 0), false)
136+ FROM (
137+ SELECT COALESCE(SUM(octet_length(lo.data)), 0) AS key_bytes
138+ FROM tenants t
139+ LEFT JOIN pg_largeobject lo
140+ ON lo.loid = t.sns_pk
141+ GROUP BY t.tenant_id
142+ ) s;
143+ " ) "
103144
104145 if [[ " ${has_activate_key} " -gt 0 && " ${has_fetched_keyset} " -gt 0 && " ${has_key_material} " == " t" ]]; then
105146 log " Bootstrap gate passed (ActivateKey + keyset + non-empty sns_pk)"
0 commit comments