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

fuzz-tests: Add fuzz target for closing_complete #8216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Chand-ra
Copy link

@Chand-ra Chand-ra commented Apr 6, 2025

closing_signed and closing_complete are channel closing negotiation messages defined in BOLT #2.

While closing_signed has a wire fuzz test, closing_complete does not. Add a test to perform a round-trip encoding check (towire -> fromwire) similar to the other wire fuzzers.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

@vincenzopalazzo
Copy link
Collaborator

Probably the best person to review this code is @morehouse

@Chand-ra
Copy link
Author

Chand-ra commented Apr 9, 2025

Probably the best person to review this code is @morehouse

Yeah, I've had a conversation with him over mail. He said he'd get around to it soon.

Comment on lines 35 to 37
size_t upto_closer_scriptpubkey = (uintptr_t)&x->closer_scriptpubkey - (uintptr_t)x;
if (memcmp(x, y, upto_closer_scriptpubkey) != 0)
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned that some architectures may pad/align struct members to 8 bytes, which means there would be 4 bytes of uninitialized padding between locktime and fee_satoshis that could trigger false positives.

If we want to use the memcmp trick, we should probably move locktime to after fee_satoshis and then manually compare fields starting with locktime and thereafter.

Copy link
Author

Choose a reason for hiding this comment

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

The memcmp dance takes as much lines as individually comparing struct closing_complete's members, so I've replaced the former with the latter in the latest push.

@morehouse
Copy link
Contributor

Also would be good to add a minimal input set as a seed corpus.

Chandra Pratap added 2 commits April 12, 2025 07:31
Changelog-Added: 'closing_signed' and 'closing_complete'
are channel closing negotiation messages defined in BOLT ElementsProject#2.

While 'closing_signed' has a wire fuzz test, 'closing_complete'
does not. Add a test to perform a round-trip encoding check
(towire -> fromwire) similar to the other wire fuzzers.
Add a minimal input set as a seed corpus for the newly introduced
test. This leads to discovery of interesting code paths faster.
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