plugin: Abort early if we have a misconfiguration in the plugins

We were reporting the failure immediately but still continuing with
the startup. This could happen if an important plugin ends up in a
race with another plugin (important or not) for a contended
resource (CLI option or RPC method name). We would eventually notice
that we were supposed to abort, but at that point we already processed
a couple of blocks, loaded the entire state, etc.

This just aborts early with a sane error message.

Changelog-Added: plugin: If there is a misconfiguration with important plugins we now abort early with a more descriptive error message.

Reported-by: PsySc0rpi0n
Reported-by: Ján Sáreník <@jsarenik>
This commit is contained in:
Christian Decker 2021-03-09 10:50:00 +01:00 committed by neil saitug
parent ba083c8869
commit e59940eb61

View File

@ -907,6 +907,16 @@ int main(int argc, char *argv[])
* options registration). */
plugins_init(ld->plugins);
/*~ If the plugis are misconfigured we don't want to proceed. A
* misconfiguration could for example be a plugin marked as important
* not working correctly or a plugin squatting something an important
* plugin needs to register, such as a method or CLI option. If we are
* going to shut down immediately again, we shouldn't spend too much
* effort in starting up.
*/
if (ld->exit_code)
fatal("Could not initialize the plugins, see above for details.");
/*~ Handle options and config. */
handle_opts(ld, argc, argv);