DAWN-80 ⁃ Computational Rate Limiting
Over a configured "per-code-account-transaction-msg-rate-limit-time-frame-sec" time frame, each account will be allowed "per-code-account-transaction-msg-rate-limit" transaction messages. For every message on a transaction, its code account will be tracked. If a message exceeds this rate limit, it will be rejected with a tx_msgs_code_exceeded exception.
Acceptance tests:
- In the config file, set an appropriate per-code-account-transaction-msg-rate-limit-time-frame-sec and per-code-account-transaction-msg-rate-limit to allow for easier testing (setting the time frame longer will give more time to observe its effect and setting rate limit lower will allow you to more quickly hit the limit)
- Construct many transfer transaction messages, using one code account, with the different messages having different authorized accounts. Also construct another transfer transaction message with a different code account.
- Send the many transfer transaction messages with the same code account, until the per-code-account-transaction-msg-rate-limit is hit and verify no more are accepted for that code account. Then send the transfer transaction message with the other code account and verify it is accepted.
- Keep doing this over time to observe the time frame's affects:
- Once limit is reached, waiting a second will allow (per-code-account-transaction-msg-rate-limit / per-code-account-transaction-msg-rate-limit-time-frame-sec) transaction messages to be accepted
- If you wait per-code-account-transaction-msg-rate-limit-time-frame-sec, then per-code-account-transaction-msg-rate-limit-time transaction messages can be sent in a second
➤ Kevin Heifner commented:
[~admin] We understand this to be the same algorithm as STAT-81, applied to account contract code instead of scoped accounts.
➤ David Moss commented:
[~kevin.heifner] Yes.
➤ Brian Johnson commented:
Did peer review of production code with Kevin. Now working on component tests.
➤ Joshua Lavin commented:
[~brian.johnson] Can you please add the details of the rate limiting algo to the ticket so we can properly review and QA? Thanks!
Resolved by #615