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

Relay : 'Hop' spec supports zero limit, but the impl does not #5170

Closed
RustMania opened this issue Feb 19, 2024 · 3 comments · Fixed by #5244
Closed

Relay : 'Hop' spec supports zero limit, but the impl does not #5170

RustMania opened this issue Feb 19, 2024 · 3 comments · Fixed by #5244

Comments

@RustMania
Copy link

Description

Hello, I m strugglinhg to establish connections to a relay, where limits are not applied.
I m not quite sure whether this is a bug or a wrong API usage, so that I post it to the enhancement category.

According to the spec relay-2.0:

The limit field in HopMessage, if present, provides information about the limits applied by the relay in relayed connection. When omitted, it indicates that the relay does not apply any limits.

The struct has the following fields:

Limit {
 duration = ...
 data = ...
}
the duration field indicates the maximum duration of a relayed connection in seconds; if 0, there is no limit applied.
the data field indicates the maximum number of bytes allowed to be transmitted in each direction; if 0 there is no limit applied.

To establish long-lived connections w/o data limits my relay app sets default values for these , max_circuit_bytes and max_circuit_duration, before the swarm is initialised. However setting them to zeros does not negotiate "no limit" condition. E.g. setting the duration to zero causes the relay to open the connection and close it instantly with a timeout error.
The obvious workaround is to set these values to high limits ( and it works), however such cornering is impractical in production cases.

Motivation

see above

Current Implementation

see above

Are you planning to do it yourself in a pull request ?

Yes

@dariusc93
Copy link
Member

Interesting. I've looked over the relay spec so many times and i somehow overlooked this part. Should be a simple change internally. Likely more in CopyFuture if my memory serve me correctly.

@drHuangMHT
Copy link
Contributor

I simply set max_circuit_bytes to u64::MAX, which is like 16EB? Basically no limit but if the spec says so it's best implemented as-is.

@drHuangMHT
Copy link
Contributor

Have you got the PR working on? I would like to take this if you don't mind. @RustMania

mergify bot pushed a commit that referenced this issue Apr 4, 2024
Allow relay to forward unlimited bytes from one peer to another by checking if `max_circuit_bytes` equals to 0 before checking if `bytes_sent` exceeds `max_circuit_bytes`.
This will make current implementation follow the spec.
May close #5170.

Pull-Request: #5244.
@mergify mergify bot closed this as completed in #5244 Apr 4, 2024
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 a pull request may close this issue.

3 participants