feat(truapi-provider): cap the light client's live connections - #817
Conversation
|
CI Status: 18 required jobs green, 15 passed and 3 skipped by path filter. All job results
Commit |
TarikGul
left a comment
There was a problem hiding this comment.
Checked the accounting rather than reading it. One construction site, one increment, one decrement, and everything after guard.connections += 1 is infallible so no error path leaks a slot. The decrement sits under the lock after the closed.swap guard so a double close cannot double decrement, and refuse is a method not a constructor, so there is no unbalanced path to underflow. The FFI closes through LightConnection::close too, so the cap holds there.
Your verification claim holds. I mutation tested both new tests: deleting the decrement fails the cap test, and making a parachain's borrowed relay also spend a slot fails the parachain test. The clippy note checks out as well, provider.rs:221 fires on main too.
One gap inline. Counting in its own field rather than summing added refcounts is the right call and the parachain test documents why.
TarikGul
left a comment
There was a problem hiding this comment.
Approving so this is not a blocker. The cap itself is correct and both new tests are pinned.
The Drop nit above still stands, it is a missing test rather than a defect, so worth picking up here or as a follow up.
Closes the last open decision on #463: the cap belongs in the provider.
The embedded light client holds at most 32 connections at once. A
connectpast that is refused withProviderError::TooManyConnections, and closing one hands its slot back.Why the provider. Every resource a connection costs is allocated here and is invisible to whoever holds it: an
add_chainwith its own request queue and response stream, aMAX_UNDELIVERED_FRAMESchannel, and on the FFI path apump thread's stack. The crate also ships standalone, into processes with no TrUAPI host in them. And a host-side cap
could not bind:
ChainRuntime::connection_forsingle-flights the providerconnectper genesis hash, and the catalogis eight chains, so a host sits at eight against a ceiling of 32.
Not covered.
ws/RpcNodeconnections never reachLightStateand stay uncapped; only the WASM build compilesthat backend. Each README states that boundary.
Verification. fmt, clippy
--all-featuresand 91 tests pass, under every feature set CI builds includingwasm32-unknown-unknown. Each test is pinned against the mutation it exists to catch, including theAddedChain::refcountsum that the counter's field doc argues against.clippy --no-default-features --features uniffialready fails onmain(provider.rs:221, a new nightly lint),independently of this branch.