Skip to content

rpc: fix leak#8515

Open
jherrera-jump wants to merge 1 commit intofiredancer-io:mainfrom
jherrera-jump:jherrera/rpc-fix-startup-behavior
Open

rpc: fix leak#8515
jherrera-jump wants to merge 1 commit intofiredancer-io:mainfrom
jherrera-jump:jherrera/rpc-fix-startup-behavior

Conversation

@jherrera-jump
Copy link
Contributor

@jherrera-jump jherrera-jump commented Feb 26, 2026

  • Free memory allocated by cJSON_PrintUnformatted
  • drive-by notar fix

closes #7885

Copilot AI review requested due to automatic review settings February 26, 2026 22:43
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 PR fixes the RPC server's startup behavior by deferring HTTP server listening until after initial bank indices are populated. Previously, the server would start listening immediately and return HTTP 500 errors for requests that arrived before the node finished booting. Now, the server doesn't begin accepting connections until all three bank indices (processed, confirmed, and finalized) have been initialized with valid values.

Changes:

  • Deferred HTTP server listening from privileged_init to before_credit function, which waits for all bank indices to be initialized
  • Added new error constant FD_HTTP_SERVER_CONNECTION_CLOSE_STILL_BOOTING to the connection close reasons (renumbering all subsequent WebSocket error codes)
  • Replaced runtime error handling with FD_TEST assertions for bank index validation, since these values are guaranteed to be valid once the server starts listening

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/waltz/http/fd_http_server.h Added FD_HTTP_SERVER_CONNECTION_CLOSE_STILL_BOOTING constant and renumbered subsequent WebSocket error constants
src/waltz/http/fd_http_server.c Added human-readable string representation for the new error constant
src/discof/rpc/fd_rpc_tile.c Added boot state tracking fields, moved server listen to before_credit callback, replaced ULONG_MAX error returns with FD_TEST assertions, added conditional debug logging

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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch 2 times, most recently from d37e324 to 2ed7ded Compare February 26, 2026 22:55
Copilot AI review requested due to automatic review settings February 26, 2026 22:55
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

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


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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch 2 times, most recently from 02fdf3d to 939e57f Compare February 26, 2026 23:09
Copilot AI review requested due to automatic review settings February 26, 2026 23:09
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

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


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

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

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


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

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from 9540922 to 3fb5954 Compare February 27, 2026 23:03
Copilot AI review requested due to automatic review settings March 2, 2026 16:16
@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from 3fb5954 to 673745a Compare March 2, 2026 16:16
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

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.


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

Copilot AI review requested due to automatic review settings March 2, 2026 19:06
@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from b6a6eb0 to ef41e5f Compare March 2, 2026 19:06
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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.


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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from ef41e5f to f636fb7 Compare March 2, 2026 19:21
@jherrera-jump jherrera-jump marked this pull request as ready for review March 2, 2026 19:22
Copilot AI review requested due to automatic review settings March 2, 2026 19:22
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

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.


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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from f636fb7 to a8f6eb3 Compare March 2, 2026 19:28
Copilot AI review requested due to automatic review settings March 2, 2026 19:31
@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from a8f6eb3 to bcc6f7a Compare March 2, 2026 19:31
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

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.


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

@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from bcc6f7a to aa35069 Compare March 3, 2026 00:59
@jherrera-jump jherrera-jump marked this pull request as draft March 3, 2026 03:53
Copilot AI review requested due to automatic review settings March 3, 2026 03:54
@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch from aa35069 to 17f8c31 Compare March 3, 2026 03:54
@jherrera-jump jherrera-jump changed the title rpc: fix leak, delay startup rpc: fix leak Mar 3, 2026
@jherrera-jump jherrera-jump force-pushed the jherrera/rpc-fix-startup-behavior branch 2 times, most recently from 304dcbd to e5359d1 Compare March 3, 2026 03: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

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

Comments suppressed due to low confidence (3)

src/discof/rpc/fd_rpc_tile.c:1782

  • This still calls fd_http_server_listen() during privileged_init, which means the RPC port will be listening immediately. That conflicts with the nearby comments (and PR description) that listening should be delayed until replay banks are available. If the intent is to match Agave by refusing connections during boot, consider moving the listen call to the point where banks are initialized (e.g. after receiving the first REPLAY_SIG_SLOT_COMPLETED / setting the processed/confirmed/finalized indices) and only then start polling/accepting.

extern char const fdctl_version_string[];

src/discof/rpc/fd_rpc_tile.c:730

  • This error response uses "code":32065 (positive). JSON-RPC error codes should be negative here (and the rest of this file uses -32065 for Firedancer-specific errors). As written, clients/tests that match on the error code will see a different value than intended.
  *bank_idx = _bank_idx;

src/discof/rpc/fd_rpc_tile.c:224

  • is_booting is introduced with a comment that the server won't start listening until it becomes false, but there is no logic in this file that reads or updates ctx->is_booting. Either wire this into the actual startup/listen gating (and clear it once banks are initialized) or remove it to avoid misleading state that suggests behavior that isn't implemented.
  fd_http_server_t * http;

  fd_rpc_cluster_node_dlist_t * cluster_nodes_dlist;
  fd_rpc_cluster_node_t cluster_nodes[ FD_CONTACT_INFO_TABLE_SIZE ];

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

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

@jherrera-jump jherrera-jump marked this pull request as ready for review March 3, 2026 04:08
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.

implement minimal rpc server

2 participants