Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions base-consensus-entrypoint
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
#!/bin/bash
set -eu

get_public_ip() {
# Define a list of HTTP-based providers
local PROVIDERS=(
"http://ifconfig.me"
"http://api.ipify.org"
"http://ipecho.net/plain"
"http://v4.ident.me"
)
# Iterate through the providers until an IP is found or the list is exhausted
for provider in "${PROVIDERS[@]}"; do
local IP
IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider")
# Check if IP contains a valid format (simple regex for an IPv4 address)
if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$IP"
return 0
fi
done
return 1
}
source ./helpers.sh

if [[ -z "${BASE_NODE_NETWORK:-}" ]]; then
echo "expected BASE_NODE_NETWORK to be set" 1>&2
Expand Down
1 change: 1 addition & 0 deletions geth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY geth/geth-entrypoint ./execution-entrypoint
COPY op-node-entrypoint .
COPY consensus-entrypoint .
COPY helpers.sh .

CMD ["/usr/bin/supervisord"]
24 changes: 24 additions & 0 deletions helpers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Shared helper functions used by Base node entrypoints

# get_public_ip attempts to discover the node's public IPv4 address
# by querying a list of HTTP-based IP detection services.
# Prints the IP to stdout and returns 0 on success, 1 on failure.
get_public_ip() {
local PROVIDERS=(
"http://ifconfig.me"
"http://api.ipify.org"
"http://ipecho.net/plain"
"http://v4.ident.me"
)

for provider in "${PROVIDERS[@]}"; do
local IP
IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider")
if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$IP"
return 0
fi
done
return 1
}
1 change: 1 addition & 0 deletions nethermind/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY nethermind/nethermind-entrypoint ./execution-entrypoint
COPY op-node-entrypoint .
COPY consensus-entrypoint .
COPY helpers.sh .

CMD ["/usr/bin/supervisord"]
21 changes: 1 addition & 20 deletions op-node-entrypoint
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
#!/bin/bash
set -eu

get_public_ip() {
# Define a list of HTTP-based providers
local PROVIDERS=(
"http://ifconfig.me"
"http://api.ipify.org"
"http://ipecho.net/plain"
"http://v4.ident.me"
)
# Iterate through the providers until an IP is found or the list is exhausted
for provider in "${PROVIDERS[@]}"; do
local IP
IP=$(curl -s --max-time 10 --connect-timeout 5 "$provider")
# Check if IP contains a valid format (simple regex for an IPv4 address)
if [[ $IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$IP"
return 0
fi
done
return 1
}
source ./helpers.sh

if [[ -z "$OP_NODE_NETWORK" && -z "$OP_NODE_ROLLUP_CONFIG" ]]; then
echo "expected OP_NODE_NETWORK to be set" 1>&2
Expand Down
1 change: 1 addition & 0 deletions reth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ COPY ./reth/reth-entrypoint ./execution-entrypoint
COPY op-node-entrypoint .
COPY base-consensus-entrypoint .
COPY consensus-entrypoint .
COPY helpers.sh .

CMD ["/usr/bin/supervisord"]