lightningd: remove #if DEVELOPER.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-09-21 15:06:28 +09:30
parent f725edad62
commit 3e124d9ec1
27 changed files with 118 additions and 197 deletions

View File

@ -1011,12 +1011,11 @@ void channel_internal_error(struct channel *channel, const char *fmt, ...)
}
/* Don't expose internal error causes to remove unless doing dev */
#if DEVELOPER
channel_fail_permanent(channel,
REASON_LOCAL, "Internal error: %s", why);
#else
channel_fail_permanent(channel, REASON_LOCAL, "Internal error");
#endif
if (channel->peer->ld->developer)
channel_fail_permanent(channel,
REASON_LOCAL, "Internal error: %s", why);
else
channel_fail_permanent(channel, REASON_LOCAL, "Internal error");
tal_free(why);
}
@ -1046,14 +1045,13 @@ static void channel_err(struct channel *channel, const char *why)
log_info(channel->log, "Peer transient failure in %s: %s",
channel_state_name(channel), why);
#if DEVELOPER
if (dev_disconnect_permanent(channel->peer->ld)) {
channel_fail_permanent(channel,
REASON_LOCAL,
"dev_disconnect permfail");
return;
}
#endif
channel_set_owner(channel, NULL);
}

View File

@ -1482,11 +1482,10 @@ bool peer_start_channeld(struct channel *channel,
remote_ann_node_sig,
remote_ann_bitcoin_sig,
channel->type,
IFDEV(ld->dev_fast_gossip, false),
IFDEV(ld->dev_disable_commit == -1
ld->dev_fast_gossip,
ld->dev_disable_commit == -1
? NULL
: (u32 *)&ld->dev_disable_commit,
NULL),
pbases,
reestablish_only,
channel->channel_update,
@ -1640,7 +1639,12 @@ is_fundee_should_forget(struct lightningd *ld,
* - SHOULD forget the channel if it does not see the
* correct funding transaction after a timeout of 2016 blocks.
*/
u32 max_funding_unconfirmed = IFDEV(ld->dev_max_funding_unconfirmed, 2016);
u32 max_funding_unconfirmed;
if (ld->developer)
max_funding_unconfirmed = ld->dev_max_funding_unconfirmed;
else
max_funding_unconfirmed = 2016;
/* Only applies if we are fundee. */
if (channel->opener == LOCAL)
@ -2084,7 +2088,6 @@ static const struct json_command splice_signed_command = {
};
AUTODATA(json_command, &splice_signed_command);
#if DEVELOPER
static struct command_result *json_dev_feerate(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -2190,4 +2193,3 @@ static const struct json_command dev_quiesce_command = {
.dev_only = true,
};
AUTODATA(json_command, &dev_quiesce_command);
#endif /* DEVELOPER */

View File

@ -390,8 +390,7 @@ void try_reconnect(const tal_t *ctx,
/* Did we last attempt to connect recently? Enter backoff mode. */
if (time_less(time_between(time_now(), peer->last_connect_attempt),
time_from_sec(MAX_WAIT_SECONDS * 2))) {
u32 max = DEV_FAST_RECONNECT(peer->ld->dev_fast_reconnect,
3, MAX_WAIT_SECONDS);
u32 max = peer->ld->dev_fast_reconnect ? 3 : MAX_WAIT_SECONDS;
peer->reconnect_delay *= 2;
if (peer->reconnect_delay > max)
peer->reconnect_delay = max;
@ -666,11 +665,9 @@ int connectd_init(struct lightningd *ld)
ld->connectd = new_global_subd(ld, "lightning_connectd",
connectd_wire_name, connectd_msg,
take(&hsmfd), take(&fds[1]),
#if DEVELOPER
/* Not take(): we share it */
ld->dev_disconnect_fd >= 0 ?
&ld->dev_disconnect_fd : NULL,
#endif
NULL);
if (!ld->connectd)
err(1, "Could not subdaemon connectd");
@ -694,15 +691,15 @@ int connectd_init(struct lightningd *ld)
wireaddrs,
listen_announce,
ld->proxyaddr, ld->always_use_proxy || ld->pure_tor_setup,
IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
ld->dev_allow_localhost, ld->config.use_dns,
ld->tor_service_password ? ld->tor_service_password : "",
ld->config.connection_timeout_secs,
websocket_helper_path,
ld->websocket_port,
!ld->deprecated_apis,
IFDEV(ld->dev_fast_gossip, false),
IFDEV(ld->dev_disconnect_fd >= 0, false),
IFDEV(ld->dev_no_ping_timer, false));
ld->dev_fast_gossip,
ld->dev_disconnect_fd >= 0,
ld->dev_no_ping_timer);
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_init_done, NULL);
@ -824,7 +821,6 @@ static const struct json_command sendcustommsg_command = {
AUTODATA(json_command, &sendcustommsg_command);
#if DEVELOPER
static struct command_result *json_dev_suppress_gossip(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -870,4 +866,3 @@ static const struct json_command dev_report_fds = {
.dev_only = true,
};
AUTODATA(json_command, &dev_report_fds);
#endif /* DEVELOPER */

View File

@ -10,10 +10,6 @@ struct peer;
struct pubkey;
struct wireaddr_internal;
/* Speedy reconnect timeout! */
#define DEV_FAST_RECONNECT(dev_fast_reconnect_flag, fast, normal) \
IFDEV((dev_fast_reconnect_flag) ? (fast) : (normal), (normal))
/* Returns fd for gossipd to talk to connectd */
int connectd_init(struct lightningd *ld);
void connectd_activate(struct lightningd *ld);

View File

@ -3397,7 +3397,6 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
return 0;
}
#if DEVELOPER
static struct command_result *json_queryrates(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -3543,7 +3542,6 @@ static const struct json_command queryrates_command = {
};
AUTODATA(json_command, &queryrates_command);
#endif /* DEVELOPER */
static const struct json_command openchannel_init_command = {
"openchannel_init",

View File

@ -290,9 +290,9 @@ void gossip_init(struct lightningd *ld, int connectd_fd)
ld->rgb,
ld->alias,
ld->announceable,
IFDEV(ld->dev_gossip_time ? &ld->dev_gossip_time: NULL, NULL),
IFDEV(ld->dev_fast_gossip, false),
IFDEV(ld->dev_fast_gossip_prune, false),
ld->dev_gossip_time ? &ld->dev_gossip_time: NULL,
ld->dev_fast_gossip,
ld->dev_fast_gossip_prune,
ld->config.ip_discovery);
subd_req(ld->gossip, ld->gossip, take(msg), -1, 0,
@ -535,7 +535,6 @@ static const struct json_command addgossip_command = {
};
AUTODATA(json_command, &addgossip_command);
#if DEVELOPER
static struct command_result *
json_dev_set_max_scids_encode_size(struct command *cmd,
const char *buffer,
@ -636,4 +635,3 @@ static const struct json_command dev_gossip_set_time = {
.dev_only = true,
};
AUTODATA(json_command, &dev_gossip_set_time);
#endif /* DEVELOPER */

View File

@ -114,13 +114,13 @@ struct ext_key *hsm_init(struct lightningd *ld)
ld->hsm_fd = fds[0];
if (!wire_sync_write(ld->hsm_fd, towire_hsmd_init(tmpctx,
&chainparams->bip32_key_version,
chainparams,
ld->config.keypass,
IFDEV(ld->dev_force_privkey, NULL),
IFDEV(ld->dev_force_bip32_seed, NULL),
IFDEV(ld->dev_force_channel_secrets, NULL),
IFDEV(ld->dev_force_channel_secrets_shaseed, NULL),
&chainparams->bip32_key_version,
chainparams,
ld->config.keypass,
ld->dev_force_privkey,
ld->dev_force_bip32_seed,
ld->dev_force_channel_secrets,
ld->dev_force_channel_secrets_shaseed,
HSM_MIN_VERSION,
HSM_MAX_VERSION)))
err(EXITCODE_HSM_GENERIC_ERROR, "Writing init msg to hsm");

View File

@ -175,7 +175,6 @@ struct invoice_payment_hook_payload {
/* FIXME: Include raw payload! */
};
#ifdef DEVELOPER
static void invoice_payment_add_tlvs(struct json_stream *stream,
struct htlc_set *hset)
{
@ -203,7 +202,6 @@ static void invoice_payment_add_tlvs(struct json_stream *stream,
}
json_array_end(stream);
}
#endif
static void
invoice_payment_serialize(struct invoice_payment_hook_payload *payload,
@ -216,9 +214,9 @@ invoice_payment_serialize(struct invoice_payment_hook_payload *payload,
json_add_string(stream, "msat",
type_to_string(tmpctx, struct amount_msat,
&payload->msat));
#ifdef DEVELOPER
invoice_payment_add_tlvs(stream, payload->set);
#endif
if (payload->ld->developer)
invoice_payment_add_tlvs(stream, payload->set);
json_object_end(stream); /* .payment */
}
@ -948,7 +946,6 @@ static void listincoming_done(const char *buffer,
db_commit_transaction(ld->wallet->db);
}
#if DEVELOPER
/* Since this is a dev-only option, we will crash if dev-routes is not
* an array-of-arrays-of-correct-items. */
static struct route_info *unpack_route(const tal_t *ctx,
@ -1002,7 +999,6 @@ static struct route_info **unpack_routes(const tal_t *ctx,
return routes;
}
#endif /* DEVELOPER */
static struct command_result *param_positive_msat_or_any(struct command *cmd,
const char *name,
@ -1098,9 +1094,7 @@ static struct command_result *json_invoice(struct command *cmd,
struct plugin *plugin;
bool *hashonly;
const size_t inv_max_label_len = 128;
#if DEVELOPER
const jsmntok_t *routes;
#endif
const jsmntok_t *dev_routes;
info = tal(cmd, struct invoice_info);
info->cmd = cmd;
@ -1117,12 +1111,14 @@ static struct command_result *json_invoice(struct command *cmd,
p_opt_def("cltv", param_number, &cltv,
cmd->ld->config.cltv_final),
p_opt_def("deschashonly", param_bool, &hashonly, false),
#if DEVELOPER
p_opt("dev-routes", param_array, &routes),
#endif
p_opt("dev-routes", param_array, &dev_routes),
NULL))
return command_param_failed();
if (dev_routes && !cmd->ld->developer)
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"dev-routes requires --developer");
if (strlen(info->label->s) > inv_max_label_len) {
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"Label '%s' over %zu bytes", info->label->s, inv_max_label_len);
@ -1188,11 +1184,8 @@ static struct command_result *json_invoice(struct command *cmd,
cmd->ld->our_features
->bits[BOLT11_FEATURE]);
#if DEVELOPER
info->b11->routes = unpack_routes(info->b11, buffer, routes);
#else
info->b11->routes = NULL;
#endif
info->b11->routes = unpack_routes(info->b11, buffer, dev_routes);
if (fallback_scripts)
info->b11->fallbacks = tal_steal(info->b11, fallback_scripts);

View File

@ -230,7 +230,6 @@ static const struct json_command stop_command = {
};
AUTODATA(json_command, &stop_command);
#if DEVELOPER
struct slowcmd {
struct command *cmd;
unsigned *msec;
@ -314,7 +313,6 @@ static const struct json_command dev_command = {
.dev_only = true,
};
AUTODATA(json_command, &dev_command);
#endif /* DEVELOPER */
static size_t num_cmdlist;

View File

@ -117,11 +117,10 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
/* They can turn this on with --developer */
ld->developer = IFDEV(true, false);
/*~ Note that we generally EXPLICITLY #if-wrap DEVELOPER code. This
* is a nod to keeping it minimal and explicit: we need this code for
* testing, but its existence means we're not actually testing the
* same exact code users will be running. */
#if DEVELOPER
/*~ We used to EXPLICITLY #if-wrap DEVELOPER code, but as our test
* matrix grew, we turned them into a --developer runtime option.
* We still use the `dev` prefix everywhere to make the developer-
* only variations explicit though. */
ld->dev_debug_subprocess = NULL;
ld->dev_no_plugin_checksum = false;
ld->dev_disconnect_fd = -1;
@ -142,7 +141,6 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
ld->dev_ignore_modern_onion = false;
ld->dev_disable_commit = -1;
ld->dev_no_ping_timer = false;
#endif
/*~ This is a CCAN list: an embedded double-linked list. It's not
* really typesafe, but relies on convention to access the contents.
@ -1096,12 +1094,11 @@ int main(int argc, char *argv[])
pidfile_create(ld);
/*~ Make sure we can reach the subdaemons, and versions match.
* This can be turned off in DEVELOPER builds with --dev-skip-version-checks,
* but the `dev_no_version_checks` field of `ld` doesn't even exist
* if DEVELOPER isn't defined, so we use IFDEV(devoption,non-devoption):
*/
* This can be turned off with --dev-skip-version-checks,
* which can only be set after --developer.
*/
trace_span_start("test_subdaemons", ld);
if (IFDEV(!ld->dev_no_version_checks, 1))
if (!ld->dev_no_version_checks)
test_subdaemons(ld);
trace_span_end(ld);

View File

@ -280,7 +280,6 @@ struct lightningd {
/* Contains the codex32 string used with --recover flag */
char *recover;
#if DEVELOPER
/* If we want to debug a subdaemon/plugin. */
char *dev_debug_subprocess;
@ -336,7 +335,6 @@ struct lightningd {
/* Tell channeld not to worry about pings. */
bool dev_no_ping_timer;
#endif /* DEVELOPER */
/* tor support */
struct wireaddr *proxyaddr;

View File

@ -1,6 +1,5 @@
/* Only possible if we're in developer mode. */
#include "config.h"
#if DEVELOPER
#include <backtrace.h>
#include <ccan/tal/str/str.h>
#include <common/json_command.h>
@ -313,4 +312,3 @@ static const struct json_command dev_memleak_command = {
.dev_only = true,
};
AUTODATA(json_command, &dev_memleak_command);
#endif /* DEVELOPER */

View File

@ -341,12 +341,12 @@ static struct command_result *param_b12_invreq(struct command *cmd,
cmd->ld->our_features, chainparams, &fail);
if (!*invreq)
return command_fail_badparam(cmd, name, buffer, tok, fail);
#if !DEVELOPER
/* We use this for testing with known payer_info */
if ((*invreq)->invreq_metadata)
if ((*invreq)->invreq_metadata && !cmd->ld->developer)
return command_fail_badparam(cmd, name, buffer, tok,
"must not have invreq_metadata");
#endif
if ((*invreq)->invreq_payer_id)
return command_fail_badparam(cmd, name, buffer, tok,
"must not have invreq_payer_id");

View File

@ -119,10 +119,8 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
return;
}
#if DEVELOPER
if (ld->dev_ignore_modern_onion)
return;
#endif
submsglen = tal_bytelen(submsg);
subptr = submsg;

View File

@ -978,7 +978,7 @@ bool peer_start_openingd(struct peer *peer, struct peer_fd *peer_fd)
&uc->local_funding_pubkey,
uc->minimum_depth,
minrate, maxrate,
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
peer->ld->dev_force_tmp_channel_id,
peer->ld->config.allowdustreserve);
subd_send_msg(uc->open_daemon, take(msg));
return true;

View File

@ -656,7 +656,6 @@ static char *opt_set_hsm_password(struct lightningd *ld)
return NULL;
}
#if DEVELOPER
static char *opt_force_privkey(const char *optarg, struct lightningd *ld)
{
tal_free(ld->dev_force_privkey);
@ -887,7 +886,6 @@ static void dev_register_opts(struct lightningd *ld)
&ld->config.allowdustreserve,
"If true, we allow the `fundchannel` RPC command and the `openchannel` plugin hook to set a reserve that is below the dust limit.");
}
#endif /* DEVELOPER */
static const struct config testnet_config = {
/* 6 blocks to catch cheating attempts. */
@ -1585,9 +1583,7 @@ static void register_opts(struct lightningd *ld)
"Set to true to allow database upgrades even on non-final releases (WARNING: you won't be able to downgrade!)");
opt_register_logging(ld);
#if DEVELOPER
dev_register_opts(ld);
#endif
}
/* We are in ld->config_netdir when this is run! */
@ -1691,15 +1687,16 @@ void setup_color_and_alias(struct lightningd *ld)
name = tal_fmt(ld, "%s%s",
codename_adjective[adjective],
codename_noun[noun]);
#if DEVELOPER
assert(strlen(name) < 32);
int taillen = 31 - strlen(name);
if (taillen > strlen(version()))
taillen = strlen(version());
/* Fit as much of end of version() as possible */
tal_append_fmt(&name, "-%s",
version() + strlen(version()) - taillen);
#endif
if (ld->developer) {
assert(strlen(name) < 32);
int taillen = 31 - strlen(name);
if (taillen > strlen(version()))
taillen = strlen(version());
/* Fit as much of end of version() as possible */
tal_append_fmt(&name, "-%s",
version() + strlen(version()) - taillen);
}
assert(strlen(name) <= 32);
ld->alias = tal_arrz(ld, u8, 33);
strcpy((char*)ld->alias, name);
@ -2041,10 +2038,6 @@ void add_config_deprecated(struct lightningd *ld,
tal_append_fmt(&answer, ",%"PRIu64,
ld->accept_extra_tlv_types[i]);
}
#if DEVELOPER
} else if (strstarts(name, "dev-")) {
/* Ignore dev settings */
#endif
}
/* We ignore future additions, since these are deprecated anyway! */
}
@ -2074,13 +2067,10 @@ bool is_known_opt_cb_arg(char *(*cb_arg)(const char *, void *))
|| cb_arg == (void *)arg_log_to_file
|| cb_arg == (void *)opt_add_accept_htlc_tlv
|| cb_arg == (void *)opt_set_codex32
#if DEVELOPER
|| cb_arg == (void *)opt_subd_dev_disconnect
|| cb_arg == (void *)opt_force_featureset
|| cb_arg == (void *)opt_force_privkey
|| cb_arg == (void *)opt_force_bip32_seed
|| cb_arg == (void *)opt_force_channel_secrets
|| cb_arg == (void *)opt_force_tmp_channel_id
#endif
;
|| cb_arg == (void *)opt_force_tmp_channel_id;
}

View File

@ -111,9 +111,7 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
else
peer->their_features = NULL;
#if DEVELOPER
peer->ignore_htlcs = false;
#endif
peer->dev_ignore_htlcs = false;
peer_node_id_map_add(ld->peers, peer);
if (dbid)
@ -1266,7 +1264,6 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
/* Notify anyone who cares */
notify_connect(ld, &peer->id, payload->incoming, &addr);
#if DEVELOPER
/* Developer hack to fail all channels on permfail line. */
if (dev_disconnect_permanent(ld)) {
list_for_each(&peer->channels, channel, list) {
@ -1279,7 +1276,6 @@ static void peer_connected_hook_final(struct peer_connected_hook_payload *payloa
}
return;
}
#endif
/* connect appropriate subds for all (active) channels! */
list_for_each(&peer->channels, channel, list) {
@ -2918,7 +2914,6 @@ static const struct json_command setchannel_command = {
};
AUTODATA(json_command, &setchannel_command);
#if DEVELOPER
static struct command_result *json_sign_last_tx(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -3294,4 +3289,3 @@ void peer_dev_memleak(struct lightningd *ld, struct leak_detect *leaks)
}
}
}
#endif /* DEVELOPER */

View File

@ -62,10 +62,8 @@ struct peer {
/* If we open a channel our direction will be this */
u8 direction;
#if DEVELOPER
/* Swallow incoming HTLCs (for testing) */
bool ignore_htlcs;
#endif
bool dev_ignore_htlcs;
};
struct peer *find_peer_by_dbid(struct lightningd *ld, u64 dbid);
@ -134,10 +132,8 @@ struct amount_msat channel_amount_receivable(const struct channel *channel);
* Returns any HTLCs we have to resubmit via htlcs_resubmit. */
struct htlc_in_map *load_channels_from_wallet(struct lightningd *ld);
#if DEVELOPER
struct leak_detect;
void peer_dev_memleak(struct lightningd *ld, struct leak_detect *leaks);
#endif /* DEVELOPER */
/* Triggered at each new block. */
void waitblockheight_notify_new_block(struct lightningd *ld,

View File

@ -648,7 +648,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
tal_add_destructor(*houtp, destroy_hout_subd_died);
/* Give channel 30 seconds to commit this htlc. */
if (!IFDEV(out->peer->ld->dev_no_htlc_timeout, 0)) {
if (!out->peer->ld->dev_no_htlc_timeout) {
(*houtp)->timeout = new_reltimer(out->peer->ld->timers,
*houtp, time_from_sec(30),
htlc_offer_timeout,
@ -1338,13 +1338,12 @@ static bool peer_accepted_htlc(const tal_t *ctx,
htlc_in_check(hin, __func__);
#if DEVELOPER
if (channel->peer->ignore_htlcs) {
if (channel->peer->dev_ignore_htlcs) {
log_debug(channel->log, "their htlc %"PRIu64" dev_ignore_htlcs",
id);
return true;
}
#endif
/* BOLT #2:
*
* - SHOULD fail to route any HTLC added after it has sent `shutdown`.
@ -2956,7 +2955,6 @@ void htlcs_resubmit(struct lightningd *ld,
tal_free(unconnected_htlcs_in);
}
#if DEVELOPER
static struct command_result *json_dev_ignore_htlcs(struct command *cmd,
const char *buffer,
const jsmntok_t *obj UNNEEDED,
@ -2977,7 +2975,7 @@ static struct command_result *json_dev_ignore_htlcs(struct command *cmd,
return command_fail(cmd, LIGHTNINGD,
"Could not find channel with that peer");
}
peer->ignore_htlcs = *ignore;
peer->dev_ignore_htlcs = *ignore;
return command_success(cmd, json_stream_success(cmd));
}
@ -2991,7 +2989,6 @@ static const struct json_command dev_ignore_htlcs = {
};
AUTODATA(json_command, &dev_ignore_htlcs);
#endif /* DEVELOPER */
/* Warp this process to ensure the consistent json object structure
* between 'listforwards' API and 'forward_event' notification. */

View File

@ -81,9 +81,7 @@ struct plugins *plugins_new(const tal_t *ctx, struct log_book *log_book,
p->plugin_cmds = tal_arr(p, struct plugin_command *, 0);
p->blacklist = tal_arr(p, const char *, 0);
p->plugin_idx = 0;
#if DEVELOPER
p->dev_builtin_plugins_unimportant = false;
#endif /* DEVELOPER */
strmap_init(&p->pending_requests);
memleak_add_helper(p, memleak_help_pending_requests);
@ -240,7 +238,7 @@ static u32 file_checksum(struct lightningd *ld, const char *path)
{
char *content;
if (IFDEV(ld->dev_no_plugin_checksum, false))
if (ld->dev_no_plugin_checksum)
return 0;
content = grab_file(tmpctx, path);
@ -1473,7 +1471,8 @@ static const char *plugin_add_params(const struct plugin *plugin)
tal_arr_expand(&plugin->plugins->ld->configvars, cv);
/* If this fails, we free plugin and unregister the configvar */
err = configvar_parse(cv, false, true, IFDEV(true, false));
err = configvar_parse(cv, false, true,
plugin->plugins->ld->developer);
if (err)
return err;
}
@ -1789,18 +1788,17 @@ void plugins_add_default_dir(struct plugins *plugins)
}
}
static bool debugging(struct plugin *p)
{
if (p->plugins->ld->dev_debug_subprocess == NULL)
return false;
return strends(p->cmd, p->plugins->ld->dev_debug_subprocess);
}
static void plugin_set_timeout(struct plugin *p)
{
bool debug = false;
#if DEVELOPER
if (p->plugins->ld->dev_debug_subprocess
&& strends(p->cmd, p->plugins->ld->dev_debug_subprocess))
debug = true;
#endif
/* Don't timeout if they're running a debugger. */
if (debug)
if (debugging(p))
p->timeout_timer = NULL;
else {
p->timeout_timer
@ -1815,16 +1813,10 @@ const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id)
char **cmd;
int stdinfd, stdoutfd;
struct jsonrpc_request *req;
bool debug = false;
#if DEVELOPER
if (p->plugins->ld->dev_debug_subprocess
&& strends(p->cmd, p->plugins->ld->dev_debug_subprocess))
debug = true;
#endif
cmd = tal_arr(tmpctx, char *, 1);
cmd[0] = p->cmd;
if (debug)
if (debugging(p))
tal_arr_expand(&cmd, "--debugger");
if (p->plugins->ld->developer)
tal_arr_expand(&cmd, "--developer");
@ -1883,7 +1875,6 @@ void plugins_init(struct plugins *plugins)
plugins->default_dir = path_join(plugins, plugins->ld->config_basedir, "plugins");
plugins_add_default_dir(plugins);
#if DEVELOPER
if (plugins->dev_builtin_plugins_unimportant) {
size_t i;
@ -1902,7 +1893,6 @@ void plugins_init(struct plugins *plugins)
}
}
}
#endif /* DEVELOPER */
setenv("LIGHTNINGD_PLUGIN", "1", 1);
setenv("LIGHTNINGD_VERSION", version(), 1);

View File

@ -118,10 +118,8 @@ struct plugins {
/* Index to show what order they were added in */
u64 plugin_idx;
#if DEVELOPER
/* Whether builtin plugins should be overridden as unimportant. */
bool dev_builtin_plugins_unimportant;
#endif /* DEVELOPER */
};
/**

View File

@ -66,13 +66,11 @@ const char *rune_is_ours(struct lightningd *ld, const struct rune *rune)
return rune_is_derived(ld->runes->master, rune);
}
#if DEVELOPER
static void memleak_help_usage_table(struct htable *memtable,
struct usage_table *usage_table)
{
memleak_scan_htable(memtable, &usage_table->raw);
}
#endif /* DEVELOPER */
/* Every minute we forget entries. */
static void flush_usage_table(struct runes *runes)

View File

@ -200,7 +200,7 @@ static void close_taken_fds(va_list *ap)
/* We use sockets, not pipes, because fds are bidir. */
static int subd(const char *path, const char *name,
const char *debug_subdaemon,
bool debugging,
int *msgfd,
bool io_logging,
bool developer,
@ -257,10 +257,8 @@ static int subd(const char *path, const char *name,
args[num_args++] = tal_strdup(NULL, path);
if (io_logging)
args[num_args++] = "--log-io";
#if DEVELOPER
if (debug_subdaemon && strends(name, debug_subdaemon))
if (debugging)
args[num_args++] = "--debugger";
#endif
if (developer)
args[num_args++] = "--developer";
execv(args[0], args);
@ -378,10 +376,8 @@ static void subdaemon_malformed_msg(struct subd *sd, const u8 *msg)
fromwire_peektype(msg),
tal_hex(msg, msg));
#if DEVELOPER
if (sd->ld->dev_subdaemon_fail)
exit(1);
#endif
}
static bool log_status_fail(struct subd *sd, const u8 *msg)
@ -413,10 +409,9 @@ static bool log_status_fail(struct subd *sd, const u8 *msg)
log_broken(sd->log, "%s: %s", name, desc);
#if DEVELOPER
if (sd->ld->dev_subdaemon_fail)
exit(1);
#endif
return true;
}
@ -595,7 +590,7 @@ static void destroy_subd(struct subd *sd)
int status;
bool fail_if_subd_fails;
fail_if_subd_fails = IFDEV(sd->ld->dev_subdaemon_fail, false);
fail_if_subd_fails = sd->ld->dev_subdaemon_fail;
list_del_from(&sd->ld->subds, &sd->list);
/* lightningd may have already done waitpid() */
@ -694,6 +689,13 @@ static struct io_plan *msg_setup(struct io_conn *conn, struct subd *sd)
msg_send_next(conn, sd));
}
static bool debugging(struct lightningd *ld, const char *name)
{
if (ld->dev_debug_subprocess == NULL)
return false;
return strends(name, ld->dev_debug_subprocess);
}
static struct subd *new_subd(const tal_t *ctx,
struct lightningd *ld,
const char *name,
@ -717,7 +719,6 @@ static struct subd *new_subd(const tal_t *ctx,
{
struct subd *sd = tal(ctx, struct subd);
int msg_fd;
const char *debug_subd = NULL;
const char *shortname;
assert(name != NULL);
@ -735,13 +736,9 @@ static struct subd *new_subd(const tal_t *ctx,
sd->log = new_logger(sd, ld->log_book, node_id, "%s", shortname);
}
#if DEVELOPER
debug_subd = ld->dev_debug_subprocess;
#endif /* DEVELOPER */
const char *path = subdaemon_path(tmpctx, ld, name);
sd->pid = subd(path, name, debug_subd,
sd->pid = subd(path, name, debugging(ld, name),
&msg_fd,
/* We only turn on subdaemon io logging if we're going
* to print it: too stressful otherwise! */
@ -933,7 +930,6 @@ void subd_release_channel(struct subd *owner, const void *channel)
}
}
#if DEVELOPER
char *opt_subd_dev_disconnect(const char *optarg, struct lightningd *ld)
{
ld->dev_disconnect_fd = open(optarg, O_RDONLY);
@ -965,7 +961,6 @@ bool dev_disconnect_permanent(struct lightningd *ld)
}
return false;
}
#endif /* DEVELOPER */
/* Ugly helper to get full pathname of the current binary. */
const char *find_my_abspath(const tal_t *ctx, const char *argv0)

View File

@ -235,9 +235,7 @@ const char *find_my_abspath(const tal_t *ctx, const char *argv0);
/* lightningd captures SIGCHLD and waits, but so does subd. */
void maybe_subd_child(struct lightningd *ld, int childpid, int wstatus);
#if DEVELOPER
char *opt_subd_dev_disconnect(const char *optarg, struct lightningd *ld);
bool dev_disconnect_permanent(struct lightningd *ld);
#endif /* DEVELOPER */
#endif /* LIGHTNING_LIGHTNINGD_SUBD_H */

View File

@ -198,6 +198,9 @@ void db_commit_transaction(struct db *db UNNEEDED)
/* Generated stub for delete_channel */
void delete_channel(struct channel *channel STEALS UNNEEDED)
{ fprintf(stderr, "delete_channel called!\n"); abort(); }
/* Generated stub for dev_disconnect_permanent */
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
/* Generated stub for encode_scriptpubkey_to_addr */
char *encode_scriptpubkey_to_addr(const tal_t *ctx UNNEEDED,
const struct chainparams *chainparams UNNEEDED,
@ -1015,12 +1018,6 @@ struct txowatch *watch_txo(const tal_t *ctx UNNEEDED,
{ fprintf(stderr, "watch_txo called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER
/* Generated stub for dev_disconnect_permanent */
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
#endif
static void add_candidate(struct routehint_candidate **candidates, int n,
struct channel *c)
{

View File

@ -144,6 +144,9 @@ struct onionreply *create_onionreply(const tal_t *ctx UNNEEDED,
void derive_channel_id(struct channel_id *channel_id UNNEEDED,
const struct bitcoin_outpoint *outpoint UNNEEDED)
{ fprintf(stderr, "derive_channel_id called!\n"); abort(); }
/* Generated stub for dev_disconnect_permanent */
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
/* Generated stub for ecdh */
void ecdh(const struct pubkey *point UNNEEDED, struct secret *ss UNNEEDED)
{ fprintf(stderr, "ecdh called!\n"); abort(); }
@ -912,11 +915,6 @@ struct onionreply *wrap_onionreply(const tal_t *ctx UNNEEDED,
{ fprintf(stderr, "wrap_onionreply called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */
#if DEVELOPER
bool dev_disconnect_permanent(struct lightningd *ld UNNEEDED)
{ fprintf(stderr, "dev_disconnect_permanent called!\n"); abort(); }
#endif
/* Fake stubs to talk to hsm */
u8 *towire_hsmd_get_channel_basepoints(const tal_t *ctx UNNEEDED, const struct node_id *peerid UNNEEDED, u64 dbid UNNEEDED)
{

View File

@ -3207,24 +3207,25 @@ void wallet_payment_store(struct wallet *wallet,
struct db_stmt *stmt;
if (!find_unstored_payment(wallet, &payment->payment_hash, payment->partid)) {
/* Already stored on-disk */
#if DEVELOPER
/* Double-check that it is indeed stored to disk
* (catch bug, where we call this on a payment_hash
* we never paid to) */
bool res;
stmt =
db_prepare_v2(wallet->db, SQL("SELECT status FROM payments"
" WHERE payment_hash=?"
" AND partid = ? AND groupid = ?;"));
db_bind_sha256(stmt, &payment->payment_hash);
db_bind_u64(stmt, payment->partid);
db_bind_u64(stmt, payment->groupid);
db_query_prepared(stmt);
res = db_step(stmt);
assert(res);
db_col_ignore(stmt, "status");
tal_free(stmt);
#endif
if (wallet->ld->developer) {
/* Double-check that it is indeed stored to disk
* (catch bug, where we call this on a payment_hash
* we never paid to) */
bool res;
stmt =
db_prepare_v2(wallet->db, SQL("SELECT status FROM payments"
" WHERE payment_hash=?"
" AND partid = ? AND groupid = ?;"));
db_bind_sha256(stmt, &payment->payment_hash);
db_bind_u64(stmt, payment->partid);
db_bind_u64(stmt, payment->groupid);
db_query_prepared(stmt);
res = db_step(stmt);
assert(res);
db_col_ignore(stmt, "status");
tal_free(stmt);
}
return;
}