Closed renepickhardt closed 5 years ago
Yuck. @cdecker changed htlcs to be retried, rather than failed, on startup. But plugins aren't ready yet.
Completing the HTLCs later is the obvious solution, but I'm not sure what the effect of having "half-finished" HTLCs lying around in the interim would be (which is why we failed on startup!).
Assigning to @cdecker for this thoughts.
I'm surprised calling any RPC call while handling a hook is actually working at all. Remember that the hooks are supposed to be synchronous and no other action is allowed to make any progress, including RPC calls. This is the main motivation when I felt ok moving the call to htlc_accepted
hook calls before init
calls in the first place (you're not supposed to interact with the RPC when handling a hook, though I could have made that more clear in the documentation).
TL;DR: Your hook handling logic simply should not rely on the fact that the RPC is available at all, since they may be called before init
, and the RPC will likely not reply, since hook calls are synchronous.
FWIW db_write
suffers from the same issue, i.e., returning writes before calling init
, and we solve it by postponing the write to the backup.
A clean solution would be to introduce a hold
state (which we'll need eventually anyway), then holding on to HTLCs until we are initialized, and only then returning the verdict that may depend on RPC calls.
I'm surprised calling any RPC call while handling a hook is actually working at all. Remember that the hooks are supposed to be synchronous and no other action is allowed to make any progress, including RPC calls..
FWIW I noticed they are not while working on https://github.com/ElementsProject/lightning/pull/2925. That surprised me and that's why I extended the API in this PR.
Ok, we'll defer this until next version, since rc1 is due.
The DB hook is a special case, and documented as such: generally we shouldn't be calling into a plugin before init.
it seems like the
@plugin.hook("htlc_accepted")
hook is not working as excpected when starting a node which has an unresolved htlc.from the logfile I copy
this error is invoked because I called
plugin.rpc.getinf()
it seems like on startupplugin.rpc
is stillNone
but the hook is already being invoked.Issue and Steps to Reproduce
create a payment channel between two nodes. Initiate the payment process and let the other node crash during the payment process. then restart the node and experience this behavior.
getinfo
output