Skip to content

refactor: extract shared get_public_ip into helpers.sh#1051

Open
mehmetkr-31 wants to merge 1 commit intobase:mainfrom
mehmetkr-31:refactor/shared-get-public-ip-helper
Open

refactor: extract shared get_public_ip into helpers.sh#1051
mehmetkr-31 wants to merge 1 commit intobase:mainfrom
mehmetkr-31:refactor/shared-get-public-ip-helper

Conversation

@mehmetkr-31
Copy link
Copy Markdown

Summary

Eliminates 23-line duplication of get_public_ip() across op-node-entrypoint and base-consensus-entrypoint by moving it into a shared helpers.sh script.

Problem

The get_public_ip() bash function was copy-pasted verbatim in two entrypoints. This violates DRY:

  • Any bug fix or provider list change must be edited twice.
  • The two copies can silently diverge over time.

Solution

  1. Create helpers.sh containing a single, documented get_public_ip implementation.
  2. Replace inline definitions with source ./helpers.sh in both entrypoints.
  3. Add COPY helpers.sh . to geth, reth, and nethermind Dockerfiles so the helper is present in all final images.

Files Changed

File Change
helpers.sh New — shared helper library
op-node-entrypoint Remove inline get_public_ip, add source ./helpers.sh
base-consensus-entrypoint Same as above
geth/Dockerfile COPY helpers.sh .
reth/Dockerfile COPY helpers.sh .
nethermind/Dockerfile COPY helpers.sh .

Verification

  • get_public_ip is still callable from both entrypoints.
  • Docker build context includes helpers.sh at repo root, so all COPY instructions resolve.
  • No functional change; behavior is identical.

Impact

  • Reduces maintenance burden for future IP-detection changes.
  • Establishes a pattern for shared helper functions across entrypoints.

Checklist

  • Refactor only — no functional changes.
  • All three client Dockerfiles updated.
  • Verified that source ./helpers.sh resolves inside the container (/app).

The get_public_ip() function was duplicated verbatim in both
op-node-entrypoint and base-consensus-entrypoint (23 lines each).
Any future change to IP detection logic would need to be made in two
places, increasing the risk of drift.

- Create helpers.sh with a single, documented get_public_ip function.
- Replace the inline definitions in op-node-entrypoint and
  base-consensus-entrypoint with source ./helpers.sh.
- Add COPY helpers.sh . to geth, reth, and nethermind Dockerfiles so
  the helper is available in all final images.

No functional change.
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants