-
Notifications
You must be signed in to change notification settings - Fork 223
Use RPC for friendbot when available #840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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_urlfrom 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.
| 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 |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
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| # complete otherwise the txs sequence numbers will conflict. | ||
| if [ "$ENABLE_HORIZON" == "true" ]; then | ||
| if [ "$ENABLE_HORIZON" == "true" ] || [ "$ENABLE_RPC" == "true" ]; then | ||
| supervisorctl start friendbot |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
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| supervisorctl start friendbot | |
| supervisorctl start friendbot |
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