-
Notifications
You must be signed in to change notification settings - Fork 76
directory: limit V1 requests to 7168 bytes #1025
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
base: master
Are you sure you want to change the base?
Conversation
This ensures that the OHTTP relay will not be able to distinguish v1 from v2 responses to the receiver.
Pull Request Test Coverage Report for Build 17336830025Details
💛 - Coveralls |
DanGould
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the desire to reduce the size but I'm not sure if 7168 is the right number. This is major bike shedding anyhow.
Unless this is enforced by sender clients, does this really help? Yes backwards-compatible v2 receivers of other implementations should respond with a standard size. ours use ohttp_encapsulate which pads to the same 8192 byte length already when responding to v1.
I did confirm PjV2MsgA/PjV2MsgB are both 7168 so that this payload would be the same size, but I'm not sure it would produce the same sized OHTTP request. I think v1 buffers up 8104 bytes to be the same size as BHTTP requests so the underlying HTTP content would need to be that minus whatever control/info/header information BHTTP encapsulates.
See:
let mut bhttp_req = [0u8; PADDED_BHTTP_REQ_BYTES];
|
I should have rewritten the commit message, it predates me verifying that the directory pads responses, details below (originally i was going to open another PR for that, realized i didn't need to but forgot to update this one). If the sender is v1, and sends a too large request, the directory will truncate that when responding to the receiver's GET request: rust-payjoin/payjoin-directory/src/lib.rs Line 211 in fe9a5c6
If it wasn't truncated then the receiver would still not be able to reply because the response will almost certainly be larger (if the sender's inputs have very large witness data, e.g. labitbus, then this might not be the case #fixthefilters) Anyway, for this reason it's better to reject these requests earlier, giving an error to the sender, instead of giving the receiver a truncated request. This will generate a content length mismatch error in the receiver's state machine and that's not a replyable error. As for the actual size, I chose that for simplicity and consistency with the requests. Technically it could be allowed to be up to BHTTP_REQ_BYTES - response overhead (status and empty headers?) and still be representable without truncation, but because the receiver needs to reply to it with a proposal request I don't think we can put a precise number on that due to the receiver adding its own inputs with arbitrary weight. Setting it to BHTTP_REQ_BYTES - overhead seems less conservative as far as facilitating a payjoin, but i guess it ensures that the sender can at least receive the request in full and choose to broadcast the fallback if it fails to construct a response that fits. |
|
ah no i remembered correctly, first the full body is written and then the serialized bhttp response is possibly truncated: rust-payjoin/payjoin-directory/src/lib.rs Line 209 in fe9a5c6
|
This ensures that the OHTTP relay will not be able to distinguish v1 from v2 responses to the receiver.
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.