charge-lnd icon indicating copy to clipboard operation
charge-lnd copied to clipboard

Add error reporting for UpdateChannelPolicy

Open derlade opened this issue 3 years ago • 5 comments

When running charge-lnd manually or from crontab, the channel properties are not updated according to the current configuration file. Instead they remain in their current state, although the output suggests that some properties are due for updating (i.e. fee_ppm 100 -> 10). Running charge-lnd repeatedly yields the same update output (i.e. fee_ppm 100 -> 10 for the same channel), and utilities like lntop show the channel still remaining at fee_ppm=100.

Running lnd v0.15.0-beta and charge-lnd v0.2.12.

derlade avatar Jul 26 '22 18:07 derlade

Can you give a bit more context? Did it work correctly with lnd v0.14.x? Did it work with older charge-lnd? Is it a certain strategy that is problematic? What authorizations are in the macaroon file you use?

accumulator avatar Jul 27 '22 07:07 accumulator

Unfortunately, I cannot remember exactly for how long the issue persisted. IIRC, it must have been a few months at least and I simply ignored it at first, so at least since charge-lnd v0.12.2 and some version of v0.14.x. It must have worked partially at some point in the past, since some channels are updated according to a previous version of the configuration file. Also, new channels I opened recently got updated to the current configuration; it seems as though older channels do not get updated properly. Furthermore, there is no specific strategy that is problematic; for instance, max_htlc_msat is not updated regardless of the strategy (be it either static, cost or match_peer). As for the macaroon file, it has info:read, offchain:read, offchain:write and onchain:read as permissions and is of version 2.

derlade avatar Jul 27 '22 07:07 derlade

The channel policy update seems to reach lnd correctly. Running lnd with debuglevel=trace doesn't reveal any errors:

2022-07-29 10:45:36.890 [DBG] RPCS: [updatechanpolicy] updating channel policy base_fee=1000, rate_fixed=10, time_lock_delta: 40, min_htlc=<nil>, max_htlc=500000000 mSAT, targets=([]wire.OutPoint) (len=1 cap=1) {
 (wire.OutPoint) XXX:1
}
2022-07-29 10:45:36.894 [TRC] DISC: Received channel 0 policy update requests
2022-07-29 10:45:36.894 [TRC] HSWC: Updating link policies: (map[wire.OutPoint]htlcswitch.ForwardingPolicy) {
}

I assume this might be a lnd issue then.

derlade avatar Jul 29 '22 08:07 derlade

Actually, I'm not sure if it's a lnd issue. Calling updatechanpolicy manually with the same parameters reveals the following output:

{
        "failed_updates": [
                {
                        "outpoint": "XXX:1",
                        "reason": "UPDATE_FAILURE_INVALID_PARAMETER",
                        "update_error": "max htlc size of 500000000 mSAT is above max pending amount of 495000000 mSAT"
                }
        ]
}

So it seems that the error doesn't get passed downstream correctly, at least the charge-lnd output doesn't reveal any errors. Changing max_htlc_msat to max_htlc_msat_ratio in the config solved the problem.

derlade avatar Jul 29 '22 09:07 derlade

Ah, yes. charge-lnd is using a bit older .proto interface definitions, where error responses are not yet added. I will update these, and add error checking and reporting, once I have some time.

accumulator avatar Jul 29 '22 10:07 accumulator