Skip to content
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

libplugin: use json stream helpers and add sanity tests #3480

Merged
merged 10 commits into from
Feb 9, 2020

Conversation

darosior
Copy link
Collaborator

@darosior darosior commented Feb 1, 2020

This is a follow-up to #3443 (based on it and implements the first of the left TODOs).

This moves all plugins from "raw" jouts to using higher-level json_stream helpers.
This also adds sanity functional tests for libplugin plugins, which uncovered a bug.

@darosior
Copy link
Collaborator Author

darosior commented Feb 1, 2020

Rebased after #3443 rebase.

@darosior darosior force-pushed the libplugin_json_stream branch 6 times, most recently from fc74bef to 66c0ae3 Compare February 2, 2020 13:15
@darosior
Copy link
Collaborator Author

darosior commented Feb 2, 2020

Re-rebased :)

plugins/libplugin.c Outdated Show resolved Hide resolved
@darosior
Copy link
Collaborator Author

darosior commented Feb 3, 2020

I'm not really happy with the read after free fix, if there are suggestions..

@rustyrussell
Copy link
Contributor

I'm not really happy with the read after free fix, if there are suggestions..

The "technically correct" answer is to create the infrastructure to unregister options in ccan/opt. To do anything else risks duplicate options in the option table as we remove then re-add a plugin.

Let me create that now...

@darosior darosior force-pushed the libplugin_json_stream branch 3 times, most recently from b5f41a9 to 9746a94 Compare February 4, 2020 23:04
darosior and others added 9 commits February 5, 2020 09:43
The usual json_stream starters and command_result enders.
This adds helpers to start and send a jsonrpc request using json_stream
in order to benefit from the helpers.

This then simplifies existing plugins RPC requests by using json_stream
helpers.
We mark the test as xfail() as it exposes that libplugin's PLUGIN_RESTARTABLE
was not taken into account !
As a separated commit because it was pre-existent (changelog + xfail test).

This also fix a logical problem in lightningd/plugin_control: we were
assuming a plugin started with 'plugin start' but which did not comport
a 'dynamic' entry in its manifest to be dynamic, though it should have
been treated as static.

Changelog-fixed: plugins: Dynamic C plugins can now be managed when lightningd is up
Co-authored-by: Rusty Russell <rusty@rustcorp.com.au>
This also remove the now duplicate plugin_hook_unregister_all(), added
in the tal destructor of the struct plugin.
Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack 77e7f0f

* This undoes opt_register[_early]_[no]arg. Returns true if the option was
* found, otherwise false.
*/
bool opt_unregister(const char *names);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, CCAN updates should be done via "make update-ccan" (optional: CCAN_NEW="". Assumes that ccan you want is in ../ccan.

Easy to fix this post, however.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it this way then withdrawn it because of the huge diff, will fix!

@@ -791,6 +791,7 @@ def test_rpc_command_hook(node_factory):
l1.rpc.plugin_stop('rpc_command.py')


@flaky
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this now @flaky?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it started failing randomly on Travis but I was not able to reproduce locally..

Btw, i can no longer restart Travis jobs.. Don't know if it's a perm error or anything

@rustyrussell rustyrussell merged commit 972b4de into ElementsProject:master Feb 9, 2020
@darosior darosior deleted the libplugin_json_stream branch February 9, 2020 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants