pub async fn peer_takes_a_batch_at_its_declared_limits<F: SyncFixture>(
open: impl AsyncFn() -> F,
) -> Result<RuleOutcome, Violation>Expand description
SY-18: a peer’s declared batch limits are the limits it imposes: a push at the declared corner, which the declaration admits, lands whole.
peer_declares_its_own_limits holds the declaration to one event at a
time. This rule holds its other half, PeerLimits::max_batch_events
and PeerLimits::max_batch_bytes, to a push as large as they say. A
runner that honours them and is refused anyway has been told a limit
that is not the one imposed, and learns the real one at ingest. The
rule plays that runner. It reads [SyncPeer::limits] once, and then:
- takes the corner’s event count,
max_batch_eventscapped byMAX_PROVOKED_BATCH_EVENTS, and its bytes,max_batch_bytescapped byMAX_PROVOKED_BATCH_BYTESand by what that many events can carry with none overmax_event_bytes; - pushes the count corner: that many single-event groups with empty payloads. The declaration must admit it, and it must land, every event acknowledged as appended;
- pushes the full corner, when it has any bytes: as many single-event groups again, from a second origin, whose payloads total exactly the corner’s bytes and differ by at most one byte. The same must hold;
- pulls the whole log back: every event of both pushes is held, byte for byte, which rejects a peer that acknowledges what it dropped.
Two pushes rather than one, so a refusal names the limit that was not
imposed: the count corner carries no bytes. And the events are as small
as the corner allows, with no guard, tags or metadata, so a lie about a
per-event limit, which is peer_declares_its_own_limits’s to judge,
cannot fail this rule as well.
§Rejects
tests/wrong_peers.rs carries five, each over the reference peer:
a peer that takes fewer events to a push than it declares, and one that
declares twice the max_batch_bytes it enforces, which SY-37’s rule
also uses to attribute its skips; two that refuse at the declared
limit, >= where the declaration means >, one on the event count and
one on the bytes, which pin each corner to the declaration exactly; and
a peer that stores only the head of a large push and acknowledges all
of it, which only the pull-back sees.
§Does not reject
A peer that accepts more than it declares: a runner that reads the
declaration never sends more, so nothing is lost. Nor the refusal of a
push one byte over the declaration, which is SY-36’s Split and
every_refusal_states_its_class’s to judge. Nor a pull larger than
the declaration: the batch limits bind a push. Nor a declaration of
max_batch_events of zero, which peer_declares_its_own_limits
fails and this rule has no corner to push into, so it pushes nothing
and runs. Nor a peer whose limits are true up to the caps and false
above them, because the corner is built at the caps.
§Errors
A Violation of SY-18 if the declaration does not admit one of the
corners, if the peer refuses either push or acknowledges it as anything
but every event appended, or if an event of either is not handed back
whole; or if the peer refuses a pull or keeps handing back groups past
one pull per event pushed.