rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

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

Open RustMania opened this issue 1 year ago • 2 comments

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

RustMania avatar Feb 19 '24 08:02 RustMania

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.

dariusc93 avatar Feb 19 '24 19:02 dariusc93

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 avatar Feb 21 '24 09:02 drHuangMHT

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

drHuangMHT avatar Mar 11 '24 12:03 drHuangMHT