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

Tweak checkrune API (nodeid isn't required) and update docs. #6622

Merged

Conversation

rustyrussell
Copy link
Contributor

@rustyrussell rustyrussell commented Aug 26, 2023

Builds on #6617 (Rebased on master)

Also tighten our rune checking on our own runes which were generated from other code (a theoretical possibility), and make sure we only add valid restrictions...

Comment on lines 676 to +725
} else if (streq(alt->fieldname, "id")) {
const char *id = node_id_to_hexstr(tmpctx, cinfo->peer);
return rune_alt_single_str(ctx, alt, id, strlen(id));
if (cinfo->peer) {
const char *id = node_id_to_hexstr(tmpctx, cinfo->peer);
return rune_alt_single_str(ctx, alt, id, strlen(id));
}
return rune_alt_single_missing(ctx, alt);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me check if I understand these lines correctly:

  1. We have an alternative with with a fieldname id
  2. We check if we got a (now optional) nodeid, that should reside in cinfo->peer
  3. If so, check the id against the alternatives rule.
  4. If not, check if the alternative is of "missing field" type (or comment).
    If this is correct, this seems likely the correct way to treat a field set of <id> requested <method> with <params> at <time> with request <rate>.

This however makes the "optional" arguments for checkrune not as "optional" as it might seem. We may consider adding 1 or 2 sentences to the docs that explain the behavior and the implications that an "unset" argument has.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

? Every optional field (e.g. parameter names) is the same. They fail any test (comparison, equality, etc), except the "not present" test.

This cannot break any existing usage, since that always sets id. I can't think of what I would document here?

There's actually no "filter" here, this was mistakenly taken from commando.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Usage line isn't correct, as fields are not optional, and return
needs fleshing out for error codes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
nodeid is only useful when we know the peer we're talking to (e.g. commando).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
No-schema-diff-check: We're simply making optional, not deprecating!
These look like uniqueids, and so can confuse us (I discovered this by
making a typo in a test!)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This was a misunderstanding: nodeid is useful for commando, where it's the
peer's nodeid, and Noise-XK guarantees that we know who that is.  It's
not useful for clnrest, so don't require it (it was our node id, which
is redundant).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It always is for runes we create, but in theory you can take our secret key
and make our own runes with your own tools.

(We correctly refuse runes without uniqueids if they're *not* ours
anyway: uniqueid is only used for our own runes).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This seems to be a cut & paste bug (mine, AFAICT!) from the command code:

```
	rune = rune_derive_start(cmd, master_rune,
				 tal_fmt(tmpctx, "%"PRIu64,
					 rune_counter ? *rune_counter : 0));
```

In that case, rune_counter was a pointer, which could be NULL.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell merged commit 2765939 into ElementsProject:master Sep 12, 2023
39 checks passed
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.

None yet

2 participants