Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit by payer account #67

Merged
merged 13 commits into from Oct 19, 2020
Merged

Conversation

jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Oct 13, 2020

Reference: https://github.com/dapperlabs/flow-go/issues/4909

This PR implements rate limiting on transaction payer accounts. It adds two new configuration options to the collection builder module, a max rate which limits the rate at which transactions for any given payer account are included, and a set of unlimited payers which are not hindered by the rate limiting.

We do not add this rate limiting to the Mutator module because this is not part of the protocol, and inconsistent configuration between collection nodes could lead to finalization problems if we did. Conceptually this is an optional feature that is enabled and enforced independently on each collection node. When all collection nodes select the same rate limit the effect is an equivalent network-wide rate limit.

Usage

NBA/Dapper use one payer account, on mainnet we should set the flag builder-unlimited-payers=<DAPPER_ADDR>. When setting the rate limit, note that the limiting is enforced on a per-cluster basis, so the number of clusters should be factored into choosing that value.

@jordanschalm jordanschalm marked this pull request as ready for review October 14, 2020 17:53
@jordanschalm jordanschalm changed the title WIP: Rate limit by payer account Rate limit by payer account Oct 14, 2020
@jordanschalm jordanschalm marked this pull request as draft October 14, 2020 18:07
@jordanschalm
Copy link
Member Author

jordanschalm commented Oct 14, 2020

Returned to draft, going to apply some cleanup before review Finished now

the main function was already too big before adding rate limiting, this
at least mvoes some logic outside
@jordanschalm jordanschalm marked this pull request as ready for review October 14, 2020 21:15
module/builder/collection/rate_limiter.go Show resolved Hide resolved
utils/unittest/fixtures.go Outdated Show resolved Hide resolved
module/builder/collection/rate_limiter.go Show resolved Hide resolved
// remove from mempool, conflicts with finalized block will never be valid
b.transactions.Rem(txID)
continue
}

// enforce rate limiting rules
if limiter.shouldRateLimit(tx) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing rate limiting a tx would be an exception vs a norm and if that is the case then should we log.debug the tx and payer we rate limited to figure out who is abusing the system from logs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we could add a metric later "rate_limited_tx".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I won't have time before the spork we're trying to get this in for, but I'll add a note to the other issue.

@jordanschalm jordanschalm merged commit ace6bdc into master Oct 19, 2020
@jordanschalm jordanschalm deleted the jordan/4909-acct-rate-limiting branch October 19, 2020 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants