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

Onion TLV support (EXPERIMENTAL_FEATURE) #3167

Merged
merged 10 commits into from
Nov 14, 2019

Conversation

rustyrussell
Copy link
Contributor

No description provided.

@rustyrussell rustyrussell added this to the 0.7.4 milestone Oct 15, 2019
common/sphinx.c Show resolved Hide resolved
wait_for(lambda: 'alias' in l1.rpc.listnodes(l3.info['id'])['nodes'][0])

inv = l3.rpc.invoice(10000, "test_tlv3", "test_tlv3")['bolt11']
print(inv)
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably can delete this

@rustyrussell rustyrussell force-pushed the guilt/onion-tlv branch 2 times, most recently from 40e81d9 to 82a38a1 Compare November 5, 2019 02:20
@rustyrussell
Copy link
Contributor Author

Rebased on top of #3245

@rustyrussell rustyrussell force-pushed the guilt/onion-tlv branch 2 times, most recently from 5bb917e to dcaf848 Compare November 8, 2019 05:12
@rustyrussell
Copy link
Contributor Author

Back on top of master again...

Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

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

Looking forward to seeing this merged :-)

vsize = bigsize_get(src, 3, &raw_size);
hop_size = raw_size + vsize + HMAC_SIZE;
step->type = SPHINX_TLV_PAYLOAD;
} else {
step->type = SPHINX_INVALID_PAYLOAD;
return;
Copy link
Member

Choose a reason for hiding this comment

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

Good catch, the src[0] == 1 escape hatch got lost somewhere before.

Comment on lines +828 to +917
/* This should probably be removed, as it's just for testing */
case SPHINX_RAW_PAYLOAD:
abort();
}
abort();
Copy link
Member

Choose a reason for hiding this comment

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

Yes, if you want I can clean it up since it also touches the onion-tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The onion tool actually uses this to make an arbitrary raw payload, so we'll leave it for a bit longer.

@@ -81,6 +81,7 @@ struct route_step {
enum sphinx_payload_type type;
union {
struct hop_data_legacy v0;
struct tlv_tlv_payload *tlv;
Copy link
Member

Choose a reason for hiding this comment

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

Why not make this an instance of the struct tlv_tlv_payload instead of a pointer to it? The struct itself only consists of 3 pointers (fixed size) and we'd be saving 1 allocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our marshaling/unmarshaling really wants a pointer...

Copy link
Member

Choose a reason for hiding this comment

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

Hm, ok, I should read the TLV implementation more carefully :-)

devtools/onion.c Outdated
/* FIXME: Generic realm support, not this hack! */
/* FIXME: Multi hop! */
/* /<hex> -> raw hopdata. /tlv -> TLV encoding. */
if (argv[1 + i][klen] != '\0' && argv[1 + i][klen] != 't') {
Copy link
Member

Choose a reason for hiding this comment

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

This seems to undo some of the fixes from #3250 (https://github.com/ElementsProject/lightning/pull/3250/files#diff-6ba0afe5becbb580348286dbd8ca2b5cR63). Which version is the correct one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just rebased again on master, which fixes this...

This highlights the various places we need to change.

Signed-off-by: Rusty Russell <[email protected]>
We add routines to decode the expected fields from both legacy and tlv
hop formats.

Signed-off-by: Rusty Russell <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
Changelog-changed: JSON API: `htlc_accepted` hook has `type` (currently `legacy` or `tlv`) and other fields directly inside `onion`.
Changelog-deprecated: JSON API: `htlc_accepted` hook `per_hop_v0` object deprecated, as is `short_channel_id` for the final hop.
We keep the feature bitmap on disk, so we cache this in the struct
explicitly.

Signed-off-by: Rusty Russell <[email protected]>
Default is legacy.  If we have future styles, new strings can be defined,
but for now it's "tlv" or "legacy".

Signed-off-by: Rusty Russell <[email protected]>
For legacy, they were the same, but for TLV we care whether it's the
final hop or not.

Signed-off-by: Rusty Russell <[email protected]>
This means we can make sphinx_add_v0_hop static, too.

Signed-off-by: Rusty Russell <[email protected]>
@cdecker
Copy link
Member

cdecker commented Nov 14, 2019

ACK ed0b575

@cdecker cdecker merged commit 21555b2 into ElementsProject:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants