Browse Source

common: add peer_error flag to treat this error as "soft".

The spec says to close the channel if they send us an error, but we
need to be more lenient to preserve channels with other
implementations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
pull/2938/head
Rusty Russell 5 years ago
parent
commit
dd79813a75
  1. 4
      common/peer_failed.c
  2. 2
      common/peer_status_wire.csv
  3. 1
      lightningd/invoice.c
  4. 1
      lightningd/onchain_control.c
  5. 1
      lightningd/opening_control.c
  6. 10
      lightningd/peer_control.c
  7. 1
      lightningd/peer_control.h
  8. 9
      lightningd/subd.c
  9. 4
      lightningd/subd.h
  10. 2
      lightningd/test/run-find_my_abspath.c

4
common/peer_failed.c

@ -42,7 +42,7 @@ void peer_failed(struct per_peer_state *pps,
/* Tell master the error so it can re-xmit. */
msg = towire_status_peer_error(NULL, channel_id,
desc, pps,
desc, false, pps,
err);
peer_billboard(true, desc);
tal_free(desc);
@ -59,7 +59,7 @@ void peer_failed_received_errmsg(struct per_peer_state *pps,
if (!channel_id)
channel_id = &all_channels;
msg = towire_status_peer_error(NULL, channel_id, desc, pps, NULL);
msg = towire_status_peer_error(NULL, channel_id, desc, false, pps, NULL);
peer_billboard(true, "Received error from peer: %s", desc);
peer_fatal_continue(take(msg), pps);
}

2
common/peer_status_wire.csv

@ -5,6 +5,8 @@ msgtype,status_peer_error,0xFFF4
# This is implied if error_for_them, but master tries not to parse packets.
msgdata,status_peer_error,channel,channel_id,
msgdata,status_peer_error,desc,wirestring,
# Take a deep breath, then try reconnecting to the precious little snowflake.
msgdata,status_peer_error,soft_error,bool,
msgdata,status_peer_error,pps,per_peer_state,
msgdata,status_peer_error,len,u16,
msgdata,status_peer_error,error_for_them,u8,len

Can't render this file because it has a wrong number of fields in line 3.

1
lightningd/invoice.c

@ -61,7 +61,6 @@ static void json_add_invoice(struct json_stream *response,
"amount_received_msat");
json_add_u64(response, "paid_at", inv->paid_timestamp);
}
if (inv->description)
json_add_string(response, "description", inv->description);

1
lightningd/onchain_control.c

@ -416,6 +416,7 @@ static void onchain_error(struct channel *channel,
struct per_peer_state *pps UNUSED,
const struct channel_id *channel_id UNUSED,
const char *desc,
bool soft_error UNUSED,
const u8 *err_for_them UNUSED)
{
/* FIXME: re-launch? */

1
lightningd/opening_control.c

@ -712,6 +712,7 @@ static void opening_channel_errmsg(struct uncommitted_channel *uc,
struct per_peer_state *pps,
const struct channel_id *channel_id UNUSED,
const char *desc,
bool soft_error UNUSED,
const u8 *err_for_them UNUSED)
{
/* Close fds, if any. */

10
lightningd/peer_control.c

@ -390,6 +390,7 @@ void channel_errmsg(struct channel *channel,
struct per_peer_state *pps,
const struct channel_id *channel_id UNUSED,
const char *desc,
bool soft_error,
const u8 *err_for_them)
{
notify_disconnect(channel->peer->ld, &channel->peer->id);
@ -407,6 +408,15 @@ void channel_errmsg(struct channel *channel,
err_for_them,
tal_count(err_for_them), 0);
/* Other implementations chose to ignore errors early on. Not
* surprisingly, they now spew out spurious errors frequently,
* and we would close the channel on them. */
if (soft_error) {
channel_fail_reconnect_later(channel, "%s: (ignoring) %s",
channel->owner->name, desc);
return;
}
/* BOLT #1:
*
* A sending node:

1
lightningd/peer_control.h

@ -78,6 +78,7 @@ void channel_errmsg(struct channel *channel,
struct per_peer_state *pps,
const struct channel_id *channel_id,
const char *desc,
bool soft_error,
const u8 *err_for_them);
u8 *p2wpkh_for_keyidx(const tal_t *ctx, struct lightningd *ld, u64 keyidx);

9
lightningd/subd.c

@ -370,9 +370,10 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[3])
char *desc;
struct per_peer_state *pps;
u8 *err_for_them;
bool soft_error;
if (!fromwire_status_peer_error(msg, msg,
&channel_id, &desc,
&channel_id, &desc, &soft_error,
&pps, &err_for_them))
return false;
@ -380,7 +381,7 @@ static bool handle_peer_error(struct subd *sd, const u8 *msg, int fds[3])
/* Don't free sd; we may be about to free channel. */
sd->channel = NULL;
sd->errcb(channel, pps, &channel_id, desc, err_for_them);
sd->errcb(channel, pps, &channel_id, desc, soft_error, err_for_them);
return true;
}
@ -561,7 +562,7 @@ static void destroy_subd(struct subd *sd)
sd->errcb(channel, NULL, NULL,
tal_fmt(sd, "Owning subdaemon %s died (%i)",
sd->name, status),
NULL);
false, NULL);
if (!outer_transaction)
db_commit_transaction(db);
}
@ -611,6 +612,7 @@ static struct subd *new_subd(struct lightningd *ld,
struct per_peer_state *pps,
const struct channel_id *channel_id,
const char *desc,
bool soft_error,
const u8 *err_for_them),
void (*billboardcb)(void *channel,
bool perm,
@ -701,6 +703,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
struct per_peer_state *pps,
const struct channel_id *channel_id,
const char *desc,
bool soft_error,
const u8 *err_for_them),
void (*billboardcb)(void *channel, bool perm,
const char *happenings),

4
lightningd/subd.h

@ -46,6 +46,7 @@ struct subd {
struct per_peer_state *pps,
const struct channel_id *channel_id,
const char *desc,
bool soft_error,
const u8 *err_for_them);
/* Callback to display information for listpeers RPC */
@ -120,6 +121,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
struct per_peer_state *pps,
const struct channel_id *channel_id,
const char *desc,
bool soft_error,
const u8 *err_for_them),
void (*billboardcb)(void *channel, bool perm,
const char *happenings),
@ -133,7 +135,7 @@ struct subd *new_channel_subd_(struct lightningd *ld,
(channel), \
struct per_peer_state *, \
const struct channel_id *, \
const char *, const u8 *), \
const char *, bool, const u8 *), \
typesafe_cb_postargs(void, void *, (billboardcb), \
(channel), bool, \
const char *), \

2
lightningd/test/run-find_my_abspath.c

@ -73,7 +73,7 @@ bool fromwire_status_fail(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, enu
bool fromwire_status_peer_billboard(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, bool *perm UNNEEDED, wirestring **happenings UNNEEDED)
{ fprintf(stderr, "fromwire_status_peer_billboard called!\n"); abort(); }
/* Generated stub for fromwire_status_peer_error */
bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED)
bool fromwire_status_peer_error(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct channel_id *channel UNNEEDED, wirestring **desc UNNEEDED, bool *soft_error UNNEEDED, struct per_peer_state **pps UNNEEDED, u8 **error_for_them UNNEEDED)
{ fprintf(stderr, "fromwire_status_peer_error called!\n"); abort(); }
/* Generated stub for get_log_book */
struct log_book *get_log_book(const struct log *log UNNEEDED)

Loading…
Cancel
Save