Open JssDWt opened 1 week ago
I suspect that crashing in this case is the best we can do: The plugin has gotten the request, may have done something with it (created DB entries, ordered a Chai Latte, you name it), and that cannot be undone by ignoring the failed result, and pretending we never called the hook.
We have two options:
In your case feeding the HTLC back into the plugin caused it to crash again, causing a crash loop, but what else could we do? If we didn't replay the HTLC then the plugin would not have seen some of the HTLCs, potentially breaking the guarantees lightningd
gives the plugin.
Given these considerations, I don't think this is fixable, as a change/weakening in semantics would be our only option, and we don't want that. You were unfortunate since htlc_accepted
is special in that the HTLC gets replayed at startup, which is not the case for all hooks.
The one option I see is to kill the plugin, if it's run with plugin
rather than important-plugin
. Then process htlcs as if the plugin didn't exist. I would consider that 'expected' if a non-important plugin misbehaves.
I believe the discussion is more about when a plugin should return an error to Core Lightning. I agree with @cdecker that killing the plugin on encountering an unexpected error does not solve anything. You cannot apply this rule universally to every plugin because you risk terminating a plugin that is performing critical operations and must not be killed—for example, a backup plugin.
That said, this is a Rust plugin (likely the one GL is shipping to handle the trampoline functionality), and in my opinion, this represents a misuse of Rust's ?
operator.
Why should this error be returned to Core Lightning in this case? If it’s a JSON encoding/decoding error (I am assuming from the error, looks like a serde_json error), the plugin author should terminate the plugin intentionally (panic
) because only they know whether it is safe to do so. Am I missing something here?
Plugin trampoline for htlc_accepted returned non-result response {"error":{"code":-32700,"data":null,"message":"missing field `forward_msat`"},"id":"cln:htlc_accepted#1","jsonrpc":"2.0"}
Issue and Steps to Reproduce
getinfo
outputv24.08