Skip to content

Commit

Permalink
Merge pull request #50 from PowerLoom/hotfix/local_collector_port_allow
Browse files Browse the repository at this point in the history
hotfix: auto add ufw rule for communication to local collector port
  • Loading branch information
anomit authored Sep 2, 2024
2 parents cf3a0a4 + 682625a commit 203a542
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
29 changes: 28 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ fi

source .env

BASE_SUBNET=$((SLOT_ID % 256))

if [ -z "$OVERRIDE_DEFAULTS" ]; then
echo "setting default values...";
export PROST_RPC_URL="https://rpc-prost1m.powerloom.io"
export PROTOCOL_STATE_CONTRACT="0xE88E5f64AEB483d7057645326AdDFA24A3B312DF"
export DATA_MARKET_CONTRACT="0x0C2E22fe7526fAeF28E7A58c84f8723dEFcE200c"
export PROST_CHAIN_ID="11169"
export DOCKER_NETWORK_NAME="snapshotter-lite-v2-${SLOT_ID}"
export DOCKER_NETWORK_SUBNET="172.16.${BASE_SUBNET}.0/23"
fi


Expand All @@ -64,7 +68,15 @@ if [ -z "$SIGNER_ACCOUNT_PRIVATE_KEY" ]; then
exit 1;
fi

echo "Found SOURCE RPC URL ${SOURCE_RPC_URL}";
if [ -z "$DOCKER_NETWORK_SUBNET" ]; then
echo "DOCKER_NETWORK_SUBNET not found, please set this in your .env!";
exit 1;
fi

echo "DOCKER NETWORK SUBNET: ${DOCKER_NETWORK_SUBNET}"
echo "DOCKER NETWORK NAME: ${DOCKER_NETWORK_NAME}"

echo "Found SOURCE RPC URL ${SOURCE_RPC_URL}"

echo "Found SIGNER ACCOUNT ADDRESS ${SIGNER_ACCOUNT_ADDRESS}";

Expand Down Expand Up @@ -111,6 +123,21 @@ else
echo "Found LOCAL_COLLECTOR_PORT ${LOCAL_COLLECTOR_PORT}";
fi

# check if ufw command exists
if [ -x "$(command -v ufw)" ]; then
ufw allow from $DOCKER_NETWORK_SUBNET to any port $LOCAL_COLLECTOR_PORT
if [ $? -eq 0 ]; then
echo "ufw allow rule added for local collector port ${LOCAL_COLLECTOR_PORT} to allow connections from ${DOCKER_NETWORK_SUBNET}.\n"
else
echo "ufw firewall allow rule could not added for local collector port ${LOCAL_COLLECTOR_PORT} \
Please attempt to add it manually with the following command with sudo privileges: \
sudo ufw allow from $DOCKER_NETWORK_SUBNET to any port $LOCAL_COLLECTOR_PORT \
Then run ./build.sh again."
# exit script if ufw rule not added
exit 1
fi
fi

#fetch current git branch name
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ services:
- BLOCK_TIME=$BLOCK_TIME
command:
bash -c "bash server_autofill.sh && bash init_processes.sh"
networks:
- custom_network

snapshotter-lite-v2:
image: ghcr.io/powerloom/snapshotter-lite-v2:${IMAGE_TAG}
Expand Down Expand Up @@ -62,6 +64,8 @@ services:
bash -c "bash snapshotter_autofill.sh && bash init_docker.sh"
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- custom_network
ipfs:
image: ipfs/kubo:release
profiles: ["ipfs"]
Expand All @@ -80,3 +84,12 @@ services:
#command:
# ["daemon", "--migrate=true", "--agent-version-suffix=docker"]
restart: on-failure
networks:
- custom_network
networks:
custom_network:
name: ${DOCKER_NETWORK_NAME}
driver: bridge
ipam:
config:
- subnet: ${DOCKER_NETWORK_SUBNET}
1 change: 1 addition & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ SOURCE_RPC_URL=<source-rpc-url>
SIGNER_ACCOUNT_ADDRESS=<signer-account-address>
SIGNER_ACCOUNT_PRIVATE_KEY=<signer-account-private-key>
SLOT_ID=<slot-id>
DOCKER_NETWORK_NAME=
PROST_RPC_URL=https://rpc-prost1m.powerloom.io
PROTOCOL_STATE_CONTRACT=0xE88E5f64AEB483d7057645326AdDFA24A3B312DF
DATA_MARKET_CONTRACT=0x0C2E22fe7526fAeF28E7A58c84f8723dEFcE200c
Expand Down

0 comments on commit 203a542

Please sign in to comment.