Skip to content

Conversation

@leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Dec 1, 2025

What

Use the RPC backend support of friendbot instead of Horizon. Update startup script to wait for either RPC or Horizon based on configuration. Remove hardcoded horizon_url from config and dynamically inject the appropriate backend URL. Allow friendbot to start when only RPC is enabled without requiring Horizon.

Why

Friendbot previously required Horizon to fund accounts. With RPC support, friendbot can operate in RPC-only deployments without needing Horizon running. RPC is the preferred integration point, because in the future Friendbot will support funding contracts, and so even if both RPC and Horizon are available it will default to RPC to be able to support contract functionality.

Merging

Dependent on:

Cannot be merged until all images are updated to use a version of friendbot that contains the two dependent changes above.

Testing

This change includes a new image, friendbot-with-rpc, temporarily just while in pull request that can be used for testing the dependent changes above.

Close stellar/friendbot#5
Close #791

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Dec 1, 2025
Copilot finished reviewing on behalf of leighmcculloch December 1, 2025 02:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enables friendbot to use RPC as its backend instead of requiring Horizon, supporting RPC-only deployments. The changes allow friendbot to dynamically configure either RPC or Horizon backends, with RPC being the preferred option when both are available to support future contract funding functionality.

  • Removed hardcoded horizon_url from friendbot config and made backend URL injection dynamic based on which service is enabled
  • Updated startup scripts to conditionally wait for either RPC or Horizon based on friendbot's configuration
  • Removed the forced enabling of Horizon when RPC is enabled for local networks

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
start Removed forced ENABLE_HORIZON when ENABLE_RPC is true; added dynamic backend URL injection in init_friendbot(); updated upgrade_local() to start friendbot when either RPC or Horizon is enabled
common/friendbot/etc/friendbot.cfg Removed hardcoded horizon_url to allow dynamic backend configuration
common/friendbot/bin/start Added conditional waiting logic for RPC and Horizon backends based on configuration file contents
images.json Added temporary "friendbot-with-rpc" image for testing the dependent friendbot changes with specific commit reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +498 to +502
if [ "$ENABLE_RPC" = "true" ]; then
echo 'rpc_url = "http://localhost:8003"' >> etc/friendbot.cfg
elif [ "$ENABLE_HORIZON" = "true" ]; then
echo 'horizon_url = "http://localhost:8001"' >> etc/friendbot.cfg
fi
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init_friendbot() function should validate that at least one of ENABLE_RPC or ENABLE_HORIZON is true before proceeding. Without this check, friendbot could be initialized with no backend configured, which would cause it to fail when started. Consider adding a validation:

function init_friendbot() {
  if [ "$ENABLE_RPC" != "true" ] && [ "$ENABLE_HORIZON" != "true" ]; then
    echo "Warning: Friendbot requires either RPC or Horizon to be enabled"
    return 0
  fi

  pushd $FBHOME
  # ... rest of function

Copilot uses AI. Check for mistakes.
# complete otherwise the txs sequence numbers will conflict.
if [ "$ENABLE_HORIZON" == "true" ]; then
if [ "$ENABLE_HORIZON" == "true" ] || [ "$ENABLE_RPC" == "true" ]; then
supervisorctl start friendbot
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: this line uses 6 spaces while the codebase consistently uses 4 spaces for content inside if blocks (see lines 690-691, 695-696, 700, 704). Please adjust to 4 spaces:

if [ "$ENABLE_HORIZON" == "true" ] || [ "$ENABLE_RPC" == "true" ]; then
    supervisorctl start friendbot
fi
Suggested change
supervisorctl start friendbot
supervisorctl start friendbot

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

Add support for using RPC instead of Horizon Make horizon optional at build/runtime

2 participants