Skip to content

reckless: rust rewrite - #9239

Open
daywalker90 wants to merge 41 commits into
ElementsProject:masterfrom
daywalker90:reckless-rs
Open

daywalker90 wants to merge 41 commits into
ElementsProject:masterfrom
daywalker90:reckless-rs

Conversation

@daywalker90

@daywalker90 daywalker90 commented Jun 19, 2026 •

Copy link
Copy Markdown
Collaborator

Should
Fixes: #8439
Fixes: #8761
Fixes: #8775
Fixes: #8776
Fixes: #8794
and should supercede #8630

Key differences:

  • it is now a plugin only, the only use case to have a standalone binary, that i could come up with, is a broken plugin install where CLN won't start, but if you can call a binary you can uncomment a line in a config, right?
  • as a consequence, alot of options are no longer necessary and reckless-dir is a proper plugin option now
  • except for the help we always output json, so no more --json option
  • the rewrite does not adhere to the reckless schema in all places, e.g. listavailable, an array of strings is just not nice here
  • a tip function was added to tip plugin authors that have an offer in their manifest.json

@daywalker90
daywalker90 force-pushed the reckless-rs branch 2 times, most recently from 8644166 to 6889d36 Compare June 19, 2026 17:21

@vincenzopalazzo vincenzopalazzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice to see that the manifest idea is taking over. Hope you are also using git for versioning, otherwise this would be another good thing to take from https://github.com/coffee-tools/coffee

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be nice to reference the original reference implementation https://coffee-docs.netlify.app/support-coffee

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Would be nice to reference the original reference implementation https://coffee-docs.netlify.app/support-coffee

I was planning on giving full credit for the manifest/tip function to coffee in the README. But i want to lock down the functionality first before writing documentation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to save credit was also good to just include coffee, I do not think there are more features than coffee, we were also supporting ws (palanning to) to support interactive UX inside the web applications

But these days cloning is easy!

@daywalker90

Copy link
Copy Markdown
Collaborator Author

Nice to see that the manifest idea is taking over. Hope you are also using git for versioning, otherwise this would be another good thing to take from https://github.com/coffee-tools/coffee

If you mean installing a plugin with a git ref then yes, that is supported.

@vincenzopalazzo

Copy link
Copy Markdown
Collaborator

If you mean installing a plugin with a git ref then yes, that is supported.

Yeah, otherwise it's insanity! Nice, it would be nice to have two lines that reference coffee because the development died because Blockstream was moving to reckless. Referencing a good idea is what is left in this AI era, where rebuilding is easy

@madelinevibes madelinevibes added this to the v26.09 milestone Jun 22, 2026
@daywalker90
daywalker90 force-pushed the reckless-rs branch 3 times, most recently from 6658af8 to f6bbfb5 Compare July 1, 2026 17:09
@daywalker90
daywalker90 force-pushed the reckless-rs branch 5 times, most recently from 5833d8b to 853fe7d Compare July 8, 2026 15:34
@daywalker90
daywalker90 force-pushed the reckless-rs branch 4 times, most recently from f4513c8 to bf9e3e2 Compare July 14, 2026 12:39
@daywalker90
daywalker90 marked this pull request as ready for review July 14, 2026 13:11
@daywalker90
daywalker90 requested a review from cdecker as a code owner July 14, 2026 13:11
@daywalker90

daywalker90 commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Some tests will fail for now because of #9283. If we decide not to fix it, i can do a workaround.

@madelinevibes madelinevibes added the QA Blockstream QA team have reproduced, or a test has been created! Look for the linked PR/Issue label Jul 17, 2026
@daywalker90
daywalker90 force-pushed the reckless-rs branch 2 times, most recently from 59f0030 to a0ca360 Compare July 21, 2026 11:04
@madelinevibes madelinevibes added the Status::Ready for Review The work has been completed and is now awaiting evaluation or approval. label Jul 23, 2026
After
ElementsProject@fce9d6e
we can now use it.

Also fix writing flag options to config file.
The python wrapper only added the repo root to sys.path and ran the
bare file stem, so an entrypoint like src/main.py failed with
ImportError. Add the entrypoint's own directory to sys.path as well.
A single malformed manifest.json made find_plugin_locs return an error,
so every plugin in that source disappeared from listavailable and
install. Skip only the plugin whose manifest is invalid, log why, and
keep scanning the rest of the source. The plugin is not installed with
a default manifest, since that would ignore fields such as
installable: false.
…name

The lookup key was lowercased but the install directory kept the
original case, so uninstall of MyPlug looked for reckless/myplug and
failed to find the directory it had just installed.
A python plugin with a package.json at its root was routed to the
nodejs installer, so its python dependencies were never installed.
The nodejs installer symlinked the entry file and executed it directly.
A javascript entrypoint without a shebang failed to start with
'Exec format error (os error 8)'. Install a #!/bin/sh wrapper that runs
the node binary found at install time instead.
The python wrapper embedded the venv and source paths in a shebang and
in python string literals. A path with a space broke the shebang
(the kernel splits it), and a path with a single quote broke the
python source. Both wrappers are now sh scripts that pass every path
as a single-quoted argument, so no value is interpolated into code.
The depth-1 filter skipped any directory whose name contained 'archive',
so a plugin named archive_backup was silently left out of the source
scan. Match the directory name exactly instead.
The uninstall section showed the install command.
The non-unix stub used a bare Result, which is not imported in this
module, so the crate did not compile on non-unix targets.
The python tools/reckless and plugins/recklessrpc are replaced by the
rust cln-reckless plugin. Remove the old binary, recklessrpc plugin and
lightning-reckless.1 man page during make install, as was done for the
old wss-proxy plugin.

Changelog-Changed: reckless is now a Rust plugin.
Changelog-Removed: the standalone `reckless` tool, the `recklessrpc` plugin and the `lightning-reckless.1` man page. If you install CLN from pre-compiled binaries, first remove `reckless` (usually /usr/local/bin/reckless), `recklessrpc` (usually /usr/local/libexec/c-lightning/plugins/recklessrpc) and `lightning-reckless.1`. If you compile from source, `make install` removes them automatically.
REDIR_GITHUB redirects where reckless fetches plugin repositories from.
Only honour it in debug and small builds, so a release build always
uses GitHub.
Plugins installed by the old python reckless use a different layout
and are not managed by the rust plugin. listinstalled now logs a
warning for each of them, with the directory to delete and the
config lines to remove by hand.

Changelog-Changed: reckless is now a Rust plugin and cannot manage plugins installed by the old python reckless. Before upgrading CLN, uninstall each plugin you installed with the old `reckless uninstall <name>`, then remove any `disable-plugin=` line for it from your reckless config, which is `<lightning-dir>/reckless/<network>-reckless.conf`. After upgrading, reinstall each plugin with `reckless install <name>`. If you skip the uninstall, `listinstalled` shows a warning for each old install, and the old plugin is not removed automatically on upgrade.
The .sources reader parsed every line as a source, so one empty line
or comment made every reckless command fail with "path does not
exist". Skip blank and # lines when reading.

source remove rewrote the file from the parsed sources, which dropped
comments and blank lines. It now removes only the matching line and
keeps the rest. A source that is not listed no longer truncates the
file.
Previously, reckless update disabled the running plugin and mutated its
installed source directory and virtualenv in place before building the
new version. If the build or startup failed, the previously working
plugin was left stopped, commented out in reckless.conf, and unable to
be enabled or disabled again.

Stage updates into a versioned source directory and temporary entrypoint
inside the plugin directory, and validate getmanifest before touching
the running plugin or its config. Also copy local-path plugins into the
managed source directory on install so local edits cannot corrupt the
active installation before an update succeeds. If activating the new
version fails after swapping, restore the previous entrypoint and
metadata and re-enable the old version with its saved options.
Previously, disable_plugin required get_plugin_manifest to succeed
before
stopping a running plugin or updating config files, and uninstall
swallowed disable errors while leaving both the running process and
reckless.conf entries behind.

Persist each plugin's known option names in .metadata.json when reading
its manifest on enable, and fall back to those saved options (and path
matching against the plugin directory) when get_plugin_manifest or
.metadata.json is unavailable. Stop matching dynamic plugins via CLN's
full plugin paths, propagate stop and config cleanup errors instead of
falsely reporting success, and purge the plugin and its options from
reckless.conf on uninstall.
Previously, every reckless failure returned JSON-RPC code -32700 with
data: null and no log output, forcing callers to match English error
messages and hiding command logs on failure.

Add a structured RecklessError type using cln-plugin's JSON-encoded
{code, message, data} error support, reserving codes 2100-2112 in
common/jsonrpc_errors.h (plus -32602 for invalid params and -3 as an
internal fallback). Every error response now includes a stable
data.error identifier, the full command data.log array, and optional
context such as data.option (missing_option) or data.tool
(missing_build_tool). Document the error codes in reckless.json and
add tests covering them.
Expand `reckless listinstalled` entries with:
- `enabled`: whether the plugin is enabled in CLN or reckless config
- `running`: whether the plugin is currently active in `lightningd`
- `options`: active configuration options (`name` and optional `value`)
- `short_description` / `long_description`: from the plugin's reckless
  manifest when present

Document that `listinstalled` covers plugins installed through reckless
and give the `reckless-dir` config option a default value
(`<lightning-dir>/reckless`) so `listconfigs reckless-dir` reports it
even when not explicitly passed.
…tream

Tie `reckless_log` progress notifications to individual command
invocations and deliver them over gRPC:
- Replace `RecklessTopic` with `RecklessLogCommand` and emit
  `reckless_log` notifications for all logged reckless commands (not
  just `install` and `update`).
- Generate a unique `id` per command invocation and include `id`,
  `command`, and optional `plugin_name` in every `reckless_log`
  notification.
- Include the matching `id` in every reckless RPC response (and in
  structured error `data.id` when a command fails).
- Subscribe `cln-grpc` to `reckless_log` so `SubscribeRecklessLog`
  streams notifications to gRPC clients.
- Update schemas, regenerated msggen/gRPC/RPC bindings, and add unit +
  integration + gRPC streaming tests.
Switch `cln-reckless` from `chrono` to `jiff` (`default-features =
false, features = ["std"]`, reusing the `jiff` crate already in
`Cargo.lock`).
Remove the non-schema-conforming `help` subcommand (and empty-argument
help fallback) from `reckless` so every valid command returns the
documented response shape across JSON-RPC, `cln-rpc`, and gRPC, while
users consult the standard `lightning-cli help reckless` manual page.

Expand `doc/schemas/reckless.json` (which generates
`lightning-reckless(7)`) to document every command, `<name>@<ref>`
tag/branch/commit pinning, local directory installs, `source`
subcommands, `options`, `--verbose`/`--developer`, and `see_also`
references.
…d clients

Make reckless request, response, and notification schemas consistent for
JSON-RPC, `cln-rpc`, and gRPC clients:
- Accept `options` as a JSON object (and gRPC `map<string, string>`) in
  addition to the string-array CLI form, and accept `true`/`""`/`null`
  for flag options.
- Serialize `listavailable[].installer` as lower-case `snake_case`
  strings (non-enum in schema/proto so future installer changes don't
  break generated clients).
- Remove stale `target/subcommand` from `request.required` in
  `doc/schemas/reckless.json`.
- Add `UNSPECIFIED = 0` as the default value of `RecklessCommand` and
  reject it so omitted gRPC `command` fields cannot accidentally trigger
  `install`.
- Change `listinstalled[].installation_time` from `number` (`double`) to
  `u64` (`uint64`).
- Replace string `time` + ISO `timestamp` in `reckless_log` with a
  single `u64` `timestamp` (UNIX seconds) plus a zero-based
  per-invocation `seq` (`u64`) so clients can strictly order log lines
  and detect gaps.
@daywalker90

Copy link
Copy Markdown
Collaborator Author

All 7 blockers are addressed. Blockers 1, 2, 4, and 5 follow the review as requested; here are the specific places where i took a slightly different approach on 3, 6, and 7:

  • Blocker 3 (structured errors):

    • Distinct JSON-RPC error codes (2100–2112, -32602, -3) plus data.error, data.id, data.log, and context fields (data.option, data.tool) are returned on failures.
    • "Installed but did not start" on install still returns a normal response with enabled: false (rather than failing the install RPC) since the plugin is installed on disk; surfacing a clearer status/reason for that case is tracked under Gap 12. (enable itself returns 2104 missing_option or 2107 start_failed.)
    • Over gRPC, errors still come back as UNKNOWN wrapping the JSON-RPC {code, message, data} error, which is cln-grpc's standard error mapping across all RPCs.
  • Blocker 6 (help subcommand):

    • Instead of changing reckless help to fit the JSON/gRPC response schema, i removed the help subcommand (and empty-argument help fallback).
    • Rationale: CLI users have lightning-cli help reckless (i expanded doc/schemas/reckless.json / lightning-reckless(7) to document every command, @<ref> pinning, local paths, options, and flags), while programmatic/gRPC clients use the schema or .proto definitions directly rather than a help RPC. Every remaining command now strictly matches the schema across JSON-RPC and gRPC.
  • Blocker 7 (typed-client formats):

    • amount_msat on tip: I did not add "1000msat" string-suffix parsing, as string msat suffixes are deprecated/removed in CLN; amount_msat stays a numeric u64 (and Amount in gRPC).
    • installer in listavailable: Changed to lower-case snake_case, and typed as a plain string (non-enum in schema/proto) rather than a fixed enum, so future installer additions/removals will not break generated clients.
    • reckless_log time/ordering: Replaced the string time + ISO timestamp pair with a single integer timestamp (u64, UNIX seconds) plus a zero-based per-invocation seq (u64) so clients can strictly order lines emitted within the same second and detect missing notifications without needing sub-second timestamps.

The gaps i will do in a follow-up PR, as this one is big enough already :)

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

QA Blockstream QA team have reproduced, or a test has been created! Look for the linked PR/Issue Status::Ready for Review The work has been completed and is now awaiting evaluation or approval.

Projects

None yet

6 participants