Skip to content

plugin and parameter enhancements - #2148

Merged
rustyrussell merged 13 commits into
ElementsProject:masterfrom
rustyrussell:guilt/pay-plugin
Dec 10, 2018
Merged

plugin and parameter enhancements#2148
rustyrussell merged 13 commits into
ElementsProject:masterfrom
rustyrussell:guilt/pay-plugin

Conversation

@rustyrussell

@rustyrussell rustyrussell commented Dec 7, 2018

Copy link
Copy Markdown
Contributor

Still a WIP, since it's based on a merge of master and #2141 which I both needed.

Goodies inside:

  • Plugin infrastructure cleanups (neatenings, pass-through)
  • More plugin debugability: --dev-debugger support, stderr preservation and printing bad JSON.
  • Large reorganization of param.c so it can be moved to common so plugins can share.

@wythe please take a look too, since some disentangling was required!
(BTW, please accept https://github.com/ElementsProject/lightning/invitations so I can tag you for review and bug you in future :)

@ZmnSCPxj ZmnSCPxj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did not review much, but changes to invoice and payalgo are minimal.

Comment thread lightningd/jsonrpc.c
{
*failed = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love it! So much better.

@rustyrussell

Copy link
Copy Markdown
Contributor Author

Trivial rebase on top of master now requirements have been merged...

@rustyrussell rustyrussell changed the title WIP: plugin and parameter enhancements plugin and parameter enhancements Dec 8, 2018
@cdecker

cdecker commented Dec 9, 2018

Copy link
Copy Markdown
Member

ACK c31e59d

Check if it's a normal file first, then check permissions.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This currently just invokes GDB, but we could generalize it (though
pdb doesn't allow attaching to a running process, other python
debuggers seem to).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Note that this changes the order of arguments to pipecmd to match the
documentation, so we fix all the callers!

Also make configure re-run when configurator changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Now we've updated ccan/pipecmd, we can use pipecmd_preserve to
preserve stderr for plugins so we see their error spew.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This (will) avoid the plugin having to walk back from the params object
as it currently does.

No code changes; I removed UNUSED and UNNEEDED labels from the other
parameters though (as *every* json_rpc callback needs to call param()
these days, they're *always* used).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We need these for literal copying of requests between plugin and client.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…them (much).

We simply look for the id token, and substitute it on the way in/out.
We also need to make sure output is '\n\n' terminated.

I started this because we weren't forwarding complex errors properly
(we treated them as a string), but it's also a huge simplification.

`struct plugin_rpc_request` is eliminated entirely: the information we need
is actually inside `struct command` already.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
All callers currently just hand the same arg twice, but plugins might
want this different.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
json_tok* is used with 'struct command', so rename this to match the other
low-level json tok helpers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
I want to use param functions in plugins, and they don't have struct
command.

I had to use a special arg to param() for check to flag it as allowing
extra parameters, rather than adding a one-use accessor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We can use the 'destructor-canary' trick instead.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
json_escaped.[ch], param.[ch] and jsonrpc_errors.h move from lightningd/
to common/.  Tests moved too.

We add a new 'common/json_tok.[ch]' for the common parameter parsing
routines which a plugin might want, taking them out of
lightningd/json.c (which now only contains the lightningd-specific
ones).

The rest is mainly fixing up includes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Comment thread common/param.h

#endif /* LIGHTNING_LIGHTNINGD_PARAM_H */
/* Special flag for 'check' which allows any parameters. */
#define p_opt_any() "", false, NULL, NULL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nicely done. This approach crossed my mind at some point but then it was gone. Its clearly better 👍

@wythe

wythe commented Dec 9, 2018

Copy link
Copy Markdown
Contributor

ACK c31e59d

param/json stuff looks great.

@rustyrussell
rustyrussell merged commit d7e233e into ElementsProject:master Dec 10, 2018
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.

4 participants