-
Notifications
You must be signed in to change notification settings - Fork 471
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
api: Disable body limit middleware for admin endpoints. #5486
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure exactly what the behavior of this middleware is, but I think I'd like to see some limit, even on admin access. Otherwise, I suspect algod can be crashed by a request that just never ends. Eventually the server exhausts memory by reading arbitrary data.
I guess you could say, "well, admins can crash the server" and I'm actually somewhat sympathetic to that if it's annoying to implement. But if it's just a different limit in the admin middleware, let's do it, with maybe 100mb?
"admins can crash the server" was my thinking here. It would also be simple to add different middlewares for each set of endpoints, but is 100MB is the right number? Without some rational about why there should be a limit and what it should be, I'd rather leave it open. |
10mb had no rationale beyond "not large enough to exhaust memory, and should be enough for anything" But we forgot part keys. So let's pick a value that still won't exhaust memory, but is big enough for the number of part keys we want to support. By the way, what I'm really worried about is that leaving it open means that a request could be arbitrarily large, even before it is authenticated as admin. |
I don't know if this alleviates the concern, but the token check happens ahead of any reading. So you don't need to worry about this part. Since it's rate limiting is implemented as a middleware, the enforcement needs to happen inline to the handler call chain. It does so using two mechanisms, each of these happen ahead of our handler code:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but needs rebase
indexer_test.go:88:
Error Trace: /opt/cibuild/project/node/indexer/indexer_test.go:88
/opt/cibuild/project/node/indexer/suite.go:132
/opt/cibuild/project/node/indexer/indexer_test.go:164
* create a test for EntityTooLarge error * move request body limit to test * move test to v2 * update request str
ca607f5
to
f3921c2
Compare
Codecov Report
@@ Coverage Diff @@
## master #5486 +/- ##
==========================================
+ Coverage 55.41% 55.72% +0.31%
==========================================
Files 446 446
Lines 63289 63291 +2
==========================================
+ Hits 35069 35267 +198
+ Misses 25826 25652 -174
+ Partials 2394 2372 -22
... and 35 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
10 million rounds (at the long end) is what we would recommend as maximum if you do NOT have a large amount of stake: 4.3s era 10m rounds = 497.7 days I'm not inclined to recommend increasing this number, as longer than 1 year still seems too long. That said, a 10m round participation key with dilution of 3162 is 192 MB, so I think an admin cap of, say, 250 MB might be sufficient. However, as this is limited to admin operations, I'm also inclined to leave it out, but your mileage may vary. |
Summary
Disable body limit middleware for admin endpoints.
Test Plan
Unit test.