-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyln: Add safe fallback results for hooks #4031
pyln: Add safe fallback results for hooks #4031
Conversation
71bf992
to
8d4ddc3
Compare
8d4ddc3
to
b7e3829
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK b7e3829
'/home/travis/build/ElementsProject/lightning/tests/plugins/htlc_accepted-crash.py': opening pipe: No such file or directory
Looks like you forgot to check in htlc_accepted-crash.py
r'Hook handler for htlc_accepted failed with an exception.' | ||
) | ||
|
||
with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_NODE_FAILURE'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also test for one of the 'non-recoverable' hooks, db_write
or commitment_revocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it, the semantics are a bit different though (db_write
hangs indefinitely for example).
Hooks do not tolerate failures at all. If we return a JSON-RPC error to a hook call the only thing the main daemon can really do is to crash. This commit adds a mapping of error to a safe fallback result, including a warning to the node operator that this should be addressed in the plugin. The warning is reported as a `**BROKEN**` message, and should therefore fail any testing done on the plugin. Changelog-Fixed: pyln: Fixed HTLCs hanging indefinitely if the hook function raises an exception. A safe fallback result is now returned instead.
b7e3829
to
7f0db34
Compare
Good catch, fixed up :-) |
Ack 7f0db34 |
Hooks do not tolerate failures at all. If we return a JSON-RPC error to a hook
call the only thing the main daemon can really do is to crash. This commit
adds a mapping of error to a safe fallback result, including a warning to the
node operator that this should be addressed in the plugin. The warning is
reported as a
**BROKEN**
message, and should therefore fail any testing doneon the plugin.
The alternatives would have been
lightningd
. But I don't like relaxing the requirements on this. It feels magic enough as it is, but prevents us from accidentally hanging due to a plugin.Fixes #3748