Skip to content

askrene/downgrade/offers: dead code and doc cleanups from #9150 #9378

Description

@nGoline

Cosmetic follow-ups from #9150, none functional.

Dead code

  • tools/lightning-downgrade.c:56,133,151: both wrappers pass convert_impression = true, so the if (!convert_impression) copy_data(...) branch is unreachable. The name also reads backwards, true means drop, not convert. Drop the parameter or rename to drop_impressions.
  • lightningd/offer.c:380,451: prev_basetime is no longer assigned after prev_payment() was removed, so if (prev_basetime) json_add_u64(response, "previous_basetime", ...) is dead.
  • plugins/askrene/datastore_wire.c: fromwire_dstore_channel_impression() takes const tal_t *ctx and never uses it, unlike fromwire_dstore_channel_bias() which needs it for the string. Drop it or mark UNUSED.

Robustness

  • plugins/askrene/layer.c:1214: layer_trim_constraints() counts old entries with continue, but relies on the array being timestamp-sorted, then does tal_arr_remove_range(&intelarr, 0, count_old). If the array is ever unsorted the two disagree, and entries already stolen to tmpctx stay referenced from the array. break matches the documented assumption and fails safe.
  • plugins/libplugin.c:346: json_id() blanks method when prefix needs escaping, leaving the unsafe prefix in the id. Unreachable today, every id a plugin sees is lightningd-generated and sanitized, and method is a compile-time literal at every call site. Fix is prefix = "!weird!".
  • plugins/offers_invreq_hook.c:793: until = *offer_absolute_expiry - *invoice_created_at underflows if the offer already expired. Safe only because listoffers_done rejects expired offers first, which is an ordering assumption. A > guard on the subtraction, plus clamping the result to at least 1, would remove the dependency. Relevant because createinvoice_error treats invoice_relative_expiry == 0 as "cancelled".

Style

  • plugins/askrene/layer.c:1142,1144: AMOUNT_MSAT(-1ULL), use AMOUNT_MSAT(UINT64_MAX) as add_constraint() does.
  • plugins/askrene/layer.c:1223: if(count_old){.
  • plugins/askrene/layer.c:1142,1144: AMOUNT_MSAT(-1ULL), use AMOUNT_MSAT(UINT64_MAX) as add_constraint() does.
  • plugins/askrene/layer.c:1223: if(count_old){.
  • common/utils.c:150: // p is a pointer-to-pointer for tal_resize. uses //, codebase uses /* */. The tal_arr_remove_range header doc says "Remove a range of element".

Docs

  • doc/schemas/askrene-age.json: num_removed is described as "The number of constraints removed from layer", it now counts impressions too.
  • doc/schemas/askrene-listlayers.json, askrene-create-layer.json, askrene-inform-channel.json: impressions[].timestamp description is copy-pasted as "The UNIX timestamp when this constraint was created."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions