tlv: allow tlv streams to use large records
Changes the tlv package such that:
-
Decodecan decode records > 65535 bytes -
DecodeWithParsedTypescan decode records > 65535 bytes - Introduces
DecodeP2Pwhich cannot decode records > 65535 bytes - Introduces
DecodeWithParsedTypesP2Pwhich cannot decode records > 65535 bytes
This is necessary for future changes to lnd and for other projects that want larger record sizes. Untrusted input should always use the *P2P variants
After this is in and tagged, we can update the call-sites to use either the p2p or non-p2p variant
Why not update them here, or instead lave the default call be the P2P one and then have a new DecodeNonP2P etc?
Only because I am not a pro at git tagging so it is easier for me if I chunk it
cause is it not the case that with the current change, we by default now dont bound the size of untrusted input from p2p land? That way we can also keep the absurd record length unit test.
Since we didn't make lnd update to this new tlv change, the old behavior of limiting to 65kb is still used. Same for other projects that require a specific tlv package version
Other than that, LGTM! (as long as no caller of the package tries to pass in a size too big for BigSize... which is extremely unlikely since it can handle like 18 exabytes 🤓 )
We could require a max for the non-p2p case, but I wouldn't know a good value
Since we didn't make lnd update to this new tlv change, the old behavior of limiting to 65kb is still used. Same for other projects that require a specific tlv package version
oh! good point! i forgot that the tlv package had its own go.mod. My bad!
Ready to land once the release notes have been updated!
added notes
Oops, another merge requires this PR to be rebased.
Needs one more rebase!
rebased