mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
test: Add test for CompactSize larger than MAX_SIZE value #36853
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36853
Loading…
Reference in a new issue
No description provided.
Delete branch "2611-test-CompactSize-MAX_SIZE"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently there is no test coverage for oversized CompactSize. This is fine, because a vector this large will already be rejected earlier by the P2P transport payload size check.
However, it would be good to still add test coverage:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Mutation:
No verified findings are available from this review.
Review coverage was incomplete.
Reviewed:
fa5aabe5a076· Review report · Previous reportspermalink
Quite nuanced to track down! Fixing this will help with coverage determinism.
Concept ACK
If this is useful to anyone, here a script that reproduces the non-determinism in coverage. With this PR applied it is fixed.
Script
An alternative would be to just replace the code with
assert(false)and then run the functional tests. Sometimes they pass, sometimes they fail.There's another one in the compactsize test. Should that be dropped too?
Perhaps:
Is there a reason you opted for a generic lambda here and not a parameter called RangeCheck? More for my understanding than a nit.
This just checks 5 byte values and I did consider if we should also check 9 byte values but I don't think it really adds anything.
In this situation it looks like the node will log the error but won't do any
Misbehavingbehaviour or anything. Do we think this is correct? It's just a malformed message I guess and not necessarily a large message.It is impossible to enumerate all cases of "misbehavior" and it can also be net-split risky to mark something as misbehavior when ancient (pre-bip) protocol may have allowed it.
The p2p protocol message size limit was added in
ba04c4a780without a bip, so making MAX_SIZE+1 compactsize a misbehavior may be controversial and difficult to review.In any case, this is a test-only pull, so I am not allowed to change misbehavior here. Also, to give more examples, https://github.com/bitcoin/bitcoin/pull/36906 goes the opposite way and changes a bad-txns-oversize from misbehavior to an ignored deser error.
To also give an example where a new misbehavior is added based on a bip text: https://github.com/bitcoin/bitcoin/pull/35550
Edit: Looks like https://github.com/bitcoin/bitcoin/pull/36906#discussion_r4629650852 may take care of it:
right, this should be sufficient
thx, took all nits
Only if there is a further change to this PR I wonder if there should be a comment to reference where this is from (
src/serialize.h)?ACK
fa01715b96Tested ACK
fa5aabe5a0compactsize_value_range) and functional (test_corrupt_compactsize) tests fail when applying the same mutationThe latest force push (
fa0899b364) includes the 9-byte check. Just to clarify since the 5-byte case was considered sufficient, did you add it because we don't have any tested 9-byte round-trip in the suite without this?reACK
fa5aabe5a0Yes, I think there was no round-trip test: I added it for the
/*range_check=*/falsecoverage. Thesize too largecoverage was "free", so I guess it can't hurt 😅