Skip to content

Add Stellar support to cre workflow simulate - #612

Open
karen-stepanyan wants to merge 4 commits into
mainfrom
stellar-simulation
Open

karen-stepanyan wants to merge 4 commits into
mainfrom
stellar-simulation

Conversation

@karen-stepanyan

Copy link
Copy Markdown
Contributor

Adds Stellar to cre workflow simulate, built on FakeStellarChain from
chainlink-stellar/capabilities.

  • New stellar chain type: reads (ReadContract, GetLatestLedger) go to the configured Stellar RPC; writes go through the CRE mock forwarder, which skips DON signature checks.
    • Default: dry-run (simulated with simulateTransaction, nothing submitted).
    • --broadcast: signed and submitted; requires CRE_STELLAR_PRIVATE_KEY (S… seed of a funded account).

Default mock forwarders

  • stellar-testnet: CC5OVNNU32FQAWHDWIGFUWYRLMPVERESM52S4IYC3MMETI2YDX3N674X
  • stellar-mainnet: CBBNYOUOFBQZDJFN4GVFODGOPDY6DRRWZBWGXFGJQZBRFXSFAQPX3L6T

Override per target with an experimental-chains entry (chain-type: stellar).

Dependency bump

  • chainlink/v2 + chainlink/deployment → edb5ba66 (includes the stellar encoder in the fake consensus), Go 1.27.1.
  • Follow-ups from the bump: capabilities registry moved to chainlink-common (capreg.Registry); telemetry writer accepts the OTel v0.22 BYTESLICE body type, otherwise simulations silently dropped all workflow logs.

@karen-stepanyan
karen-stepanyan marked this pull request as ready for review October 6, 2026 13:07
@karen-stepanyan
karen-stepanyan requested a review from a team as a code owner October 6, 2026 13:07
@anirudhwarrier
anirudhwarrier requested a balanced review from Copilot October 7, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Stellar services are not started, and the core broadcast/dry-run registration path lacks coverage.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds Stellar read/write support to workflow simulation, including dry-run and broadcast modes.

Changes:

  • Registers Stellar clients, mock forwarders, keys, health checks, and limits.
  • Migrates capability registries and updates telemetry compatibility.
  • Upgrades Go, Chainlink, Stellar, and related dependencies.
File Description
.github/​workflows/​pull-request-main.yml Updates golangci-lint.
cmd/​workflow/​simulate/​capabilities.go Migrates capability registry types.
cmd/​workflow/​simulate/​chain/​evm/​capabilities.go Migrates EVM registry types.
cmd/​workflow/​simulate/​chain/​evm/​chaintype_test.go Updates EVM registry tests.
cmd/​workflow/​simulate/​chain/​solana/​capabilities.go Migrates Solana registry types.
cmd/​workflow/​simulate/​chain/​stellar/​chaintype.go Implements Stellar simulation support.
cmd/​workflow/​simulate/​chain/​stellar/​chaintype_test.go Tests Stellar configuration and keys.
cmd/​workflow/​simulate/​chain/​stellar/​health.go Adds Stellar RPC health checks.
cmd/​workflow/​simulate/​chain/​stellar/​limited_capabilities.go Enforces Stellar report limits.
cmd/​workflow/​simulate/​chain/​stellar/​supported_chains.go Defines default Stellar networks and forwarders.
cmd/​workflow/​simulate/​chain/​types.go Migrates shared registry configuration.
cmd/​workflow/​simulate/​simulate.go Registers Stellar and the new registry implementation.
cmd/​workflow/​simulate/​telemetry_writer.go Supports OTel byte-slice bodies.
go.mod Upgrades Go and dependencies.
go.sum Refreshes dependency checksums.
internal/​settings/​settings.go Adds Stellar private-key settings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +180 to +181
Transmitter: transmitter,
DryRun: !cfg.Broadcast,
Comment on lines +190 to +191
ct.chains[sel] = dc
out = append(out, dc)
@anirudhwarrier
anirudhwarrier requested review from anirudhwarrier and removed request for leeyikjiun October 7, 2026 07:48

@anirudhwarrier anirudhwarrier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requesting changes for a resource leak in StellarChainType.RegisterCapabilities: started fake chains aren't closed on error paths. Details inline.

if err != nil {
return nil, fmt.Errorf("stellar: selector %d: %w", sel, err)
}
if err := dc.Start(ctx); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Chains started in earlier iterations leak if a later iteration fails. Every error return here (and the resolvePassphrase / NewFakeStellarChain errors above) returns nil, err, so out is discarded. simulate.go only keeps the services when there's no error, so simulatorCleanup never calls Close on the chains that were already started.

Example: testnet plus an experimental selector. Testnet starts first (depending on map order), then GetNetwork for the experimental selector fails. The testnet chain's goroutines and RPC polling keep running.

Suggestion: on any error, close everything already in out before returning, e.g. a deferred cleanup guarded by a named err:

defer func() {
	if err != nil {
		for _, s := range out {
			_ = s.Close()
		}
	}
}()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, good catch. There are no background goroutines or polling, Start and Close both are no-ops and just return nil now, so nothing actually leaked, but this no longer relies on that.

return nil, fmt.Errorf("stellar: failed to start chain for selector %d: %w", sel, err)
}
server := stellarserver.NewClientServer(NewLimitedStellarChain(dc, lim))
if err := cfg.Registry.Add(ctx, server); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dc.Start runs before cfg.Registry.Add. If Add fails (e.g. a duplicate capability ID), dc is already started but never appended to out and never closed.

Solana builds and registers everything first and starts afterwards (solana/chaintype.go:253). Could we do the same here: register first, then start, or at least dc.Close() when Add fails? Combined with the cleanup suggested on L186, that covers every error path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as comment above, applied fix to not rely on no-ops

This branch has not been deployed

No deployments
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.

3 participants