Rate-limiting AggLayer transaction settlement #213
Replies: 4 comments 13 replies
-
Thanks for the proposal ! Some adjustments that we may need: epochsFor configsFor configuration, I think that the config example has a little issue on how to handle custom configuration. The general idea is to have the global configuration, that also offer customization per network. Also, tagging that it's for RPCs can be better for the future iteration: # Default rate limiting
[rate-limiting.rpc.send-certificate]
limit-per-epoch = 1
[rate-limiting.rpc.send-tx]
time-limit = 1
time-interval = "1h"
# Configuration overrides for network #1
[rate-limiting.rpc.network.1.send-tx]
time-limit = 1
time-interval = "15min"
[rate-limiting.rpc.network.1.send-certificate]
limit-per-epoch = 2
For the disabling the rate limiting, I think there are two propositions in the post:
I think that the
It could be, but not for now, if we need to change the rate limiting we need to change the config and reboot. RPCs error code needs to be documented somewhere too :) |
Beta Was this translation helpful? Give feedback.
-
Thanks to @Freyskeyd for the comments. There is one point he made that's a bit more general and deserves a separate discussion. It revolves around the structure of the configuration file with respect to per-network overrides. Basically we have two competing options here. In the following, I assume there is a possibility that there might be other options that are configurable on a per-network basis in the future. Option A) Grouping the per-network overrides with the option in question# General options from category A
[categoryA]
option1 = "..."
option2 = "..."
# Category A options overrides for network 1
[categoryA.networks.1]
option1 = "..."
option2 = "..."
# Category A options overrides for network 2
[categoryA.networks.2]
option2 = "..."
# General category B options
[categoryB]
option3 = "..."
# Category B options overrides for network 1
[categoryB.networks.1]
option3 = "..." Option B) Grouping all the network-specific options into its own sectionThis hoists the per-network configuration to the top level and groups all the network-specific options together. This is how the above example could look like. (Please note that the file format is ambiguous since the user can decide how to break the file down into sections. The format below would make sense to me.) # General options
[categoryA]
option1 = "..."
option2 = "..."
[categoryB]
option3 = "..."
# Overrides for network 1
[networks.1]
categoryA.option1 = "..."
categoryA.option2 = "..."
categoryB.option3 = "..."
# Overrides for network 2
[networks.2]
categoryA.option2 = "..." Trade-offs
I am in favour of Option B, where the network sub-sections mimick the general part of the config file. It also seems to me more natural fit when adding new network specific configuration. Thoughts / comments? |
Beta Was this translation helpful? Give feedback.
-
Posting here the updated document. It's been modified based on the feedback so far. Version 2. This document proposes a mechanism and an interface specification of limiting the rate of L1 transaction settlement AggLayer performs on behalf of participating chains. This is needed to avoid excessive L1 fees. Requirements
Non-goals:
ConfigurationThe rate limit is specified as the maximum number of settlements The period is specified as:
An example configuration: # Default rate limiting
[rate-limiting.rpc.send-certificate]
max-per-epoch = 1
[rate-limiting.rpc.send-tx]
max-per-interval = 1
interval-duration = "1h"
# Configuration overrides for network #1
[rate-limiting.rpc.network.1.send-tx]
max-per-interval = 1
interval-duration = "15min"
[rate-limiting.rpc.network.1.send-certificate]
max-per-epoch = 2
[rate-limiting.rpc.network.2]
# No rate limit applied for network 2
send-tx = "unlimited"
send-certificate = "unlimited"
[rate-limiting.rpc.network.3]
send-certificate = "unlimited" # No rate limit for sendCertificate RPC applied for network 3
RPC responsesWhen a network is rate-limited, a response is issued indicating the reason. The jsonrpc 2.0 Error object is used to communicate the request has been rate limited. Rate-limited
|
Beta Was this translation helpful? Give feedback.
-
Updated based on what has actually been implemented the pull request so far. Only
Rate-limiting AggLayer transaction settlementVersion 3. This document proposes a mechanism and an interface specification of limiting the rate of L1 transaction settlement AggLayer performs on behalf of participating chains. This is needed to avoid excessive L1 fees. Requirements
Non-goals:
ConfigurationThe rate limit is specified as the maximum number of settlements The period is specified as:
An example configuration: # Default rate limiting
[rate-limiting.send-certificate]
max-per-epoch = 1
[rate-limiting.send-tx]
max-per-interval = 1
interval-duration = "1h"
# Configuration overrides for network #1
[rate-limiting.network.1.send-tx]
max-per-interval = 1
interval-duration = "15min"
[rate-limiting.network.1.send-certificate]
max-per-epoch = 2
[rate-limiting.network.2]
# No rate limit applied for network 2
send-tx = "unlimited"
send-certificate = "unlimited"
[rate-limiting.network.3]
send-certificate = "unlimited" # No rate limit for sendCertificate RPC applied for network 3
RPC responsesWhen a network is rate-limited, a response is issued indicating the reason. The jsonrpc 2.0 Error object is used to communicate the request has been rate limited. Rate-limited
|
Beta Was this translation helpful? Give feedback.
-
UPDATE: This document has been updated a couple of times. The initial version remains below for historical reference. Updates are posted in subsequent posts. Please
Version history
Rate-limiting AggLayer transaction settlement
Version 1.
This document proposes a mechanism and an interface specification of limiting the rate of L1 transaction settlement AggLayer performs on behalf of participating chains. This is needed to avoid excessive L1 fees.
Requirements
sendTx
- limit the number of transactions submitted within given time interval.sendCertificate
- limit the number of transactions submitted within a specified number of epochs.Non-goals:
Configuration
The rate limit is specified as the maximum number of settlements
N
over given periodT
.The period is specified as:
An example configuration:
The
time-limit
andtime-interval
keys apply limits tosubmit_transaction
calls. Similarly, theepoch-limit
andepoch-interval
keys apply limits tosubmit_certificate
calls.epoch-limit
andtime-limit
keys are natural numbers (including0
) specifying the number of submissions.epoch-interval
is a non-zero natural number specifying the epoch count.time-interval
is a string giving a time duration within which the limit is enforced. Units such as3h
or15min
are allowed.Note that setting
time-limit
orepoch-limit
to0
effectively disables the transaction-based settlement or certificate-based settlement, respectively.RPC responses
When a network is rate-limited, a response is issued indicating the reason. The jsonrpc 2.0 Error object is used to communicate the request has been rate limited.
Rate-limited
sendTx
responseWhere:
CALL_ID
is the ID of the call we're responding toLIMIT
andINTERVAL
are the rate limiting parameters configured for this networkINTERVAL
is an integer specifying the number of secondsEARLIEST_FREE
is the timestamp at which the current rate limit expires and re-submitting the request is expected to pass the rate limiterRate-limited
sendCertificate
responseWhere:
CALL_ID
is the ID of the call we're responding toLIMIT
andINTERVAL
are the rate limiting parameters configured for this networkINTERVAL
is an integer specifying the number of epochsEARLIEST_FREE
is the epoch number at which the current rate limit expires and re-submitting the request is expected to pass the rate limiterOpen questions
Some discussion points and design alternatives.
Handling of interactions between epoch-based and time-based rate limiting
We have both time limit (for transactions) and epoch limit (for certificates). These potentially interact in subtle ways. In principle, a network should not use both tx submission and certificate submission, but the possibility still has to be handled.
Some options:
Option to disable rate limiting
In principle,
{time,epoch}-limit = false
configuration option could be introduced to disable rate limiting altogether, whether by default or on per-network basis. Should this option be implemented?Rate limiting configuration flexibility
The configuration section above proposes the rate limit is specified using two parameters, the limit
N
and intervalT
.Note that limiting submissions to 1 in 10min (
N=1, T=10min
) is not the same as 3 submissions in 30min. Although in the long run, these are expected to have about the same gas consumption.The design space here is quite rich:
N
parameterN=1
, i.e. spacing of submissions at leastT
The answer to this for time-based rate limiting may be different from the answer for the epoch-based limiting.
Changing rate limits online
Should it be possible to change the rate limits without restarting the node? A privileged authenticated admin-level RPC endpoint would be introduced to make it possible.
Implementation notes
Potentially useful libraries and tools:
jsonrpsee
middleware +tower
humantime
crate for time interval parsingCare must be taken to properly authenticate the network ID before rate limiting is applied to prevent malicious actors from exhausting somebody else's quota.
Conclusion
This is to start a discussion about L1 submission rate limiting. Any comment and/or something missing, please discuss below.
Also please tag anyone who might be interested in this.
Beta Was this translation helpful? Give feedback.
All reactions