Skip to content

wire: Reject invalid tx trees early. - #3815

Merged
davecgh merged 2 commits into
decred:masterfrom
davecgh:wire_early_invalid_tree_reject
Sep 27, 2026
Merged

davecgh merged 2 commits into
decred:masterfrom
davecgh:wire_early_invalid_tree_reject

Conversation

@davecgh

@davecgh davecgh commented Sep 25, 2026

Copy link
Copy Markdown
Member

This modifies the code that deals with serializing and deserializing outpoints to be more restrictive and immediately reject any values that result in obviously invalid trees.

Such outpoints are always ultimately invalid, so it is preferable to reject them early to avoid unnecessary work that will ultimately be discarded.

It also adds explicit tests for reading and writing outpoints independently of the larger structures that contain them.

The code is already indirectly tested fairly well since it is used as a part of larger structures that are themselves tested. However, testing the operations independently makes it easier to add specific cases and exercise relevant error paths.

Finally, the tests also exercise truncated reads and short writes at each serialization boundary.

@davecgh davecgh added this to the 2.2.0 milestone Sep 25, 2026
This modifies the code that deals with serializing and deserializing
outpoints to be more restrictive and immediately reject any values that
result in obviously invalid trees.

Such outpoints are always ultimately invalid, so it is preferable to
reject them early to avoid unnecessary work that will ultimately be
discarded.
This adds explicit tests for reading and writing outpoints independently
of the larger structures that contain them.

The code is already indirectly tested fairly well since it is used as a
part of larger structures that are themselves tested.  However, testing
the operations independently makes it easier to add specific cases and
exercise relevant error paths.

The tests also exercise truncated reads and short writes at each
serialization boundary.
@davecgh
davecgh force-pushed the wire_early_invalid_tree_reject branch from cfb77e2 to 6f6cf21 Compare September 27, 2026 22:59
@davecgh
davecgh merged commit 6f6cf21 into decred:master Sep 27, 2026
32 checks passed
@davecgh
davecgh deleted the wire_early_invalid_tree_reject branch September 27, 2026 23:02
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