-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config changes #3268
Config changes #3268
Conversation
rustyrussell
commented
Nov 18, 2019
- Files now moved into bitcoin/testnet/regtest/etc subdir.
- Config file still parsed in old location, but also network/config is parsed
- Default for new installs in bitcoin, not testnet!
this breaks my current system clightning system service with: |
Another thing that is a bit confusing is lightning-cli now shows this message when clightning isn't running: |
Oops, this is a bug. Network should only be disallowed in the /config file. Should still be valid on the root config. |
0b891dd
to
b16fdf6
Compare
Thanks @jb55 ... and this time with tests! BTW, you can restore with |
hmm I was able to test it and the |
d2546ce
to
9188e0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a very painful upgrade, but honestly I don't see how we could make it less painful. Some general comments below:
- We have no recursion depth, so circular includes can result in endless
loops - Starting a node without a
--network
parameter may end up movingtestnet
files into thebitcoin
directory and treating them like mainnet.
The latter is really what bothers me, we are moving things around without really knowing what network the config is for, but I also don't see how we could avoid that without reading the DB chain and then comparing with the chainparams.
lightningd/options.c
Outdated
if (all_args[i] == NULL) | ||
continue; | ||
|
||
if (!strstarts(all_args[i], "--")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me think we should make the all_args
entries into a struct that carries a type with it. Something like this seems better for future extensibility:
enum ConfigLineType {
CONFIG_COMMENT,
CONFIG_ARGUMENT,
CONFIG_INCLUDE,
};
struct ConfigEntry {
ConfigLineType type;
char *line;
char *filename;
size_t pos;
};
It can also be used to reconstruct the config from the in-memory representation and provide nicer error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could help people keep testnet/mainnet nodes running at the same time, so overall I'm a fan.
The includes
capability is particularly nice.
As @cdecker mentioned, if we want to be super safe for the transition/upgrade path we could check the database for the chainhash. Not sure what our risk profile is though :)
common/configdir.c
Outdated
void parse_include(const char *filename, bool must_exist, bool early) | ||
{ | ||
char *contents, **lines; | ||
char **all_args; /*For each line: either argument string or NULL*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might also be a path to load for an includes
all_args = tal_arr_label(options_ctx, char *, tal_count(lines) - 1, | ||
TAL_LABEL(options_array_notleak, "")); | ||
|
||
for (i = 0; i < tal_count(lines) - 1; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this skip the last line because the tal_strsplit
above leaves the last line blank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It NULL-terminates the array, yes.
common/configdir.c
Outdated
config_basedir = base; | ||
|
||
/* If it doesn't exist, it's not testnet. */ | ||
if (stat(base, &st) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you might mean to be testing config_basedir
here?
} | ||
|
||
/* Does it have a bitcoin/ subdir and no testnet/ subdir? */ | ||
if (stat(path_join(base, config_basedir, "bitcoin"), &st) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i'll admit i'm a bit confused here. at L255 we might have set config_basedir
to be base
; in that case we'd be joining the same path twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First arg is context: we're not relying on tmpctx here, so I'm abusing base as a per-function ctx. Will comment :)
lightningd/options.c
Outdated
@@ -972,7 +974,7 @@ void handle_early_opts(struct lightningd *ld, int argc, char *argv[]) | |||
ld->config_netdir); | |||
|
|||
/* Set default PID file name to be per-network */ | |||
ld->pidfile = tal_fmt(ld, "lightningd-%s.pid", | |||
ld->pidfile = tal_fmt(ld, "../lightningd-%s.pid", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to change where 'custom set' lightning-directory PID files are located.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because they get parsed next.
However, this "../" is wrong (network/ may be a symlink): this code is left over from before I gave in and made basedir and netdir explicit. Will fix:
/* Set default PID file name to be per-network (in base dir) */
ld->pidfile = path_join(ld, ld->config_basedir,
tal_fmt(tmpctx, "lightningd-%s.pid",
chainparams->network_name));
'--lightning-dir={}'.format(l1.daemon.opts.get("lightning-dir"))], | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
assert out.returncode == 1 | ||
assert "lightning-dir: not permitted in implicit configuration files" in out.stderr.decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add test for PID location?
Yes, this I can fix quite easily.
That should not happen (unless they specify --allow-deprecated-apis=false): if nothing is specified, they get testnet on existing installs. I will add a test for this, however.
|
Doing so is amazingly ugly, since we need to plumb though a lot of code to get the db open early. So I chose the simpler approach of leaving existing installs as testnet by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 46e6b38
1337d51
to
8eb7eee
Compare
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Config: configuration files now support `include`.
…annel_start With coming changes, this will segfault if we access it when param code is trying to get usage from functions. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
lightning-cli is going to need to know what network we're on, so it will need to parse the config files. Move the code which does the initial bootstrap parsing into common, as well as the config file parsing core. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This lets you have a default, but also a network-specific config. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-changed: Options: `config` and <network>/`config` read by default.
…twork> subdir Changelog-changed: .lightningd plugins and files moved into <network>/ subdir Changelog-changed: WARNING: If you don't have a config file, you now may need to specify the network to lightning-cli Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We're going to want this for changing the default network. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-changed: Default network (new installs) is now bitcoin, not testnet. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1. "conf" can't be specified in a configuration file. 2. "lightning-dir" can't be specified in a configuration file unless the file was explicitly set with --conf=. 3. "network" options can't be set in a per-network configuration file. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
They're already qualified with network name, and there's little point moving them; it might even be dangerous if multiple are running. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Otherwise we don't print out the upgrading messages when we move things! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Don't spend too much effort on it, but this is better than running out of memory and crashing. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Do the same thing '--help' does with them; append `...`. Valgrind noticed that we weren't NUL-terminarting if answer was over 78 characters. Changelog-Fixed: JSONRPC: listconfigs appends '...' to truncated config options.
8eb7eee
to
e04199d
Compare
Trivial rebase to fold fixes. |
e04199d
to
ee79dee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ee79dee
I noticed a nit while testing though: Creating configuration [...] Moving [...] ...
would be shown two times when upgrading testnet old directories, but not regtest ones.
Yes, I can remove doubling in a separate patch, is a side effect of when we finally set up the log. Previously it was only for broken messages, which usually meant we exited before log setup anyway... |