feat: Introduce msg_limit for application subnets in payload builder #1798
+37
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After inducting a stream slice, the number of signals in the outgoing stream is equal to number_of_signals_after_gcing + number_of_messages_inducted. So if we want to cap the number of signals in a stream at 50k, we can induct no more than 50k - number_of_signals_after_gcing number of messages.
Gc'ing signals is done using begin in the stream slice, so number_of_signals_after_gcing = outgoing_stream_signals_end - incoming_slice_begin; the signals_end of the outgoing stream is given by
message_index
ofExpectedIndices
.One way or another this means we now have a cap on how many messages we can extract from the slice pool in any case. Since there already is a mechanism for limiting the number of messages called
msg_limit
it seems logical to modify this accordingly. Note that this is not handed in from outside but rather initialized by the functionget_msg_limit()
inget_xnet_payload_impl()
andvalidate_slice()
. To include what I laid out out above inget_msg_limit()
, I need thesignals_end
of the outgoing stream and thebegin
of the stream slice we want to extract.In
validate_slice()
both are available, inget_xnet_payload_impl()
thebegin
of the stream slice is not. Butmsg_limit
is only passed down to a place where it is.What this PR does is move the call to
get_msg_limit()
further down to where all the variables are available. All I have to do for that is pass a reference to the state rather than themsg_limit
.