-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: types: apply a max length when decoding events #11054
Conversation
Ok, so, this is the maximum number of events as emitted by the FVM when encoded as an array.
6M events per epoch is probably safe, but I'm inclined to simply move |
Another option would be to not pre-allocate a slice larger than N. If someone passes an enormous blob into there and gets, let's say, 30x expansion, it is bad but not as bad as passing a couple hundred bytes and OOMing. |
Seems missing tests |
Wait, no it's not? These are the events emitted by a single message, which is bounded by block gas limit?
Seems reasonable, gonna do that, that definitely derisks this from future danger. Okay if I keep the max limit anyway? |
fevm_events_test covers relevant cases, I think? |
c13d123
to
68c4738
Compare
Uh, yes, nvm. You're right. |
Only if we end up logging and dropping in that case, but even then I don't think it matters. Returning an error here will make nodes recording events halt. |
68c4738
to
dd84f11
Compare
dd84f11
to
0796546
Compare
Related Issues
A security report pointed out the unbounded allocation here, which could be problematic. In practice, this is not a problem, since we can trust the FVM not too return dangerously large data, which can in turn trust gas costs to not allow several GiBs of events.
Proposed Changes
Despite that, we might as well apply some limit here. I settled on 6 million, since it seems like a good theoretical limit, given that a single message can't use more than 10 Billion gas (block gas limit), and a single event must cost at least 1750 gas, leading to a theoretical max of 5.7 Million entries.
I'm happy to use something bigger or smaller, this number is only consensus critical for folks actually decoding events, which Lotus doesn't do by default.
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps