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:

Close stellar/friendbot#5
Close #791

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.

Copy link
Contributor

@sreuland sreuland left a comment

Choose a reason for hiding this comment

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

looks good, left one comment on friendbot startup config.

@leighmcculloch leighmcculloch marked this pull request as ready for review December 5, 2025 11:25
@leighmcculloch leighmcculloch marked this pull request as draft December 5, 2025 14:58
@leighmcculloch
Copy link
Member Author

TODO:

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Dec 6, 2025

The intermittent race condition failure is difficult to debug because the container log collection is broken.

Opened issue to track fixing that:

And pull request with fix:

@leighmcculloch
Copy link
Member Author

This is an example of intermittent failure now that the logging has been fixed:

@leighmcculloch
Copy link
Member Author

These are Friendbot logs. It looks like it's failing trying to create the minion accounts.

Waiting for rpc to be available...
starting friendbot...
time="2025-12-07T23:31:03.005Z" level=info msg="Tracing disabled - using no-op tracer" pid=759
time="2025-12-07T23:31:03.005Z" level=info msg="Tracer initialized" pid=759
2025/12/07 23:31:03 Found all valid params, now creating 10 minions
2025/12/07 23:31:03 Creating 10 new minion accounts
time="2025-12-07T23:31:03.146Z" level=error msg="creating minion accounts: submitting create accounts tx: transaction rejected" pid=759

@leighmcculloch
Copy link
Member Author

I've added better logging via the following change to better understand what is causing the failure:

@leighmcculloch
Copy link
Member Author

leighmcculloch commented Dec 15, 2025

Failure with the additional logs:

Waiting for rpc to be available...
[before loop] RPC getHealth:
{"jsonrpc":"2.0","id":1,"result":{"status":"healthy","latestLedger":8,"oldestLedger":7,"ledgerRetentionWindow":120960}}[after loop - RPC healthy] RPC getHealth:
{"jsonrpc":"2.0","id":1,"result":{"status":"healthy","latestLedger":8,"oldestLedger":7,"ledgerRetentionWindow":120960}}starting friendbot...
time="2025-12-15T02:02:56.060Z" level=info msg="Tracing disabled - using no-op tracer" pid=766
time="2025-12-15T02:02:56.060Z" level=info msg="Tracer initialized" pid=766
2025/12/15 02:02:56 Found all valid params, now creating 10 minions
2025/12/15 02:02:56 Creating 10 new minion accounts
time="2025-12-15T02:02:56.223Z" level=error msg="creating minion accounts: submitting create accounts tx: transaction rejected, result_xdr: AAAAAAAAA+j////7AAAAAA==, diagnostic_events_xdr: []" pid=766
$ echo 'AAAAAAAAA+j////7AAAAAA==' | stellar xdr decode --type TransactionResult
(eval):7003: command not found: compdef
{"fee_charged":"1000","result":"tx_bad_seq","ext":"v0"}

@leighmcculloch
Copy link
Member Author

Confirmed in run https://github.com/stellar/quickstart/actions/runs/20224258276/job/58052322453?pr=840 that the fix in stellar/friendbot#35 works as expected:

Waiting for rpc to be available...
[before loop] RPC getHealth:
{"jsonrpc":"2.0","id":1,"result":{"status":"healthy","latestLedger":9,"oldestLedger":7,"ledgerRetentionWindow":120960}}[after loop - RPC healthy] RPC getHealth:
{"jsonrpc":"2.0","id":1,"result":{"status":"healthy","latestLedger":10,"oldestLedger":7,"ledgerRetentionWindow":120960}}starting friendbot...
time="2025-12-15T07:45:16.822Z" level=info msg="Tracing disabled - using no-op tracer" pid=768
time="2025-12-15T07:45:16.822Z" level=info msg="Tracer initialized" pid=768
2025/12/15 07:45:16 Found all valid params, now creating 10 minions
2025/12/15 07:45:16 Creating 10 new minion accounts
2025/12/15 07:45:16 submitting create accounts tx: transaction rejected
2025/12/15 07:45:16 trying again to submit create accounts tx
2025/12/15 07:45:16 Creating 10 new minion accounts
2025/12/15 07:45:19 Submitted create accounts tx for 10 minions successfully
2025/12/15 07:45:19 Adding 10 minions to friendbot
time="2025-12-15T07:45:19.120Z" level=info msg="starting friendbot server - d075991bca9365a9c87ab39f891dd3583e78c5c6-(built-from-source)" pid=768
time="2025-12-15T07:45:19.120Z" level=info msg="listening on 0.0.0.0:8002" pid=768
time="2025-12-15T07:45:31.199Z" level=info msg="starting request" host="127.0.0.1:8002" ip="127.0.0.1:38534" method=GET path="/?addr=GDDVAW5VBBMSKIGNHCZIRZ3BCDQXKO7TCPGEPJR4KL72RHAL2R2ETEST" pid=768 req=731641b79c8a/yguam9D3Yk-000001 subsys=http useragent=Go-http-client/1.1
2025/12/15 07:45:31 Selecting minion at index 0 of max length 10
time="2025-12-15T07:45:32.895Z" level=info msg="finished request" bytes=552 duration=1.695951897s ip="127.0.0.1:38534" method=GET path="/?addr=GDDVAW5VBBMSKIGNHCZIRZ3BCDQXKO7TCPGEPJR4KL72RHAL2R2ETEST" pid=768 req=731641b79c8a/yguam9D3Yk-000001 status=200 subsys=http

@leighmcculloch leighmcculloch marked this pull request as ready for review December 15, 2025 07:50
@leighmcculloch leighmcculloch enabled auto-merge (squash) December 15, 2025 22:54
@leighmcculloch leighmcculloch merged commit 9cd0488 into main Dec 15, 2025
88 checks passed
@leighmcculloch leighmcculloch deleted the add-friendbot-rpc-support branch December 15, 2025 23:03
@github-project-automation github-project-automation bot moved this from Backlog (Not Ready) to Done in DevX Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

3 participants