Skip to content

Commit 1826e82

Browse files
committed
Refactored generate-policies script to remove Git cloning and build steps, and streamline Docker image usage
1 parent 4e45ed4 commit 1826e82

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

scripts/cross-chain-policies/generate-policies.sh

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
#!/usr/bin/env bash
33
set -euo pipefail
44

5-
# - Clones https://github.com/merendamattia/crosschain-policy-agent
6-
# - Builds a Docker image and runs it for each bridge folder found under BRIDGES_ROOT
7-
# - Outputs per-bridge policy files into OUTPUT_ROOT
8-
95
# -----------------------------
10-
# Configuration (edit these variables directly)
116
BRIDGES_ROOT="/Users/mere/git/evm-lisa/datasets/cross-chain/smartaxe/manually-labeled"
12-
REPO_TAG="v1.2.1"
13-
REPO_URL="https://github.com/merendamattia/crosschain-policy-agent.git"
14-
CLONE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/.external/crosschain-policy-agent-${REPO_TAG}"
15-
IMAGE_TAG="crosschain-agent:${REPO_TAG}"
16-
OUTPUT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/outputs/generated-policies-${REPO_TAG}"
7+
DOCKER_IMAGE_TAG="v1.2.1"
8+
DOCKER_IMAGE_NAME="merendamattia/crosschain-policy-agent:${DOCKER_IMAGE_TAG}"
9+
OUTPUT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/outputs/generated-policies-${DOCKER_IMAGE_TAG}"
1710
ENV_FILE=".env"
1811
CLIENT="google" # "openai" or "google"
1912
# -----------------------------
@@ -31,41 +24,25 @@ if [[ -z "$BRIDGES_ROOT" || ! -d "$BRIDGES_ROOT" ]]; then
3124
exit 2
3225
fi
3326

34-
mkdir -p "$(dirname "$CLONE_DIR")"
3527
mkdir -p "$OUTPUT_ROOT"
3628

37-
command -v git >/dev/null 2>&1 || { echo "ERROR: git not found. Install git." >&2; exit 3; }
3829
command -v docker >/dev/null 2>&1 || { echo "ERROR: docker not found. Install Docker." >&2; exit 4; }
3930

4031
log "Bridges root: $BRIDGES_ROOT"
41-
log "Clone dir: $CLONE_DIR"
4232
log "Output root: $OUTPUT_ROOT"
4333

44-
# Clone or update the repository at the specific tag
45-
if [[ -d "$CLONE_DIR/.git" ]]; then
46-
log "Repository already cloned. Fetching tags and checking out $REPO_TAG"
47-
set +e
48-
git -C "$CLONE_DIR" fetch --tags --prune
49-
git -C "$CLONE_DIR" checkout "$REPO_TAG"
50-
git -C "$CLONE_DIR" reset --hard
51-
set -e
52-
else
53-
log "Cloning $REPO_URL $REPO_TAG into $CLONE_DIR"
54-
git clone --depth 1 --branch "$REPO_TAG" "$REPO_URL" "$CLONE_DIR"
55-
fi
56-
5734
# Decide env-file usage (ENV_FILE can be left empty to skip)
5835
if [[ -n "$ENV_FILE" && ! -f "$ENV_FILE" ]]; then
5936
echo "ERROR: ENV_FILE is set but file does not exist: $ENV_FILE" >&2
6037
exit 5
6138
fi
6239

63-
# Build docker image
64-
log "Building Docker image: $IMAGE_TAG (context: $CLONE_DIR)"
40+
# Pull docker image from Docker Hub
41+
log "Pulling Docker image: $DOCKER_IMAGE_NAME"
6542
if [[ $DRY_RUN -eq 1 ]]; then
66-
echo "DRY-RUN: docker build -t $IMAGE_TAG $CLONE_DIR"
43+
echo "DRY-RUN: docker pull $DOCKER_IMAGE_NAME"
6744
else
68-
docker build -t "$IMAGE_TAG" "$CLONE_DIR"
45+
docker pull "$DOCKER_IMAGE_NAME"
6946
fi
7047

7148
shopt -s nullglob
@@ -95,7 +72,7 @@ for entry in "$BRIDGES_ROOT"/*; do
9572
fi
9673
docker_cmd+=(-v "$src_dir:/data/sol:ro")
9774
docker_cmd+=(-v "$out_dir:/app/output")
98-
docker_cmd+=("$IMAGE_TAG")
75+
docker_cmd+=("$DOCKER_IMAGE_NAME")
9976
docker_cmd+=(--target-path /data/sol --output-file /app/output/"${bridge_name}.policy.json")
10077
docker_cmd+=(--client "$CLIENT")
10178

0 commit comments

Comments
 (0)